mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 06:25:38 +00:00
[Mac] Match win32 scrolling coordinates
This commit is contained in:
parent
525af589f1
commit
2a4f634848
|
@ -540,7 +540,10 @@ namespace OpenTK.Platform.MacOS
|
||||||
// Only raise wheel events when the user has actually scrolled
|
// Only raise wheel events when the user has actually scrolled
|
||||||
if (dx != 0 || dy != 0)
|
if (dx != 0 || dy != 0)
|
||||||
{
|
{
|
||||||
OnMouseWheel(dx, dy);
|
// Note: OpenTK follows the win32 convention, where
|
||||||
|
// (+h, +v) = (right, up). MacOS reports (+h, +v) = (left, up)
|
||||||
|
// so we need to flip the horizontal scroll direction.
|
||||||
|
OnMouseWheel(-dx, dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -180,9 +180,14 @@ namespace OpenTK.Platform.MacOS
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CGEventType.ScrollWheel:
|
case CGEventType.ScrollWheel:
|
||||||
CursorState.SetScrollRelative(
|
{
|
||||||
(float)CG.EventGetDoubleValueField(@event, CGEventField.ScrollWheelEventPointDeltaAxis2) * MacOSFactory.ScrollFactor,
|
// Note: OpenTK follows the win32 convention, where
|
||||||
(float)CG.EventGetDoubleValueField(@event, CGEventField.ScrollWheelEventPointDeltaAxis1) * MacOSFactory.ScrollFactor);
|
// (+h, +v) = (right, up). MacOS reports (+h, +v) = (left, up)
|
||||||
|
// so we need to flip the horizontal scroll direction.
|
||||||
|
double h = CG.EventGetDoubleValueField(@event, CGEventField.ScrollWheelEventPointDeltaAxis2) * MacOSFactory.ScrollFactor;
|
||||||
|
double v = CG.EventGetDoubleValueField(@event, CGEventField.ScrollWheelEventPointDeltaAxis1) * MacOSFactory.ScrollFactor;
|
||||||
|
CursorState.SetScrollRelative((float)(-h), (float)v);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CGEventType.LeftMouseDown:
|
case CGEventType.LeftMouseDown:
|
||||||
|
@ -190,6 +195,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
case CGEventType.OtherMouseDown:
|
case CGEventType.OtherMouseDown:
|
||||||
{
|
{
|
||||||
int n = CG.EventGetIntegerValueField(@event, CGEventField.MouseEventButtonNumber);
|
int n = CG.EventGetIntegerValueField(@event, CGEventField.MouseEventButtonNumber);
|
||||||
|
n = n == 1 ? 2 : n == 2 ? 1 : n; // flip middle and right button numbers to match OpenTK
|
||||||
MouseButton b = MouseButton.Left + n;
|
MouseButton b = MouseButton.Left + n;
|
||||||
CursorState[b] = true;
|
CursorState[b] = true;
|
||||||
}
|
}
|
||||||
|
@ -200,6 +206,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
case CGEventType.OtherMouseUp:
|
case CGEventType.OtherMouseUp:
|
||||||
{
|
{
|
||||||
int n = CG.EventGetIntegerValueField(@event, CGEventField.MouseEventButtonNumber);
|
int n = CG.EventGetIntegerValueField(@event, CGEventField.MouseEventButtonNumber);
|
||||||
|
n = n == 1 ? 2 : n == 2 ? 1 : n; // flip middle and right button numbers to match OpenTK
|
||||||
MouseButton b = MouseButton.Left + n;
|
MouseButton b = MouseButton.Left + n;
|
||||||
CursorState[b] = false;
|
CursorState[b] = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue