mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 16:15:33 +00:00
Use UIntPtr instead of IntPtr to avoid overflow exceptions in x64 mode.
This commit is contained in:
parent
e6baa0a42f
commit
9bbef90088
|
@ -62,6 +62,13 @@ namespace OpenTK.Platform.Windows
|
|||
bool mouse_about_to_enter = false;
|
||||
protected override void WndProc(ref Message msg)
|
||||
{
|
||||
UIntPtr lparam, wparam;
|
||||
unsafe
|
||||
{
|
||||
lparam = (UIntPtr)(void*)msg.LParam;
|
||||
wparam = (UIntPtr)(void*)msg.WParam;
|
||||
}
|
||||
|
||||
switch ((WindowMessage)msg.Msg)
|
||||
{
|
||||
// Mouse events:
|
||||
|
@ -70,8 +77,9 @@ namespace OpenTK.Platform.Windows
|
|||
break;
|
||||
|
||||
case WindowMessage.MOUSEMOVE:
|
||||
mouse.Position = new System.Drawing.Point(msg.LParam.ToInt32() & 0x0000FFFF,
|
||||
(int)(msg.LParam.ToInt32() & 0xFFFF0000) >> 16);
|
||||
mouse.Position = new System.Drawing.Point(
|
||||
(int)(lparam.ToUInt32() & 0x0000FFFF),
|
||||
(int)(lparam.ToUInt32() & 0xFFFF0000) >> 16);
|
||||
if (mouse_about_to_enter)
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
@ -80,7 +88,7 @@ namespace OpenTK.Platform.Windows
|
|||
return;
|
||||
|
||||
case WindowMessage.MOUSEWHEEL:
|
||||
mouse.Wheel += (msg.WParam.ToInt32() >> 16) / 120;
|
||||
mouse.Wheel += (int)(wparam.ToUInt32() >> 16) / 120;
|
||||
return;
|
||||
|
||||
case WindowMessage.LBUTTONDOWN:
|
||||
|
@ -96,7 +104,7 @@ namespace OpenTK.Platform.Windows
|
|||
return;
|
||||
|
||||
case WindowMessage.XBUTTONDOWN:
|
||||
mouse[((msg.WParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true;
|
||||
mouse[((wparam.ToUInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true;
|
||||
return;
|
||||
|
||||
case WindowMessage.LBUTTONUP:
|
||||
|
@ -113,7 +121,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
case WindowMessage.XBUTTONUP:
|
||||
// TODO: Is this correct?
|
||||
mouse[((msg.WParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false;
|
||||
mouse[((wparam.ToUInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false;
|
||||
return;
|
||||
|
||||
// Keyboard events:
|
||||
|
@ -132,7 +140,7 @@ namespace OpenTK.Platform.Windows
|
|||
// In this case, both keys will be reported as pressed.
|
||||
|
||||
bool extended = (msg.LParam.ToInt64() & ExtendedBit) != 0;
|
||||
switch ((VirtualKeys)msg.WParam)
|
||||
switch ((VirtualKeys)wparam)
|
||||
{
|
||||
case VirtualKeys.SHIFT:
|
||||
// The behavior of this key is very strange. Unlike Control and Alt, there is no extended bit
|
||||
|
@ -144,11 +152,14 @@ namespace OpenTK.Platform.Windows
|
|||
// TODO: Not 100% reliable, when both keys are pressed at once.
|
||||
if (ShiftRightScanCode != 0)
|
||||
{
|
||||
if (((msg.LParam.ToInt32() >> 16) & 0xFF) == ShiftRightScanCode)
|
||||
unchecked
|
||||
{
|
||||
if (((lparam.ToUInt32() >> 16) & 0xFF) == ShiftRightScanCode)
|
||||
keyboard[Input.Key.ShiftRight] = pressed;
|
||||
else
|
||||
keyboard[Input.Key.ShiftLeft] = pressed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Should only fall here on Windows 9x and NT4.0-
|
||||
|
|
Loading…
Reference in a new issue