Respect background input setting for axis values

- closes #3957.
Previously, axis values were always set, even when that setting was offf.
This commit is contained in:
Morilli 2024-06-26 23:19:56 +02:00
parent 64ef1bfc17
commit bf82d95e0d
1 changed files with 8 additions and 5 deletions

View File

@ -133,6 +133,9 @@ namespace BizHawk.Client.EmuHawk
private void HandleAxis(string axis, int newValue) private void HandleAxis(string axis, int newValue)
{ {
if (ShouldSwallow(MainFormInputAllowedCallback(false), ClientInputFocus.Pad))
return;
if (_trackDeltas) _axisDeltas[axis] += Math.Abs(newValue - _axisValues[axis]); if (_trackDeltas) _axisDeltas[axis] += Math.Abs(newValue - _axisValues[axis]);
_axisValues[axis] = newValue; _axisValues[axis] = newValue;
} }
@ -250,9 +253,9 @@ namespace BizHawk.Client.EmuHawk
foreach (var ie in _newEvents) foreach (var ie in _newEvents)
{ {
//events are swallowed in some cases: //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; continue;
if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie)) if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie.Source))
continue; continue;
EnqueueEvent(ie); 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() public void StartListeningForAxisEvents()
@ -326,7 +329,7 @@ namespace BizHawk.Client.EmuHawk
{ {
InputEvent ie = DequeueEvent(); InputEvent ie = DequeueEvent();
if (ShouldSwallow(allowInput, ie)) continue; if (ShouldSwallow(allowInput, ie.Source)) continue;
if (ie.EventType == InputEventType.Press) if (ie.EventType == InputEventType.Press)
{ {