From bf82d95e0d8fa3d5fedb332c9e89e185477491dd Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Wed, 26 Jun 2024 23:19:56 +0200 Subject: [PATCH] Respect background input setting for axis values - closes #3957. Previously, axis values were always set, even when that setting was offf. --- src/BizHawk.Client.EmuHawk/Input/Input.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/Input/Input.cs b/src/BizHawk.Client.EmuHawk/Input/Input.cs index e90c295563..5aad4dafc8 100644 --- a/src/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/src/BizHawk.Client.EmuHawk/Input/Input.cs @@ -133,6 +133,9 @@ namespace BizHawk.Client.EmuHawk private void HandleAxis(string axis, int newValue) { + if (ShouldSwallow(MainFormInputAllowedCallback(false), ClientInputFocus.Pad)) + return; + if (_trackDeltas) _axisDeltas[axis] += Math.Abs(newValue - _axisValues[axis]); _axisValues[axis] = newValue; } @@ -250,9 +253,9 @@ namespace BizHawk.Client.EmuHawk foreach (var ie in _newEvents) { //events are swallowed in some cases: - if ((ie.LogicalButton.Modifiers & LogicalButton.MASK_ALT) is not 0U && ShouldSwallow(MainFormInputAllowedCallback(true), ie)) + if ((ie.LogicalButton.Modifiers & LogicalButton.MASK_ALT) is not 0U && ShouldSwallow(MainFormInputAllowedCallback(true), ie.Source)) continue; - if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie)) + if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie.Source)) continue; EnqueueEvent(ie); @@ -267,9 +270,9 @@ namespace BizHawk.Client.EmuHawk } } - private static bool ShouldSwallow(AllowInput allowInput, InputEvent inputEvent) + private static bool ShouldSwallow(AllowInput allowInput, ClientInputFocus inputFocus) { - return allowInput == AllowInput.None || (allowInput == AllowInput.OnlyController && inputEvent.Source != ClientInputFocus.Pad); + return allowInput == AllowInput.None || (allowInput == AllowInput.OnlyController && inputFocus != ClientInputFocus.Pad); } public void StartListeningForAxisEvents() @@ -326,7 +329,7 @@ namespace BizHawk.Client.EmuHawk { InputEvent ie = DequeueEvent(); - if (ShouldSwallow(allowInput, ie)) continue; + if (ShouldSwallow(allowInput, ie.Source)) continue; if (ie.EventType == InputEventType.Press) {