Mouse up events in Windows occur regardless of where on the screen the cursor is. OpenTK issue 2133
This commit is contained in:
parent
c98d9e4503
commit
5b0db16a89
1 changed files with 20 additions and 10 deletions
|
@ -145,6 +145,8 @@ namespace OpenTK.Platform.Windows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delegate void MouseButtonChangedHandler(MouseButton Button);
|
||||||
|
|
||||||
public bool ProcessMouseEvent(RawInput rin)
|
public bool ProcessMouseEvent(RawInput rin)
|
||||||
{
|
{
|
||||||
RawMouse raw = rin.Data.Mouse;
|
RawMouse raw = rin.Data.Mouse;
|
||||||
|
@ -166,16 +168,24 @@ namespace OpenTK.Platform.Windows
|
||||||
int mouse_handle = rawids.ContainsKey(handle) ? rawids[handle] : 0;
|
int mouse_handle = rawids.ContainsKey(handle) ? rawids[handle] : 0;
|
||||||
mouse = mice[mouse_handle];
|
mouse = mice[mouse_handle];
|
||||||
|
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.LEFT_BUTTON_DOWN) != 0) mouse.EnableBit((int)MouseButton.Left);
|
// Set and release capture of the mouse to fix http://www.opentk.com/node/2133, Patch by Artfunkel
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.LEFT_BUTTON_UP) != 0) mouse.DisableBit((int)MouseButton.Left);
|
MouseButtonChangedHandler EnableBit = (Button) => {
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.RIGHT_BUTTON_DOWN) != 0) mouse.EnableBit((int)MouseButton.Right);
|
mouse.EnableBit((int)Button); Functions.SetCapture(Window);
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.RIGHT_BUTTON_UP) != 0) mouse.DisableBit((int)MouseButton.Right);
|
};
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.MIDDLE_BUTTON_DOWN) != 0) mouse.EnableBit((int)MouseButton.Middle);
|
MouseButtonChangedHandler DisableBit = (Button) => {
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.MIDDLE_BUTTON_UP) != 0) mouse.DisableBit((int)MouseButton.Middle);
|
mouse.DisableBit((int)Button); Functions.ReleaseCapture();
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_4_DOWN) != 0) mouse.EnableBit((int)MouseButton.Button1);
|
};
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_4_UP) != 0) mouse.DisableBit((int)MouseButton.Button1);
|
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_5_DOWN) != 0) mouse.EnableBit((int)MouseButton.Button2);
|
if ((raw.ButtonFlags & RawInputMouseState.LEFT_BUTTON_DOWN) != 0) EnableBit(MouseButton.Left);
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_5_UP) != 0) mouse.DisableBit((int)MouseButton.Button2);
|
if ((raw.ButtonFlags & RawInputMouseState.LEFT_BUTTON_UP) != 0) DisableBit(MouseButton.Left);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.RIGHT_BUTTON_DOWN) != 0) EnableBit(MouseButton.Right);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.RIGHT_BUTTON_UP) != 0) DisableBit(MouseButton.Right);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.MIDDLE_BUTTON_DOWN) != 0) EnableBit(MouseButton.Middle);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.MIDDLE_BUTTON_UP) != 0) DisableBit(MouseButton.Middle);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_4_DOWN) != 0) EnableBit(MouseButton.Button1);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_4_UP) != 0) DisableBit(MouseButton.Button1);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_5_DOWN) != 0) EnableBit(MouseButton.Button2);
|
||||||
|
if ((raw.ButtonFlags & RawInputMouseState.BUTTON_5_UP) != 0) DisableBit(MouseButton.Button2);
|
||||||
|
|
||||||
if ((raw.ButtonFlags & RawInputMouseState.WHEEL) != 0)
|
if ((raw.ButtonFlags & RawInputMouseState.WHEEL) != 0)
|
||||||
mouse.WheelPrecise += (short)raw.ButtonData / 120.0f;
|
mouse.WheelPrecise += (short)raw.ButtonData / 120.0f;
|
||||||
|
|
Loading…
Reference in a new issue