Skip to content

Commit 4a47079

Browse files
committed
Fix: Input overrides hotkeys did not work if both input and hotkey were bound to a combination such as Shift+A.
passes test ControllerPriorityWithModifier
1 parent 6b20777 commit 4a47079

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/BizHawk.Client.Common/Controller.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,20 @@ public bool AnyInputHeld
5959
public List<string> SearchBindings(string button)
6060
=> _bindings.Where(b => b.Value.Contains(button)).Select(static b => b.Key).ToList();
6161

62-
// Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller
63-
public bool HasBinding(string button) =>
64-
_bindings
62+
/// <summary>
63+
/// Checks if the given button combination would be a controller input.
64+
/// This means Shift+A will return true if an input is bound to either A or Shift+A.
65+
/// </summary>
66+
public bool HasBinding(string button)
67+
{
68+
string[] buttons = button.Split('+');
69+
return _bindings
6570
.SelectMany(kvp => kvp.Value)
66-
.Any(boundButton => boundButton == button);
71+
.Any((boundCombination) => {
72+
string[] boundButtons = boundCombination.Split('+');
73+
return boundButtons.All((b) => buttons.Contains(b));
74+
});
75+
}
6776

6877
/// <summary>
6978
/// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding).

src/BizHawk.Client.Common/inputAdapters/InputManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void ProcessInput(IInputSource source, Func<string, bool> processHotkey,
167167
// TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing
168168

169169
var hotkeyTriggers = ClientControls.SearchBindings(ie.LogicalButton.ToString());
170-
bool isEmuInput = ie.LogicalButton.ToString().Split('+').Any(ActiveController.HasBinding);
170+
bool isEmuInput = ActiveController.HasBinding(ie.LogicalButton.ToString());
171171

172172
bool shouldDoHotkey = config.InputHotkeyOverrideOptions != 1;
173173
bool shouldDoEmuInput = config.InputHotkeyOverrideOptions != 2;

0 commit comments

Comments
 (0)