Skip to content

Commit 4ff24e2

Browse files
committed
Fix: Controller inputs bound to a modifier key combination would not be triggered if additional modifier keys were also pressed.
1 parent 164acd8 commit 4ff24e2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/BizHawk.Client.Common/input/InputCoalescerControllers.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ public class InputCoalescer : SimpleController
1111
public InputCoalescer()
1212
: base(NullController.Instance.Definition) {} // is Definition ever read on these subclasses? --yoshi
1313

14-
protected virtual void ProcessSubsets(string button, bool state) {}
14+
protected virtual void ProcessInput(string button, bool state)
15+
{
16+
Buttons[button] = state;
17+
}
1518

1619
public void Receive(InputEvent ie)
1720
{
1821
var state = ie.EventType is InputEventType.Press;
1922
var button = ie.LogicalButton.ToString();
20-
Buttons[button] = state;
21-
ProcessSubsets(button, state);
23+
ProcessInput(button, state);
2224
if (state) return;
2325
// when a button or modifier key is released, all modified key variants with it are released as well
2426
foreach (var k in Buttons.Keys.Where(k =>
@@ -30,10 +32,21 @@ public void Receive(InputEvent ie)
3032

3133
public sealed class ControllerInputCoalescer : InputCoalescer
3234
{
33-
protected override void ProcessSubsets(string button, bool state)
35+
protected override void ProcessInput(string button, bool state)
3436
{
3537
// For controller input, we want Shift+X to register as both Shift and X (for Keyboard controllers)
3638
foreach (var s in button.Split('+')) Buttons[s] = state;
3739
}
40+
41+
public override bool IsPressed(string button)
42+
{
43+
// Since we split all inputs into their separate physical buttons, we need to check combinations here.
44+
bool allPressed = true;
45+
foreach (var individualButton in button.Split('+'))
46+
{
47+
allPressed &= Buttons.GetValueOrDefault(individualButton);
48+
}
49+
return allPressed;
50+
}
3851
}
3952
}

0 commit comments

Comments
 (0)