internal KeySetting CreateNew(Win32.VK inputKey)
        {
            ConfigurationElement element  = CreateNewElement();
            KeySetting           settings = element as KeySetting;

            settings.InputKey  = inputKey;
            settings.OutputKey = inputKey;
            base.BaseAdd(element);
            return(settings);
        }
Example #2
0
 public bool TryGetKeySetting(WinAPI.VK vk, out KeySetting keySetting)
 {
     keySetting = base.BaseGet(vk) as KeySetting;
     return keySetting != null;
 }
Example #3
0
        private static bool OnKeyboardInputReceived(WinAPI.WM wParam, WinAPI.WindowHook.KBDLLHOOKSTRUCT hookStruct)
        {
            // ignore injected input
            if (hookStruct.flags.HasFlag(WinAPI.WindowHook.LLKHF.INJECTED))
            {
                return(false);
            }

            // coerce specialized left/right shift-state to generalized shift-state
            if (MuboxConfigSection.Default.Profiles.ActiveProfile.EnableCASFix)
            {
                switch ((WinAPI.VK)hookStruct.vkCode)
                {
                case WinAPI.VK.LeftShift:
                case WinAPI.VK.RightShift:
                    hookStruct.vkCode = WinAPI.VK.Shift;
                    break;

                case WinAPI.VK.LeftMenu:
                case WinAPI.VK.RightMenu:
                    hookStruct.vkCode = WinAPI.VK.Menu;
                    break;

                case WinAPI.VK.LeftControl:
                case WinAPI.VK.RightControl:
                    hookStruct.vkCode = WinAPI.VK.Control;
                    break;
                }
            }

            // ignore "global desktop keys"
            Mubox.Configuration.KeySetting globalKeySetting = null;
            if (Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile.Keys.TryGetKeySetting((WinAPI.VK)hookStruct.vkCode, out globalKeySetting) && (globalKeySetting.SendToDesktop))
            {
                return(false);
            }

            // update pressed keys
            if (!UpdatePressedKeys(hookStruct) && Mubox.Configuration.MuboxConfigSection.Default.IsCaptureEnabled && !Mubox.Configuration.MuboxConfigSection.Default.DisableRepeatKeyFiltering)
            {
                return(true);
            }

            // count
            if (Performance.IsPerformanceEnabled)
            {
                KeyboardInputPerformance.Count(Convert.ToInt64(hookStruct.time));
            }

            // handle high-level
            if (KeyboardInputReceived != null)
            {
                KeyboardInput keyboardInputEventArgs = KeyboardInput.CreateFrom(wParam, hookStruct);
                {
                    Mubox.Configuration.KeySetting keySetting = globalKeySetting;
                    if (Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile != null)
                    {
                        Mubox.Configuration.ClientSettings activeClient = Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile.ActiveClient;
                        if (activeClient != null)
                        {
                            activeClient.Keys.TryGetKeySetting((WinAPI.VK)keyboardInputEventArgs.VK, out keySetting);
                        }
                        if (keySetting != null)
                        {
                            keyboardInputEventArgs.VK  = keySetting.OutputKey;
                            keyboardInputEventArgs.CAS = keySetting.OutputModifiers;
                        }
                    }
                }
                OnKeyboardInputReceivedInternal(keyboardInputEventArgs);
                return(keyboardInputEventArgs.Handled);
            }

            return(false);
        }
 public bool TryGetKeySetting(Win32.VK vk, out KeySetting keySetting)
 {
     keySetting = base.BaseGet(vk) as KeySetting;
     return(keySetting != null);
 }