From 525af589f1c9ac38415a0ead1b9f2bb029688aed Mon Sep 17 00:00:00 2001 From: thefiddler Date: Tue, 10 Jun 2014 14:53:23 +0200 Subject: [PATCH] [X11] Match win32 wheel coordinate system OpenTK uses the win32 wheel coordinate system, where (+h, +v) = (right, up). XI2 uses (+h, +v) = (right, down) instead, so we need to flip the vertical offset. Fixes issue #133 and https://github.com/mono/MonoGame/issues/2686 --- Source/OpenTK/Platform/X11/XI2MouseKeyboard.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/X11/XI2MouseKeyboard.cs b/Source/OpenTK/Platform/X11/XI2MouseKeyboard.cs index 1ef31796..0df840ce 100644 --- a/Source/OpenTK/Platform/X11/XI2MouseKeyboard.cs +++ b/Source/OpenTK/Platform/X11/XI2MouseKeyboard.cs @@ -544,7 +544,11 @@ namespace OpenTK.Platform.X11 d.State.X += (int)Math.Round(x); d.State.Y += (int)Math.Round(y); - d.State.SetScrollRelative((float)h, (float)v); + + // Note: OpenTK follows the windows scrolling convention where + // (+h, +v) = (right, up). XI2 uses (+h, +v) = (right, down) + // instead, so we need to flip the vertical offset. + d.State.SetScrollRelative((float)h, (float)(-v)); } unsafe static double ReadRawValue(ref XIRawEvent raw, int bit)