mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-23 00:19:53 +00:00
Fix incorrect behavior of modifier keys on the right side of the keyboard
This commit is contained in:
@@ -561,14 +561,46 @@ int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any keyboard event with the META modifier flag is dropped by all known GFE versions.
|
// For proper behavior, the MODIFIER flag must not be set on the modifier key down event itself
|
||||||
// This prevents us from sending shortcuts involving the meta key (Win+X, Win+Tab, etc).
|
// for the extended modifiers on the right side of the keyboard. If the MODIFIER flag is set,
|
||||||
// The catch is that the meta key event itself would actually work if it didn't set its
|
// GFE will synthesize an errant key down event for the non-extended key, causing that key to be
|
||||||
// own modifier flag, so we'll clear that here. This should be safe even if a new GFE
|
// stuck down after the extended modifier key is raised. For non-extended keys, we must set the
|
||||||
// release comes out that stops dropping events with MODIFIER_META flag.
|
// MODIFIER flag for correct behavior.
|
||||||
if ((keyCode & 0x00FF) == 0x5B || // VK_LWIN
|
switch (keyCode & 0xFF) {
|
||||||
(keyCode & 0x00FF) == 0x5C) { // VK_RWIN
|
case 0x5B: // VK_LWIN
|
||||||
|
case 0x5C: // VK_RWIN
|
||||||
|
// Any keyboard event with the META modifier flag is dropped by all known GFE versions.
|
||||||
|
// This prevents us from sending shortcuts involving the meta key (Win+X, Win+Tab, etc).
|
||||||
|
// The catch is that the meta key event itself would actually work if it didn't set its
|
||||||
|
// own modifier flag, so we'll clear that here. This should be safe even if a new GFE
|
||||||
|
// release comes out that stops dropping events with MODIFIER_META flag.
|
||||||
modifiers &= ~MODIFIER_META;
|
modifiers &= ~MODIFIER_META;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xA0: // VK_LSHIFT
|
||||||
|
modifiers |= MODIFIER_SHIFT;
|
||||||
|
break;
|
||||||
|
case 0xA1: // VK_RSHIFT
|
||||||
|
modifiers &= ~MODIFIER_SHIFT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xA2: // VK_LCONTROL
|
||||||
|
modifiers |= MODIFIER_CTRL;
|
||||||
|
break;
|
||||||
|
case 0xA3: // VK_RCONTROL
|
||||||
|
modifiers &= ~MODIFIER_CTRL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xA4: // VK_LMENU
|
||||||
|
modifiers |= MODIFIER_ALT;
|
||||||
|
break;
|
||||||
|
case 0xA5: // VK_RMENU
|
||||||
|
modifiers &= ~MODIFIER_ALT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// No fixups
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
holder->packetLength = sizeof(NV_KEYBOARD_PACKET);
|
holder->packetLength = sizeof(NV_KEYBOARD_PACKET);
|
||||||
|
|||||||
Reference in New Issue
Block a user