@@ -11,21 +11,21 @@ internal partial class HotkeysLoad
1111 private static readonly List < IntPtr > yeetedWindows = [ ] ;
1212 private static readonly List < IntPtr > enumWindowsResult = [ ] ;
1313
14- private static readonly List < int > modifierKeys = [
15- ( int ) VirtualKey . LeftControl ,
16- ( int ) VirtualKey . RightControl ,
17- ( int ) VirtualKey . Control ,
18- ( int ) VirtualKey . LeftShift ,
19- ( int ) VirtualKey . RightShift ,
20- ( int ) VirtualKey . Shift ,
21- ( int ) VirtualKey . LeftMenu ,
22- ( int ) VirtualKey . RightMenu ,
23- ( int ) VirtualKey . Menu ,
24- ( int ) VirtualKey . LeftWindows ,
25- ( int ) VirtualKey . RightWindows ] ;
26-
27- private static readonly HashSet < int > currentKeys = [ ] ;
28- private static readonly List < int > assignedHotkeys = [ ] ;
14+ private static readonly List < VirtualKey > modifierKeys = [
15+ VirtualKey . LeftControl ,
16+ VirtualKey . RightControl ,
17+ VirtualKey . Control ,
18+ VirtualKey . LeftShift ,
19+ VirtualKey . RightShift ,
20+ VirtualKey . Shift ,
21+ VirtualKey . LeftMenu ,
22+ VirtualKey . RightMenu ,
23+ VirtualKey . Menu ,
24+ VirtualKey . LeftWindows ,
25+ VirtualKey . RightWindows ] ;
26+
27+ private static readonly SortedSet < VirtualKey > currentKeys = [ ] ;
28+ private static readonly List < SortedSet < VirtualKey > > assignedHotkeys = [ ] ;
2929 private static HotkeyEvent pointedEvent = delegate { } ;
3030
3131 public delegate void HotkeyEvent ( int Id ) ;
@@ -39,19 +39,17 @@ public static void RegisterHotkeys(HotkeyEvent hotkeyEvent)
3939 KeyboardHookHandler . SetupHook ( DownKeyEvent , UpKeyEvent ) ;
4040 }
4141
42- private static bool DownKeyEvent ( int key )
42+ private static bool DownKeyEvent ( VirtualKey key )
4343 {
44- int index = assignedHotkeys . IndexOf ( key ) ;
44+ int index = assignedHotkeys . FindIndex ( set => set . SetEquals ( [ key ] ) ) ;
4545 if ( index != - 1 && ! currentKeys . Intersect ( modifierKeys ) . Any ( ) )
4646 {
4747 pointedEvent ( index ) ;
4848 return true ;
4949 }
5050
5151 currentKeys . Add ( key ) ;
52-
53- int combined = currentKeys . Sum ( ) ;
54- index = assignedHotkeys . IndexOf ( combined ) ;
52+ index = assignedHotkeys . FindIndex ( set => set . SetEquals ( currentKeys ) ) ;
5553
5654 if ( index != - 1 )
5755 {
@@ -62,7 +60,7 @@ private static bool DownKeyEvent(int key)
6260 return false ;
6361 }
6462
65- private static bool UpKeyEvent ( int key )
63+ private static bool UpKeyEvent ( VirtualKey key )
6664 {
6765 currentKeys . Remove ( key ) ;
6866 return false ;
@@ -140,10 +138,10 @@ private static void ConfigParse()
140138 }
141139 private static void InitHotkey ( string name , JObject config )
142140 {
143- int hotkey = 0 ;
141+ SortedSet < VirtualKey > hotkey = [ ] ;
144142 foreach ( string ? key in config [ name ] ! . Select ( v => ( string ? ) v ) )
145143 {
146- hotkey += ( int ) Enum . Parse < VirtualKey > ( key ! ) ;
144+ hotkey . Add ( Enum . Parse < VirtualKey > ( key ! ) ) ;
147145 }
148146
149147 assignedHotkeys . Add ( hotkey ) ;
0 commit comments