mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-23 02:58:27 +00:00
[Mac] Add horizontal scrolling
This commit is contained in:
parent
30c73e8ead
commit
4b115c443b
|
@ -78,6 +78,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
static readonly IntPtr selLocationInWindowOwner = Selector.Get("locationInWindow");
|
static readonly IntPtr selLocationInWindowOwner = Selector.Get("locationInWindow");
|
||||||
static readonly IntPtr selHide = Selector.Get("hide");
|
static readonly IntPtr selHide = Selector.Get("hide");
|
||||||
static readonly IntPtr selUnhide = Selector.Get("unhide");
|
static readonly IntPtr selUnhide = Selector.Get("unhide");
|
||||||
|
static readonly IntPtr selScrollingDeltaX = Selector.Get("scrollingDeltaX");
|
||||||
static readonly IntPtr selScrollingDeltaY = Selector.Get("scrollingDeltaY");
|
static readonly IntPtr selScrollingDeltaY = Selector.Get("scrollingDeltaY");
|
||||||
static readonly IntPtr selDeltaX = Selector.Get("deltaX");
|
static readonly IntPtr selDeltaX = Selector.Get("deltaX");
|
||||||
static readonly IntPtr selDeltaY = Selector.Get("deltaY");
|
static readonly IntPtr selDeltaY = Selector.Get("deltaY");
|
||||||
|
@ -145,7 +146,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
private bool cursorInsideWindow = true;
|
private bool cursorInsideWindow = true;
|
||||||
private MouseCursor selectedCursor = MouseCursor.Default; // user-selected cursor
|
private MouseCursor selectedCursor = MouseCursor.Default; // user-selected cursor
|
||||||
|
|
||||||
private const float scrollFactor = 120.0f;
|
private const float scrollFactor = 10.0f;
|
||||||
private const bool exclusiveFullscreen = false;
|
private const bool exclusiveFullscreen = false;
|
||||||
|
|
||||||
public CocoaNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
public CocoaNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||||
|
@ -517,9 +518,13 @@ namespace OpenTK.Platform.MacOS
|
||||||
MathHelper.Clamp((int)Math.Round(p.Y + dy), 0, Height));
|
MathHelper.Clamp((int)Math.Round(p.Y + dy), 0, Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseState.X = p.X;
|
// Only raise events when the mouse has actually moved
|
||||||
MouseState.Y = p.Y;
|
if (MouseState.X != p.X || MouseState.Y != p.Y)
|
||||||
OnMouseMove();
|
{
|
||||||
|
MouseState.X = p.X;
|
||||||
|
MouseState.Y = p.Y;
|
||||||
|
OnMouseMove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -528,16 +533,24 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
case NSEventType.ScrollWheel:
|
case NSEventType.ScrollWheel:
|
||||||
{
|
{
|
||||||
var scrollingDelta = Cocoa.SendFloat(e, selScrollingDeltaY);
|
float dx, dy;
|
||||||
var factor = 1.0f;
|
|
||||||
|
|
||||||
if (Cocoa.SendBool(e, selHasPreciseScrollingDeltas))
|
if (Cocoa.SendBool(e, selHasPreciseScrollingDeltas))
|
||||||
{
|
{
|
||||||
factor = 1.0f / scrollFactor; // Problem: Don't know what factor to use here, but this seems to work.
|
dx = Cocoa.SendFloat(e, selScrollingDeltaX) / scrollFactor;
|
||||||
|
dy = Cocoa.SendFloat(e, selScrollingDeltaY) / scrollFactor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dx = Cocoa.SendFloat(e, selDeltaX);
|
||||||
|
dy = Cocoa.SendFloat(e, selDeltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseState.SetScrollRelative(0, scrollingDelta * factor);
|
// Only raise wheel events when the user has actually scrolled
|
||||||
OnMouseWheel();
|
if (dx != 0 || dy != 0)
|
||||||
|
{
|
||||||
|
MouseState.SetScrollRelative(dx, dy);
|
||||||
|
OnMouseWheel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue