diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/KeyboardHookHelper.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/KeyboardHookHelper.cs index a6560754f5..99e6346c2b 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/KeyboardHookHelper.cs +++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/KeyboardHookHelper.cs @@ -88,18 +88,18 @@ namespace KeyboardManagerEditorUI.Helpers } // Count current modifiers - int modifierCount = _currentlyPressedKeys.Count(k => _activeTarget.IsModifierKey(k)); + int modifierCount = _currentlyPressedKeys.Count(k => RemappingHelper.IsModifierKey(k)); // If adding this key would exceed the limits (4 modifiers + 1 action key), don't add it and show notification - if ((_activeTarget.IsModifierKey(virtualKey) && modifierCount >= 4) || - (!_activeTarget.IsModifierKey(virtualKey) && _currentlyPressedKeys.Count >= 5)) + if ((RemappingHelper.IsModifierKey(virtualKey) && modifierCount >= 4) || + (!RemappingHelper.IsModifierKey(virtualKey) && _currentlyPressedKeys.Count >= 5)) { _activeTarget.OnInputLimitReached(); return; } // Check if this is a different variant of a modifier key already pressed - if (_activeTarget.IsModifierKey(virtualKey)) + if (RemappingHelper.IsModifierKey(virtualKey)) { // Remove existing variant of this modifier key if a new one is pressed // This is to ensure that only one variant of a modifier key is displayed at a time @@ -151,7 +151,7 @@ namespace KeyboardManagerEditorUI.Helpers continue; } - if (_activeTarget.IsModifierKey(key)) + if (RemappingHelper.IsModifierKey(key)) { if (!modifierKeys.Contains(key)) { @@ -234,8 +234,6 @@ namespace KeyboardManagerEditorUI.Helpers void ClearKeys(); - bool IsModifierKey(VirtualKey key); - void OnInputLimitReached(); } } diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/RemappingHelper.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/RemappingHelper.cs index b86609cf33..bc6d595228 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/RemappingHelper.cs +++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/RemappingHelper.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using KeyboardManagerEditorUI.Interop; using ManagedCommon; +using Windows.System; namespace KeyboardManagerEditorUI.Helpers { @@ -124,5 +125,20 @@ namespace KeyboardManagerEditorUI.Helpers return false; } } + + public static bool IsModifierKey(VirtualKey key) + { + return key == VirtualKey.Control + || key == VirtualKey.LeftControl + || key == VirtualKey.RightControl + || key == VirtualKey.Menu + || key == VirtualKey.LeftMenu + || key == VirtualKey.RightMenu + || key == VirtualKey.Shift + || key == VirtualKey.LeftShift + || key == VirtualKey.RightShift + || key == VirtualKey.LeftWindows + || key == VirtualKey.RightWindows; + } } } diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs index b16d46dd46..f85cddba7e 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs +++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs @@ -168,21 +168,6 @@ namespace KeyboardManagerEditorUI.Styles KeyboardHookHelper.Instance.CleanupHook(); } - public bool IsModifierKey(VirtualKey key) - { - return key == VirtualKey.Control - || key == VirtualKey.LeftControl - || key == VirtualKey.RightControl - || key == VirtualKey.Menu - || key == VirtualKey.LeftMenu - || key == VirtualKey.RightMenu - || key == VirtualKey.Shift - || key == VirtualKey.LeftShift - || key == VirtualKey.RightShift - || key == VirtualKey.LeftWindows - || key == VirtualKey.RightWindows; - } - public void SetRemappedKeys(List keys) { _remappedKeys.Clear(); diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/TextPageInputControl.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/TextPageInputControl.xaml.cs index 0d02a5b33a..1d2a28c8d7 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/TextPageInputControl.xaml.cs +++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/TextPageInputControl.xaml.cs @@ -194,16 +194,6 @@ namespace KeyboardManagerEditorUI.Styles UpdateAllAppsCheckBoxState(); } - public bool IsModifierKey(VirtualKey key) - { - return key == VirtualKey.Control || key == VirtualKey.Menu || - key == VirtualKey.Shift || key == VirtualKey.LeftWindows || - key == VirtualKey.RightWindows || key == VirtualKey.LeftControl || - key == VirtualKey.RightControl || key == VirtualKey.LeftMenu || - key == VirtualKey.RightMenu || key == VirtualKey.LeftShift || - key == VirtualKey.RightShift; - } - public List GetShortcutKeys() { List keys = new List();