/// <summary> /// Removes a hotkey for the specified function /// </summary> /// <exception cref="ArgumentException">hotkey not found</exception>" /// <param name="function">Function hotkey to remove</param> public void RemoveFunctionHotkey(Hotkeyfunction function) { FunctionHotkey fhk = GetFunctionHotkey(function); if (fhk == null) { throw new ArgumentNullException("Hotkey not found"); } hotkeys.Remove(fhk); }
/// <summary> /// Adds or updates a current function hotkey /// </summary> /// <exception cref="ArgumentException"></exception> /// <param name="hotkey"></param> public void AddUpdateFunctionHotkey(FunctionHotkey hotkey) { if (CheckHotkeyInUse(hotkey)) { throw new ArgumentException("Hotkey already in use"); } if (GetFunctionHotkey(hotkey.Function) != null) { RemoveFunctionHotkey(hotkey.Function); } ISLogger.Write("Assigned {0} to {1}", hotkey, hotkey.Function); hotkeys.Add(hotkey); }
private void InputMan_FunctionHotkeyPressed(object sender, FunctionHotkey e) { switch (e.Function) { case HotkeyFunction.Exit: Stop(); break; case HotkeyFunction.SwitchToLocalInput: if (!LocalInput) { SwitchLocalInput(); } break; case HotkeyFunction.SAS: if (!LocalInput) { currentInputClient?.SendInput(new ISInputData(ISInputCode.IS_SENDSAS, 0, 0)); } break; } }
private void IsThreadHandleKeyboard(uint wParam, KBDLLHOOKSTRUCT keyboardStruct) { int code = (int)wParam; switch (code) { case WM_SYSKEYDOWN: case WM_KEYDOWN: { if (keyboardStruct.scanCode == 0) { ISLogger.Write("Cannot get scancode for virtual key {0}", keyboardStruct.vkCode); return; } if (keyboardStruct.scanCode == (int)ScanCode.Control) { currentModifiers |= Hotkey.Modifiers.Ctrl; } else if (keyboardStruct.scanCode == (int)ScanCode.Alt) { currentModifiers |= Hotkey.Modifiers.Alt; } else if (keyboardStruct.scanCode == (int)ScanCode.LShift | keyboardStruct.scanCode == (int)ScanCode.RShift) { currentModifiers |= Hotkey.Modifiers.Shift; } Hotkey[] list = hotkeyList.ToArray(); for (int i = 0; i < list.Length; i++) { if ((keyboardStruct.scanCode == (short)list[i].HkScan) && (currentModifiers == list[i].Mods)) { if (list[i] is ClientHotkey) { ClientHotkey hk = list[i] as ClientHotkey; ClientHotkeyPressed?.Invoke(this, hk); } else if (list[i] is FunctionHotkey) { FunctionHotkey hk = list[i] as FunctionHotkey; FunctionHotkeyPressed?.Invoke(this, hk); } } } kbData = new ISInputData(ISInputCode.IS_KEYDOWN, (short)keyboardStruct.scanCode, 0); break; } case WM_SYSKEYUP: case WM_KEYUP: { if (keyboardStruct.scanCode == (int)ScanCode.Control) { currentModifiers &= ~Hotkey.Modifiers.Ctrl; } else if (keyboardStruct.scanCode == (int)ScanCode.Alt) { currentModifiers &= ~Hotkey.Modifiers.Alt; } else if (keyboardStruct.scanCode == (int)ScanCode.LShift | keyboardStruct.scanCode == (int)ScanCode.RShift) { currentModifiers &= ~Hotkey.Modifiers.Shift; } kbData = new ISInputData(ISInputCode.IS_KEYUP, (short)keyboardStruct.scanCode, 0); break; } default: { ISLogger.Write("Unexpected windows keyboard input code " + code); return; } } if (UserInputBlocked) { InputReceived?.Invoke(this, kbData); } }
private ConnectedClientInfo CreateClientInfo(ConnectedClient client, bool includeEdges) { if (client == null) { return(ConnectedClientInfo.None); } ClientHotkey hk = new ClientHotkey(0, 0, Guid.Empty); try { hk = inputMan.GetClientHotkey(client.ClientGuid); } catch (InvalidOperationException) { } if (client == ConnectedClient.LocalHost) { FunctionHotkey fhk = inputMan.GetFunctionHotkey(HotkeyFunction.SwitchToLocalInput); hk = new ClientHotkey(fhk.HkScan, fhk.Mods, Guid.Empty); } if (includeEdges) { ConnectedClientInfo lc; if (client.LeftClient == null) { lc = ConnectedClientInfo.None; } else { lc = CreateClientInfo(client.LeftClient, false); } ConnectedClientInfo rc; if (client.RightClient == null) { rc = ConnectedClientInfo.None; } else { rc = CreateClientInfo(client.RightClient, false); } ConnectedClientInfo ac; if (client.AboveClient == null) { ac = ConnectedClientInfo.None; } else { ac = CreateClientInfo(client.AboveClient, false); } ConnectedClientInfo bc; if (client.BelowClient == null) { bc = ConnectedClientInfo.None; } else { bc = CreateClientInfo(client.BelowClient, false); } return(new ConnectedClientInfo(client.ClientName, client.ClientGuid, client.ClientEndPoint.Address, hk, lc, rc, ac, bc)); } else { return(new ConnectedClientInfo(client.ClientName, client.ClientGuid, client.ClientEndPoint.Address, hk, null, null, null, null)); } }