@@ -4,20 +4,29 @@ import { SetRequired } from 'type-fest' // eslint-disable-line n/no-missing-impo
44export type CompanionActionWithCallback = SetRequired < CompanionActionDefinition , 'callback' >
55
66import { CompanionActionDefinitions } from '@companion-module/base'
7- import { GetDropdown , GetMuteDropdown } from '../choices/common.js'
7+ import { GetDropdown , GetMuteDropdown , GetNumberField } from '../choices/common.js'
88import { InstanceBaseExt } from '../types.js'
99import { WingConfig } from '../config.js'
1010import * as ActionUtil from './utils.js'
1111import { ConfigurationCommands } from '../commands/config.js'
1212import { StateUtil } from '../state/index.js'
1313import { getIdLabelPair } from '../choices/utils.js'
14+ import { getTalkbackOptions , getTalkbackModeOptions , getTalkbackIndividualOptions } from '../choices/config.js'
1415
1516export enum CommonActions {
1617 // Solo
1718 SetSoloMute = 'set-solo-mute' ,
1819 SetSoloDim = 'set-solo-dim' ,
1920 SetSoloMono = 'set-solo-mono' ,
2021 SetSoloLRSwap = 'set-solo-swap' ,
22+
23+ // Talkback
24+ TalkbackOn = 'talkback-on' ,
25+ TalkbackMode = 'talkback-mode' ,
26+ TalkbackMonitorDim = 'talkback-monitor-dim' ,
27+ TalkbackBusDim = 'talkback-bus-dim' ,
28+ TalkbackAssign = 'talkback-destination' ,
29+ TalkbackIndividualLevels = 'talkback-individual-levels' ,
2130}
2231
2332export function createConfigurationActions ( self : InstanceBaseExt < WingConfig > ) : CompanionActionDefinitions {
@@ -126,6 +135,112 @@ export function createConfigurationActions(self: InstanceBaseExt<WingConfig>): C
126135 ensureLoaded ( cmd )
127136 } ,
128137 } ,
138+ ////////////////////////////////////////////////////////////////
139+ // Talkback
140+ ////////////////////////////////////////////////////////////////
141+ [ CommonActions . TalkbackOn ] : {
142+ name : 'Talkback On' ,
143+ description : 'Enable or disable the on state of a talkback.' ,
144+ options : [
145+ GetDropdown ( 'Talkback' , 'tb' , getTalkbackOptions ( ) ) ,
146+ GetDropdown ( 'On/Off' , 'on' , [ getIdLabelPair ( '1' , 'On' ) , getIdLabelPair ( '0' , 'Off' ) ] ) ,
147+ ] ,
148+ callback : async ( event ) => {
149+ const cmd = ConfigurationCommands . TalkbackOn ( event . options . tb as string )
150+ const val = event . options . on as number
151+ send ( cmd , val )
152+ } ,
153+ } ,
154+ [ CommonActions . TalkbackMode ] : {
155+ name : 'Talkback Mode' ,
156+ description : 'Set the mode of a talkback channel.' ,
157+ options : [
158+ GetDropdown ( 'Talkback' , 'tb' , getTalkbackOptions ( ) ) ,
159+ GetDropdown ( 'Mode' , 'mode' , getTalkbackModeOptions ( ) ) ,
160+ ] ,
161+ callback : async ( event ) => {
162+ const cmd = ConfigurationCommands . TalkbackMode ( event . options . tb as string )
163+ const val = event . options . mode as string
164+ send ( cmd , val )
165+ } ,
166+ } ,
167+ [ CommonActions . TalkbackMonitorDim ] : {
168+ name : 'Talkback Monitor Dim' ,
169+ description : 'Set the the monitor dim amount of a talkback channel.' ,
170+ options : [
171+ GetDropdown ( 'Talkback' , 'tb' , getTalkbackOptions ( ) ) ,
172+ GetNumberField ( 'Dim [dB]' , 'dim' , 0 , 40 , 1 , 10 , true ) ,
173+ ] ,
174+ callback : async ( event ) => {
175+ const cmd = ConfigurationCommands . TalkbackMonitorDim ( event . options . tb as string )
176+ const val = event . options . dim as number
177+ send ( cmd , val , true )
178+ } ,
179+ } ,
180+ [ CommonActions . TalkbackBusDim ] : {
181+ name : 'Talkback Bus Dim' ,
182+ description : 'Set the the bus dim amount of a talkback channel.' ,
183+ options : [
184+ GetDropdown ( 'Talkback' , 'tb' , getTalkbackOptions ( ) ) ,
185+ GetNumberField ( 'Dim [dB]' , 'dim' , 0 , 40 , 1 , 10 , true ) ,
186+ ] ,
187+ callback : async ( event ) => {
188+ const cmd = ConfigurationCommands . TalkbackBusDim ( event . options . tb as string )
189+ const val = event . options . dim as number
190+ send ( cmd , val , true )
191+ } ,
192+ } ,
193+ [ CommonActions . TalkbackAssign ] : {
194+ name : 'Talkback Assign' ,
195+ description : 'Enable, disable or toggle the assignment of a talkback to a bus, matrix or main.' ,
196+ options : [
197+ GetDropdown ( 'Talkback' , 'tb' , getTalkbackOptions ( ) ) ,
198+ GetDropdown ( 'Destination' , 'dest' , [
199+ ...state . namedChoices . busses ,
200+ ...state . namedChoices . matrices ,
201+ ...state . namedChoices . mains ,
202+ ] ) ,
203+ GetDropdown ( 'Assign' , 'assign' , [
204+ getIdLabelPair ( '1' , 'Assign' ) ,
205+ getIdLabelPair ( '0' , 'Not Assign' ) ,
206+ getIdLabelPair ( '2' , 'Toggle' ) ,
207+ ] ) ,
208+ ] ,
209+ callback : async ( event ) => {
210+ const talkback = event . options . tb as string
211+ const destination = event . options . dest as string
212+ const cmd = ActionUtil . getTalkbackAssignCommand ( talkback , destination )
213+ const val = event . options . assign as number
214+ if ( val < 2 ) {
215+ send ( cmd , val )
216+ } else {
217+ const currentVal = StateUtil . getBooleanFromState ( cmd , state )
218+ send ( cmd , Number ( ! currentVal ) )
219+ }
220+ } ,
221+ subscribe : ( event ) => {
222+ const val = event . options . mode as number
223+ if ( val >= 2 ) {
224+ const talkback = event . options . tb as string
225+ const destination = event . options . dest as string
226+ const cmd = ActionUtil . getTalkbackAssignCommand ( talkback , destination )
227+ ensureLoaded ( cmd )
228+ }
229+ } ,
230+ } ,
231+ [ CommonActions . TalkbackIndividualLevels ] : {
232+ name : 'Talkback Individual Levels' ,
233+ description : 'Enable or disable individual bus and main talkback levels.' ,
234+ options : [
235+ GetDropdown ( 'Talkback' , 'tb' , getTalkbackOptions ( ) ) ,
236+ GetDropdown ( 'Mode' , 'mode' , getTalkbackIndividualOptions ( ) ) ,
237+ ] ,
238+ callback : async ( event ) => {
239+ const cmd = ConfigurationCommands . TalkbackIndividual ( event . options . tb as string )
240+ const val = event . options . mode as number
241+ send ( cmd , val )
242+ } ,
243+ } ,
129244 }
130245 return actions
131246}
0 commit comments