private void SyncronizeKeyStates(UtilInterop.WindowMessage action, LowLevelKeyboardInput input) { for (int i = 0; i < _keyStates.Count; i++) { _keyStates.Set(i, (UInt16)UtilInterop.GetKeyState(i) >> 15 == 1 ? true : false); } _keyStates.Set((int)input.VirtualKeyCode, (action == UtilInterop.WindowMessage.WM_KEYDOWN || action == UtilInterop.WindowMessage.WM_SYSKEYDOWN) ? true : false); }
private bool ProceedKey(UtilInterop.WindowMessage action, LowLevelKeyboardInput input) { if (action == UtilInterop.WindowMessage.WM_KEYDOWN || action == UtilInterop.WindowMessage.WM_KEYUP || action == UtilInterop.WindowMessage.WM_SYSKEYDOWN || action == UtilInterop.WindowMessage.WM_SYSKEYUP) { SyncronizeKeyStates(action, input); var key = (int)input.VirtualKeyCode; if (action == UtilInterop.WindowMessage.WM_KEYDOWN || action == UtilInterop.WindowMessage.WM_SYSKEYDOWN) { if (!API.Instance.Chat.IsOpen() && !API.Instance.Dialog.IsOpen()) { if (_keyStates.Get(key) && _keyPressedCount[key] < 2) { if (_keyPressedCount[key] != 2) { _keyPressedCount[key]++; } } else if (!_keyStates.Get(key) && _keyPressedCount[key] != 0) { _keyPressedCount[key] = 0; } } } else { if (action == UtilInterop.WindowMessage.WM_KEYUP && input.VirtualKeyCode == UtilInterop.Keys.VK_MENU && API.Instance.Chat.IsOpen()) { _menuPressed = true; } else { _menuPressed = false; } if (_keyStates.Get(key) && _keyPressedCount[key] == 0) { if (_keyPressedCount[key] != 2) { _keyPressedCount[key]++; } } else if (!_keyStates.Get(key) && _keyPressedCount[key] != 0) { _keyPressedCount[key] = 0; _keyUsed.Set(key, false); } } } else if (action == UtilInterop.WindowMessage.WM_CHAR && _menuPressed && API.Instance.Chat.IsOpen()) { _menuPressed = false; return(true); } return(false); }
private Tuple <UtilInterop.Keys, UtilInterop.Keys> GetTranslatedKey(UtilInterop.WindowMessage action, LowLevelKeyboardInput input) { var key = input.VirtualKeyCode; var modifierKey = UtilInterop.Keys.VK_NONE; if (_keyStates[(int)UtilInterop.Keys.VK_SHIFT] && key != UtilInterop.Keys.VK_SHIFT) { modifierKey |= UtilInterop.Keys.VK_SHIFT; } if (_keyStates[(int)UtilInterop.Keys.VK_CONTROL] && key != UtilInterop.Keys.VK_CONTROL) { modifierKey |= UtilInterop.Keys.VK_CONTROL; } if (_keyStates[(int)UtilInterop.Keys.VK_MENU] && key != UtilInterop.Keys.VK_MENU) { modifierKey |= UtilInterop.Keys.VK_MENU; } if (_keyStates[(int)UtilInterop.Keys.VK_APPS] && key != UtilInterop.Keys.VK_APPS) { modifierKey |= UtilInterop.Keys.VK_APPS; } if (_keyStates[(int)UtilInterop.Keys.VK_LWIN] && key != UtilInterop.Keys.VK_LWIN) { modifierKey |= UtilInterop.Keys.VK_LWIN; } if (_keyStates[(int)key]) { if (_keyPressedCount[(int)key] < 2) { return(new Tuple <UtilInterop.Keys, UtilInterop.Keys>(key, modifierKey)); } } return(new Tuple <UtilInterop.Keys, UtilInterop.Keys>(UtilInterop.Keys.VK_NONE, UtilInterop.Keys.VK_NONE)); }