@@ -4,7 +4,6 @@ import got from 'got';
4
4
import delay from 'delay' ;
5
5
import merge from 'deepmerge' ;
6
6
import { Enums } from 'atem-connection' ;
7
- // Import { EventEmitter } from 'inf-ee'
8
7
9
8
import beforeShutdown from './beforeShutdown.js' ;
10
9
import { ControllerWebServer } from './ControllerWebServer.js' ;
@@ -167,7 +166,7 @@ export class ControlThemAll {
167
166
168
167
streamDeckOnDisconnect ( parameters ) {
169
168
console . log ( 'streamDeck onDisconnect:' , parameters ) ;
170
- // This .streamDeckStopTimers();
169
+ this . streamDeckStopTimers ( ) ;
171
170
}
172
171
173
172
streamDeckOnButtonDown ( keyIndex ) {
@@ -417,6 +416,7 @@ export class ControlThemAll {
417
416
418
417
this . updateDveButtons ( ) ;
419
418
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
419
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
420
420
} ,
421
421
422
422
switchProgramAndDveSource : ( ) => {
@@ -565,6 +565,7 @@ export class ControlThemAll {
565
565
}
566
566
567
567
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
568
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
568
569
} ,
569
570
ResetDvePosition : ( options , value ) => {
570
571
const { defaultValue} = options ;
@@ -594,6 +595,7 @@ export class ControlThemAll {
594
595
}
595
596
596
597
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
598
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
597
599
} ,
598
600
ResetDveMask : ( options , value ) => {
599
601
const { defaultValue} = options ;
@@ -623,6 +625,7 @@ export class ControlThemAll {
623
625
}
624
626
625
627
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
628
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
626
629
} ,
627
630
628
631
ResetDveAll : ( ) => {
@@ -669,6 +672,7 @@ export class ControlThemAll {
669
672
670
673
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
671
674
this . controllerMidi . updateControllersViaState ( this . config . controllers ) ;
675
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
672
676
} ,
673
677
674
678
FadeToBlack : ( options , value ) => this . controllerAtem . fadeToBlack ( ) ,
@@ -682,6 +686,7 @@ export class ControlThemAll {
682
686
}
683
687
684
688
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
689
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
685
690
} ,
686
691
687
692
ChangeProgramSource : ( options , value ) => {
@@ -737,6 +742,10 @@ export class ControlThemAll {
737
742
if ( this . controllerMidi ) {
738
743
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
739
744
}
745
+
746
+ if ( this . controllerStreamDeck ) {
747
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
748
+ }
740
749
} ,
741
750
ChangeDvePosition : ( options , value ) => {
742
751
const { defaultValue} = options ;
@@ -774,6 +783,10 @@ export class ControlThemAll {
774
783
if ( this . controllerMidi ) {
775
784
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
776
785
}
786
+
787
+ if ( this . controllerStreamDeck ) {
788
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
789
+ }
777
790
} ,
778
791
ChangeDveMask : ( options , value ) => {
779
792
const { defaultValue} = options ;
@@ -809,6 +822,10 @@ export class ControlThemAll {
809
822
if ( this . controllerMidi ) {
810
823
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
811
824
}
825
+
826
+ if ( this . controllerStreamDeck ) {
827
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons ) ;
828
+ }
812
829
} ,
813
830
814
831
ChangeAudioSourceGain : ( options , value ) => this . getActionChain ( 'changeAudioSourceGain' ) ( options , value ) ,
@@ -837,26 +854,40 @@ export class ControlThemAll {
837
854
this . updateButtonState ( btns , { state : 'noteoff' , value : 0 } , 'note' ) ;
838
855
}
839
856
840
- // SwitchStreamDeckOn(btns) {
841
- // btns = asArray(btns)
842
- // // Console.log(`switchStreamDeckOn:`, btns)
843
- // btns = btns.map((btn) => ({ note: btn }))
844
- // this.updateStreamDeckState(btns, { state: 'buttonon', value: 127 }, 'note')
845
- // }
846
-
847
- // switchStreamDeckFlashing(btns) {
848
- // btns = asArray(btns)
849
- // // Console.log(`switchStreamDeckFlashing:`, btns)
850
- // btns = btns.map((btn) => ({ note: btn }))
851
- // this.updateStreamDeckState(btns, { state: 'flashingon', value: 127 }, 'note')
852
- // }
853
-
854
- // switchStreamDeckOff(btns) {
855
- // btns = asArray(btns)
856
- // // Console.log(`switchStreamDeckOff:`, btns)
857
- // btns = btns.map((btn) => ({ note: btn }))
858
- // this.updateStreamDeckState(btns, { state: 'buttonoff', value: 0 }, 'note')
859
- // }
857
+ switchStreamDeckOn ( btns ) {
858
+ btns = asArray ( btns ) ;
859
+ console . log ( 'switchStreamDeckOn:' , btns ) ;
860
+ btns = btns . map ( btn => ( { button : btn } ) ) ;
861
+ this . updateStreamDeckState ( btns , { state : 'buttonon' } , 'button' ) ;
862
+ }
863
+
864
+ switchStreamDeckFlashing ( btns ) {
865
+ btns = asArray ( btns ) ;
866
+ console . log ( 'switchStreamDeckFlashing:' , btns ) ;
867
+ btns = btns . map ( btn => ( { button : btn } ) ) ;
868
+ this . updateStreamDeckState ( btns , { state : 'flashingon' } , 'button' ) ;
869
+ }
870
+
871
+ switchStreamDeckOff ( btns ) {
872
+ btns = asArray ( btns ) ;
873
+ console . log ( 'switchStreamDeckOff:' , btns ) ;
874
+ btns = btns . map ( btn => ( { button : btn } ) ) ;
875
+ this . updateStreamDeckState ( btns , { state : 'buttonoff' } , 'button' ) ;
876
+ }
877
+
878
+ updateStreamDeckState ( buttonStates , overwrite = { } , via = 'action' ) {
879
+ buttonStates = asArray ( buttonStates ) ;
880
+ buttonStates = buttonStates . map ( buttonState => ( { state : 'buttonoff' , ...buttonState , ...overwrite } ) ) ;
881
+ this . config . streamDeck . buttons = this . config . streamDeck . buttons . map ( button => {
882
+ const updatedButtonState = find ( buttonStates , element => element [ via ] === button [ via ] ) ;
883
+ if ( updatedButtonState ) {
884
+ button . value = updatedButtonState . value ;
885
+ button . state = updatedButtonState . state ;
886
+ }
887
+
888
+ return button ;
889
+ } ) ;
890
+ }
860
891
861
892
getButtonsByAction ( action ) {
862
893
return this . config . buttons . filter ( element => element . action === action || element . noteOn ?. action === action || element . noteOff ?. action === action ) . map ( element => element . note ) ;
@@ -903,14 +934,14 @@ export class ControlThemAll {
903
934
const buttonsForDveSelection = this . config . feedback . buttonsForActiveUpstreamKeyerFillSource ;
904
935
const buttonActiveDveFillSource = buttonsForDveSelection [ nameOfInput ] ;
905
936
906
- const streamDecksForDveSelection = this . config . feedback . streamDeckForActiveUpstreamKeyerFillSource ;
937
+ const streamDecksForDveSelection = this . config . streamDeck . feedback . activeUpstreamKeyerFillSource ;
907
938
const streamDeckActiveDveFillSource = streamDecksForDveSelection [ nameOfInput ] ;
908
939
909
940
this . switchButtonLightOff ( difference ( flatten ( Object . values ( buttonsForDveSelection ) ) , buttonActiveDveFillSource ) ) ;
910
941
this . switchButtonLightOn ( buttonActiveDveFillSource ) ;
911
942
912
- // This .switchStreamDeckOff(difference(flatten(Object.values(streamDecksForDveSelection)), streamDeckActiveDveFillSource))
913
- // this.switchStreamDeckOn(streamDeckActiveDveFillSource)
943
+ this . switchStreamDeckOff ( difference ( flatten ( Object . values ( streamDecksForDveSelection ) ) , streamDeckActiveDveFillSource ) ) ;
944
+ this . switchStreamDeckOn ( streamDeckActiveDveFillSource ) ;
914
945
}
915
946
916
947
updatecontrollerState ( controllerStates , overwrite = { } , via = 'action' ) {
@@ -973,8 +1004,9 @@ export class ControlThemAll {
973
1004
console . log ( 'pathToChange:' , pathToChange ) ;
974
1005
}
975
1006
1007
+ const isInitial = pathToChange . length === 1 && pathToChange [ 0 ] === 'initial' ;
1008
+
976
1009
for ( const path of pathToChange ) {
977
- const isInitial = path === 'initial' ;
978
1010
if ( isInitial ) {
979
1011
// Find all ChangeAudioSourceGain controllers and set them to their default
980
1012
for ( const controller of this . config . controllers ) {
@@ -1028,8 +1060,8 @@ export class ControlThemAll {
1028
1060
const buttonsForProgramInputWithoutDve = this . config . feedback . buttonsForProgramInputWithoutDve ;
1029
1061
const buttonsForProgramInputWithDve = this . config . feedback . buttonsForProgramInputWithDve ;
1030
1062
1031
- const streamDeckForProgramInputWithoutDve = this . config . feedback . streamDeckForProgramInputWithoutDve ;
1032
- const streamDeckForProgramInputWithDve = this . config . feedback . streamDeckForProgramInputWithDve ;
1063
+ const streamDeckForProgramInputWithoutDve = this . config . streamDeck . feedback . programInputWithoutDve ;
1064
+ const streamDeckForProgramInputWithDve = this . config . streamDeck . feedback . programInputWithDve ;
1033
1065
1034
1066
const nameOfInput = Object . keys ( this . config . inputMapping ) . find ( key => this . config . inputMapping [ key ] === programInput ) ;
1035
1067
@@ -1042,6 +1074,9 @@ export class ControlThemAll {
1042
1074
this . switchButtonLightOff ( difference ( buttonsForProgramInputAll , buttonsForProgramInput ) ) ;
1043
1075
this . switchButtonLightOn ( buttonsForProgramInput ) ;
1044
1076
1077
+ this . switchStreamDeckOff ( difference ( streamDeckForProgramInputAll , streamDeckForProgramInput ) ) ;
1078
+ this . switchStreamDeckOn ( streamDeckForProgramInput ) ;
1079
+
1045
1080
this . updateDveButtons ( ) ;
1046
1081
1047
1082
if ( state . video . mixEffects [ me ] . fadeToBlack . isFullyBlack ) {
@@ -1054,15 +1089,12 @@ export class ControlThemAll {
1054
1089
1055
1090
if ( this . controllerMidi ) {
1056
1091
this . controllerMidi . updateControllersViaState ( this . config . controllers ) ;
1057
- }
1058
-
1059
- if ( this . controllerMidi ) {
1060
1092
this . controllerMidi . updateButtonsViaState ( this . config . buttons ) ;
1061
1093
}
1062
1094
1063
- // If (this.controllerStreamDeck) {
1064
- // this.controllerStreamDeck.updateButtonsViaState(this.config.streamDeck.buttons)
1065
- // }
1095
+ if ( this . controllerStreamDeck ) {
1096
+ this . controllerStreamDeck . updateButtonsViaState ( this . config . streamDeck . buttons , isInitial ) ;
1097
+ }
1066
1098
}
1067
1099
1068
1100
async exitHandler ( options , exitCode ) {
0 commit comments