From 2f2c3e4f68a37f9a770c465d7a8180554a076cac Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Sun, 23 Feb 2025 21:42:30 -0800 Subject: [PATCH] Try fixing pointer barriers harder (still doesn't work :( ), also fix XI2 raw motion polling (IsNormal was always returning false for whatever reason, seems to work fine with just simple Inf/NaN checks). XI2 raw motion polling however seems to use a far larger scale compared to Windows (seemingly in the hundred thousands??? although this is in a VM so this might just be a quirk of such) --- .../KeyMouseInput/X11KeyMouseInput.cs | 13 ++----------- src/BizHawk.Client.EmuHawk/MainForm.cs | 14 +++++++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/BizHawk.Bizware.Input/KeyMouseInput/X11KeyMouseInput.cs b/src/BizHawk.Bizware.Input/KeyMouseInput/X11KeyMouseInput.cs index b714827e4c..3b12eed679 100644 --- a/src/BizHawk.Bizware.Input/KeyMouseInput/X11KeyMouseInput.cs +++ b/src/BizHawk.Bizware.Input/KeyMouseInput/X11KeyMouseInput.cs @@ -184,19 +184,10 @@ namespace BizHawk.Bizware.Input { var rawValueIndex = 0; - // not implemented until netcore / netstandard2.1 - // copied from modern runtime - static bool IsNormal(double d) - { - var bits = BitConverter.DoubleToInt64Bits(d); - bits &= 0x7FFF_FFFF_FFFF_FFFF; - return (bits < 0x7FF0_0000_0000_0000) && (bits != 0) && ((bits & 0x7FF0_0000_0000_0000) == 0); - } - if (XIMaskIsSet(valuatorsMask, 0)) { var deltaX = xiRawEvent->raw_values[rawValueIndex]; - if (IsNormal(deltaX)) + if (!double.IsInfinity(deltaX) && !double.IsNaN(deltaX)) { mouseDeltaX += deltaX; } @@ -207,7 +198,7 @@ namespace BizHawk.Bizware.Input if (XIMaskIsSet(valuatorsMask, 1)) { var deltaY = xiRawEvent->raw_values[rawValueIndex]; - if (IsNormal(deltaY)) + if (!double.IsInfinity(deltaY) && !double.IsNaN(deltaY)) { mouseDeltaY += deltaY; } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index f4c2f8eb78..c394172d7c 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -4899,23 +4899,27 @@ namespace BizHawk.Client.EmuHawk fbLocation.Offset(_presentationPanel.Control.Location); var barrierRect = new Rectangle(fbLocation, _presentationPanel.Control.Size); - // each line of the barrier rect must be a separate barrier object + // each line of the barrier rect must be a separate barrier object + // also, the lines should span the entire screen, to avoid the cursor escaping at the corner + + var mfScreen = Screen.FromControl(this); + var screenRect = mfScreen.Bounds; // left barrier _pointerBarriers[0] = XfixesImports.XFixesCreatePointerBarrier( - _x11Display, Handle, barrierRect.X, barrierRect.Y, barrierRect.X, barrierRect.Bottom, + _x11Display, Handle, barrierRect.X, screenRect.Y, barrierRect.X, screenRect.Bottom, XfixesImports.BarrierDirection.BarrierPositiveX, 0, IntPtr.Zero); // top barrier _pointerBarriers[1] = XfixesImports.XFixesCreatePointerBarrier( - _x11Display, Handle, barrierRect.X, barrierRect.Y, barrierRect.Right, barrierRect.Y, + _x11Display, Handle, screenRect.X, barrierRect.Y, screenRect.Right, barrierRect.Y, XfixesImports.BarrierDirection.BarrierPositiveY, 0, IntPtr.Zero); // right barrier _pointerBarriers[2] = XfixesImports.XFixesCreatePointerBarrier( - _x11Display, Handle, barrierRect.Right, barrierRect.Y, barrierRect.Right, barrierRect.Bottom, + _x11Display, Handle, barrierRect.Right, screenRect.Y, barrierRect.Right, screenRect.Bottom, XfixesImports.BarrierDirection.BarrierNegativeX, 0, IntPtr.Zero); // bottom barrier _pointerBarriers[3] = XfixesImports.XFixesCreatePointerBarrier( - _x11Display, Handle, barrierRect.X, barrierRect.Bottom, barrierRect.Right, barrierRect.Bottom, + _x11Display, Handle, screenRect.X, barrierRect.Bottom, screenRect.Right, barrierRect.Bottom, XfixesImports.BarrierDirection.BarrierNegativeY, 0, IntPtr.Zero); } else