mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-24 00:21:07 +00:00
Added detection of left and right shift/control/alt buttons.
This commit is contained in:
parent
ef16a9d296
commit
bc1801d5d5
|
@ -525,7 +525,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
[System.Security.SuppressUnmanagedCodeSecurity]
|
[System.Security.SuppressUnmanagedCodeSecurity]
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
internal static extern SHORT GetAsyncKeyState(int vKey);
|
internal static extern SHORT GetAsyncKeyState(VirtualKeys vKey);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -110,18 +110,42 @@ namespace OpenTK.Platform.Windows
|
||||||
case WindowMessage.SYSKEYUP:
|
case WindowMessage.SYSKEYUP:
|
||||||
bool pressed = (WindowMessage)msg.Msg == WindowMessage.KEYDOWN ||
|
bool pressed = (WindowMessage)msg.Msg == WindowMessage.KEYDOWN ||
|
||||||
(WindowMessage)msg.Msg == WindowMessage.SYSKEYDOWN;
|
(WindowMessage)msg.Msg == WindowMessage.SYSKEYDOWN;
|
||||||
|
//bool left = (((int)msg.LParam) & 0x100000) == 0; // valid for Shift, Control and Menu presses.
|
||||||
switch ((VirtualKeys)msg.WParam)
|
switch ((VirtualKeys)msg.WParam)
|
||||||
{
|
{
|
||||||
case VirtualKeys.SHIFT:
|
case VirtualKeys.SHIFT:
|
||||||
keyboard[Input.Key.ShiftLeft] = keyboard[Input.Key.ShiftRight] = pressed;
|
// Win95 does not distinguish left/right constants (GetAsyncKeyState returns 0).
|
||||||
|
// In this case, report both keys as down.
|
||||||
|
bool left = Functions.GetAsyncKeyState(VirtualKeys.LSHIFT) != 0;
|
||||||
|
bool right = Functions.GetAsyncKeyState(VirtualKeys.RSHIFT) != 0;
|
||||||
|
if (left)
|
||||||
|
keyboard[Input.Key.ShiftLeft] = pressed;
|
||||||
|
if (right)
|
||||||
|
keyboard[Input.Key.ShiftRight] = pressed;
|
||||||
|
if (!left && !right)
|
||||||
|
keyboard[Input.Key.ShiftLeft] = keyboard[Input.Key.ShiftRight] = pressed;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case VirtualKeys.CONTROL:
|
case VirtualKeys.CONTROL:
|
||||||
keyboard[Input.Key.ControlLeft] = keyboard[Input.Key.ControlRight] = pressed;
|
left = Functions.GetAsyncKeyState(VirtualKeys.LCONTROL) != 0;
|
||||||
|
right = Functions.GetAsyncKeyState(VirtualKeys.RCONTROL) != 0;
|
||||||
|
if (left)
|
||||||
|
keyboard[Input.Key.ControlLeft] = pressed;
|
||||||
|
if (right)
|
||||||
|
keyboard[Input.Key.ControlRight] = pressed;
|
||||||
|
if (!left && !right)
|
||||||
|
keyboard[Input.Key.ControlLeft] = keyboard[Input.Key.ControlRight] = pressed;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case VirtualKeys.MENU:
|
case VirtualKeys.MENU:
|
||||||
keyboard[Input.Key.AltLeft] = keyboard[Input.Key.AltRight] = pressed;
|
left = Functions.GetAsyncKeyState(VirtualKeys.LMENU) != 0;
|
||||||
|
right = Functions.GetAsyncKeyState(VirtualKeys.RMENU) != 0;
|
||||||
|
if (left)
|
||||||
|
keyboard[Input.Key.AltLeft] = pressed;
|
||||||
|
if (right)
|
||||||
|
keyboard[Input.Key.AltRight] = pressed;
|
||||||
|
if (!left && !right)
|
||||||
|
keyboard[Input.Key.AltLeft] = keyboard[Input.Key.AltRight] = pressed;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue