diff --git a/src/BizHawk.Bizware.Input/HostInputFocus.cs b/src/BizHawk.Bizware.Input/HostInputType.cs similarity index 81% rename from src/BizHawk.Bizware.Input/HostInputFocus.cs rename to src/BizHawk.Bizware.Input/HostInputType.cs index 57a8bff423..01587fb776 100644 --- a/src/BizHawk.Bizware.Input/HostInputFocus.cs +++ b/src/BizHawk.Bizware.Input/HostInputType.cs @@ -3,7 +3,7 @@ namespace BizHawk.Bizware.Input { [Flags] - public enum HostInputFocus + public enum HostInputType { None = 0, Mouse = 1, diff --git a/src/BizHawk.Bizware.Input/IHostInputAdapter.cs b/src/BizHawk.Bizware.Input/IHostInputAdapter.cs index 8947a7ed02..4c006c6de7 100644 --- a/src/BizHawk.Bizware.Input/IHostInputAdapter.cs +++ b/src/BizHawk.Bizware.Input/IHostInputAdapter.cs @@ -20,7 +20,7 @@ namespace BizHawk.Bizware.Input void PreprocessHostGamepads(); - void ProcessHostGamepads(Action handleButton, Action handleAxis); + void ProcessHostGamepads(Action handleButton, Action handleAxis); IEnumerable ProcessHostKeyboards(); diff --git a/src/BizHawk.Bizware.Input/OSTailoredKeyInputAdapter.cs b/src/BizHawk.Bizware.Input/OSTailoredKeyInputAdapter.cs index b9fa23ae79..761351d3b9 100644 --- a/src/BizHawk.Bizware.Input/OSTailoredKeyInputAdapter.cs +++ b/src/BizHawk.Bizware.Input/OSTailoredKeyInputAdapter.cs @@ -31,7 +31,7 @@ namespace BizHawk.Bizware.Input public abstract void PreprocessHostGamepads(); - public abstract void ProcessHostGamepads(Action handleButton, Action handleAxis); + public abstract void ProcessHostGamepads(Action handleButton, Action handleAxis); public virtual IEnumerable ProcessHostKeyboards() { diff --git a/src/BizHawk.Bizware.Input/SDL2/SDL2InputAdapter.cs b/src/BizHawk.Bizware.Input/SDL2/SDL2InputAdapter.cs index 06a7bbfc6f..343fd6d3fc 100644 --- a/src/BizHawk.Bizware.Input/SDL2/SDL2InputAdapter.cs +++ b/src/BizHawk.Bizware.Input/SDL2/SDL2InputAdapter.cs @@ -148,7 +148,7 @@ namespace BizHawk.Bizware.Input DoSDLEventLoop(); } - public override void ProcessHostGamepads(Action handleButton, Action handleAxis) + public override void ProcessHostGamepads(Action handleButton, Action handleAxis) { if (!_isInit) return; @@ -156,7 +156,7 @@ namespace BizHawk.Bizware.Input { foreach (var (ButtonName, GetIsPressed) in pad.ButtonGetters) { - handleButton(pad.InputNamePrefix + ButtonName, GetIsPressed(), HostInputFocus.Pad); + handleButton(pad.InputNamePrefix + ButtonName, GetIsPressed(), HostInputType.Pad); } foreach (var (axisID, f) in pad.GetAxes()) diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs index fc67cd18bd..fb5c5a40ef 100644 --- a/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs +++ b/src/BizHawk.Client.Common/Api/Interfaces/IInputApi.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +using BizHawk.Bizware.Input; + namespace BizHawk.Client.Common { /// for querying host input diff --git a/src/BizHawk.Client.Common/input/InputEvent.cs b/src/BizHawk.Client.Common/input/InputEvent.cs index fcbd07e07f..71536c8467 100644 --- a/src/BizHawk.Client.Common/input/InputEvent.cs +++ b/src/BizHawk.Client.Common/input/InputEvent.cs @@ -13,7 +13,7 @@ namespace BizHawk.Client.Common public LogicalButton LogicalButton; - public HostInputFocus Source; + public HostInputType Source; public override string ToString() => $"{EventType}:{LogicalButton}"; } diff --git a/src/BizHawk.Client.EmuHawk/Input/Input.cs b/src/BizHawk.Client.EmuHawk/Input/Input.cs index e11770f939..bff97c0323 100644 --- a/src/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/src/BizHawk.Client.EmuHawk/Input/Input.cs @@ -18,10 +18,10 @@ namespace BizHawk.Client.EmuHawk /// Why is this receiving a control, but actually using it as a Form (where the WantingMouseFocus is checked?) /// Because later we might change it to work off the control, specifically, if a control is supplied (normally actually a Form will be supplied) /// - public void ControlInputFocus(Control c, HostInputFocus types, bool wants) + public void ControlInputFocus(Control c, HostInputType types, bool wants) { - if (types.HasFlag(HostInputFocus.Mouse) && wants) _wantingMouseFocus.Add(c); - if (types.HasFlag(HostInputFocus.Mouse) && !wants) _wantingMouseFocus.Remove(c); + if (types.HasFlag(HostInputType.Mouse) && wants) _wantingMouseFocus.Add(c); + if (types.HasFlag(HostInputType.Mouse) && !wants) _wantingMouseFocus.Remove(c); } private readonly HashSet _wantingMouseFocus = new HashSet(); @@ -96,7 +96,7 @@ namespace BizHawk.Client.EmuHawk ["Shift"] = "LeftShift", }; - private void HandleButton(string button, bool newState, HostInputFocus source) + private void HandleButton(string button, bool newState, HostInputType source) { if (!(_currentConfig.MergeLAndRModifierKeys && ModifierKeyPreMap.TryGetValue(button, out var button1))) button1 = button; var modIndex = _currentConfig.ModifierKeysEffective.IndexOf(button1); @@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk private void HandleAxis(string axis, int newValue) { - if (ShouldSwallow(MainFormInputAllowedCallback(false), HostInputFocus.Pad)) + if (ShouldSwallow(MainFormInputAllowedCallback(false), HostInputType.Pad)) return; if (_trackDeltas) @@ -208,7 +208,7 @@ namespace BizHawk.Client.EmuHawk //analyze keys foreach (var ke in keyEvents) { - HandleButton(DistinctKeyNameOverrides.GetName(ke.Key), ke.Pressed, HostInputFocus.Keyboard); + HandleButton(DistinctKeyNameOverrides.GetName(ke.Key), ke.Pressed, HostInputType.Keyboard); } lock (_axisValues) @@ -234,11 +234,11 @@ namespace BizHawk.Client.EmuHawk _axisValues["WMouse Y"] = mousePos.Y; var mouseBtns = Control.MouseButtons; - HandleButton("WMouse L", (mouseBtns & MouseButtons.Left) != 0, HostInputFocus.Mouse); - HandleButton("WMouse M", (mouseBtns & MouseButtons.Middle) != 0, HostInputFocus.Mouse); - HandleButton("WMouse R", (mouseBtns & MouseButtons.Right) != 0, HostInputFocus.Mouse); - HandleButton("WMouse 1", (mouseBtns & MouseButtons.XButton1) != 0, HostInputFocus.Mouse); - HandleButton("WMouse 2", (mouseBtns & MouseButtons.XButton2) != 0, HostInputFocus.Mouse); + HandleButton("WMouse L", (mouseBtns & MouseButtons.Left) != 0, HostInputType.Mouse); + HandleButton("WMouse M", (mouseBtns & MouseButtons.Middle) != 0, HostInputType.Mouse); + HandleButton("WMouse R", (mouseBtns & MouseButtons.Right) != 0, HostInputType.Mouse); + HandleButton("WMouse 1", (mouseBtns & MouseButtons.XButton1) != 0, HostInputType.Mouse); + HandleButton("WMouse 2", (mouseBtns & MouseButtons.XButton2) != 0, HostInputType.Mouse); // raw (relative) mouse input _axisValues["RMouse X"] = mouseDeltaX; @@ -282,9 +282,9 @@ namespace BizHawk.Client.EmuHawk } } - private static bool ShouldSwallow(AllowInput allowInput, HostInputFocus inputFocus) + private static bool ShouldSwallow(AllowInput allowInput, HostInputType inputFocus) { - return allowInput == AllowInput.None || (allowInput == AllowInput.OnlyController && inputFocus != HostInputFocus.Pad); + return allowInput == AllowInput.None || (allowInput == AllowInput.OnlyController && inputFocus != HostInputType.Pad); } public void StartListeningForAxisEvents() diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 092712f143..ef43ae8677 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -1164,12 +1164,12 @@ namespace BizHawk.Client.EmuHawk protected override void OnActivated(EventArgs e) { base.OnActivated(e); - Input.Instance.ControlInputFocus(this, HostInputFocus.Mouse, true); + Input.Instance.ControlInputFocus(this, HostInputType.Mouse, true); } protected override void OnDeactivate(EventArgs e) { - Input.Instance.ControlInputFocus(this, HostInputFocus.Mouse, false); + Input.Instance.ControlInputFocus(this, HostInputType.Mouse, false); base.OnDeactivate(e); } diff --git a/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs b/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs index 57860d9bd3..9ecf285a7a 100644 --- a/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/ControllerConfig.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; +using BizHawk.Bizware.Input; using BizHawk.Client.Common; using BizHawk.Common; using BizHawk.Common.CollectionExtensions; @@ -58,13 +59,13 @@ namespace BizHawk.Client.EmuHawk protected override void OnActivated(EventArgs e) { base.OnActivated(e); - Input.Instance.ControlInputFocus(this, ClientInputFocus.Mouse, true); + Input.Instance.ControlInputFocus(this, HostInputType.Mouse, true); } protected override void OnDeactivate(EventArgs e) { base.OnDeactivate(e); - Input.Instance.ControlInputFocus(this, ClientInputFocus.Mouse, false); + Input.Instance.ControlInputFocus(this, HostInputType.Mouse, false); } private void ControllerConfig_Load(object sender, EventArgs e) diff --git a/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs b/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs index 7d896bff98..eeab67f3c7 100644 --- a/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs +++ b/src/BizHawk.Client.EmuHawk/config/ControllerConfig/FeedbackBindControl.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Windows.Forms; +using BizHawk.Bizware.Input; using BizHawk.Client.Common; using BizHawk.Common.StringExtensions; using BizHawk.WinForms.Controls; diff --git a/src/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs b/src/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs index 4419225eae..d13726a2d3 100644 --- a/src/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/HotkeyConfig.cs @@ -3,6 +3,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using BizHawk.Bizware.Input; using BizHawk.Client.Common; using BizHawk.Common; using BizHawk.Common.CollectionExtensions; @@ -25,13 +26,13 @@ namespace BizHawk.Client.EmuHawk protected override void OnActivated(EventArgs e) { base.OnActivated(e); - Input.Instance.ControlInputFocus(this, ClientInputFocus.Mouse, true); + Input.Instance.ControlInputFocus(this, HostInputType.Mouse, true); } protected override void OnDeactivate(EventArgs e) { base.OnDeactivate(e); - Input.Instance.ControlInputFocus(this, ClientInputFocus.Mouse, false); + Input.Instance.ControlInputFocus(this, HostInputType.Mouse, false); } private void HotkeyConfig_Load(object sender, EventArgs e)