@@ -47,32 +47,17 @@ public override async Task OnStart(IVoiceAttackProxy proxy)
4747 proxy . Log . Write ( $ "Watching { e . Name } ", VoiceAttackColor . Blue ) ;
4848 } ) ;
4949
50- _api . OnKeybindingsChanged ( e =>
50+ _api . OnKeybindingsChanged ( bindings =>
5151 {
52- List < ( string name , Binding binding ) > bindings = [ ] ;
53-
54- foreach ( var binding in e )
55- {
56- Binding keyboardBinding ;
57-
58- if ( binding . Primary . HasValue && binding . Primary . Value . Device == "Keyboard" )
59- keyboardBinding = binding . Primary . Value ;
60- else if ( binding . Secondary . HasValue && binding . Secondary . Value . Device == "Keyboard" )
61- keyboardBinding = binding . Secondary . Value ;
62- else
63- continue ;
64-
65- bindings . Add ( ( binding . Name , keyboardBinding ) ) ;
66-
67- Proxy . Variables . Set ( $ "EliteAPI.{ binding . Name } ", binding . Primary . HasValue ? binding . Primary . Value . KeyCode : "" , TypeCode . String ) ;
68- }
52+ foreach ( var binding in bindings )
53+ Proxy . Variables . Set ( $ "EliteAPI.{ binding . Name } ", binding . KeyCode , TypeCode . String ) ;
6954
7055 if ( ! Directory . Exists ( Path . Combine ( Dir , "Variables" ) ) )
7156 Directory . CreateDirectory ( Path . Combine ( Dir , "Variables" ) ) ;
7257
73- File . WriteAllText ( Path . Combine ( Dir , "Variables" , $ "Keybindings.txt") , bindings . Select ( b => $ "{{TXT:{ b . name } }}: { b . binding . KeyCode } ") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
58+ File . WriteAllText ( Path . Combine ( Dir , "Variables" , "Keybindings.txt" ) , bindings . Select ( b => $ "{{TXT:EliteAPI. { b . Name } }}: { b . KeyCode } ") . Aggregate ( ( a , b ) => $ "{ a } \n { b } ") ) ;
7459
75- proxy . Log . Write ( $ "Applying { bindings . Count } keybindings", VoiceAttackColor . Blue ) ;
60+ proxy . Log . Write ( $ "Applying { bindings . Count ( b => ! string . IsNullOrEmpty ( b . KeyCode ) ) } keybindings", VoiceAttackColor . Blue ) ;
7661 } ) ;
7762
7863 // json event
0 commit comments