From 23815b47839ef75ca9a0df8658d2ce6d557d9f73 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sun, 22 Sep 2024 23:56:53 +0200 Subject: [PATCH] some more sticky renames for clarity SetSticky and ClearStickies sounds an awful like they affect the same thing, also this makes it clear whether to set a hold or an autofire --- .../Api/Classes/JoypadApi.cs | 2 +- .../inputAdapters/StickyAdapters.cs | 18 +++++++++--------- .../tools/TAStudio/TAStudio.ListView.cs | 4 ++-- .../controls/VirtualPadAnalogButton.cs | 4 ++-- .../controls/VirtualPadAnalogStick.cs | 4 ++-- .../VirtualPads/controls/VirtualPadButton.cs | 8 ++++---- .../controls/VirtualPadDiscManager.cs | 2 +- .../controls/VirtualPadTargetScreen.cs | 8 ++++---- .../controls/components/AnalogStickPanel.cs | 4 ++-- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs b/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs index e9e6113b7e..d66c5cc550 100644 --- a/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs @@ -97,7 +97,7 @@ namespace BizHawk.Client.Common { try { - _inputManager.StickyXorAdapter.SetAxis(controller == null ? control : $"P{controller} {control}", value); + _inputManager.StickyXorAdapter.SetAxisHold(controller == null ? control : $"P{controller} {control}", value); } catch { diff --git a/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs b/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs index 790a2d76f1..02f64767f1 100644 --- a/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs +++ b/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs @@ -38,9 +38,9 @@ namespace BizHawk.Client.Common public void SetHapticChannelStrength(string name, int strength) => Source.SetHapticChannelStrength(name, strength); - public void SetSticky(string button, bool isSticky) + public void SetButtonHold(string button, bool enabled) { - if (isSticky) + if (enabled) { _buttonHolds.Add(button); } @@ -50,11 +50,11 @@ namespace BizHawk.Client.Common } } - public void SetAxis(string name, int? value) + public void SetAxisHold(string name, int? value) { - if (value is int i) + if (value.HasValue) { - _axisHolds[name] = i; + _axisHolds[name] = value.Value; } else { @@ -140,9 +140,9 @@ namespace BizHawk.Client.Common _offFrames = Math.Max(offFrames, 1); } - public void SetSticky(string button, bool isSticky, AutoPatternBool pattern = null) + public void SetButtonAutofire(string button, bool enabled, AutoPatternBool pattern = null) { - if (isSticky) + if (enabled) { pattern ??= new AutoPatternBool(_onFrames, _offFrames); _boolPatterns[button] = pattern; @@ -153,7 +153,7 @@ namespace BizHawk.Client.Common } } - public void SetAxis(string name, int? value, AutoPatternAxis pattern = null) + public void SetAxisAutofire(string name, int? value, AutoPatternAxis pattern = null) { if (value.HasValue) { @@ -186,7 +186,7 @@ namespace BizHawk.Client.Common { foreach (var button in buttons.Where(button => !_justPressed.Contains(button))) { - SetSticky(button, !_boolPatterns.ContainsKey(button)); + SetButtonAutofire(button, !_boolPatterns.ContainsKey(button)); } _justPressed = buttons; diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 5b0a3f4810..872d17eef3 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -471,7 +471,7 @@ namespace BizHawk.Client.EmuHawk if (index < BoolPatterns.Length) { AutoPatternBool p = BoolPatterns[index]; - InputManager.AutofireStickyXorAdapter.SetSticky(button, isOn.Value, p); + InputManager.AutofireStickyXorAdapter.SetButtonAutofire(button, isOn.Value, p); } } else @@ -496,7 +496,7 @@ namespace BizHawk.Client.EmuHawk if (index < AxisPatterns.Length) { AutoPatternAxis p = AxisPatterns[index]; - InputManager.AutofireStickyXorAdapter.SetAxis(button, value, p); + InputManager.AutofireStickyXorAdapter.SetAxisAutofire(button, value, p); } } } diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs index 9805450ad2..a7a741f577 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.cs @@ -75,7 +75,7 @@ namespace BizHawk.Client.EmuHawk public void Clear() { - _stickyXorAdapter.SetAxis(Name, null); + _stickyXorAdapter.SetAxisHold(Name, null); IsSet = false; } @@ -149,7 +149,7 @@ namespace BizHawk.Client.EmuHawk if (!_programmaticallyChangingValue) { CurrentValue = AnalogTrackBar.Value; - _stickyXorAdapter.SetAxis(Name, AnalogTrackBar.Value); + _stickyXorAdapter.SetAxisHold(Name, AnalogTrackBar.Value); } } diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs index 7ee0b792fa..75d87715db 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs @@ -138,8 +138,8 @@ namespace BizHawk.Client.EmuHawk { AnalogStick.Clear(fromCallback: true); SetNumericsFromAnalog(); - _stickyXorAdapter.SetAxis(AnalogStick.XName, null); - _stickyXorAdapter.SetAxis(AnalogStick.YName, null); + _stickyXorAdapter.SetAxisHold(AnalogStick.XName, null); + _stickyXorAdapter.SetAxisHold(AnalogStick.YName, null); } public void Clear() => AnalogStick.Clear(); diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs index 03de6452af..c79a355f31 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadButton.cs @@ -31,8 +31,8 @@ namespace BizHawk.Client.EmuHawk RightClicked = false; Checked = false; //HOOMOO - InputManager.AutofireStickyXorAdapter.SetSticky(Name, false); - InputManager.StickyXorAdapter.SetSticky(Name, false); + InputManager.AutofireStickyXorAdapter.SetButtonAutofire(Name, false); + InputManager.StickyXorAdapter.SetButtonHold(Name, false); } } @@ -133,11 +133,11 @@ namespace BizHawk.Client.EmuHawk { if (RightClicked) { - InputManager.AutofireStickyXorAdapter.SetSticky(Name, Checked); + InputManager.AutofireStickyXorAdapter.SetButtonAutofire(Name, Checked); } else { - InputManager.StickyXorAdapter.SetSticky(Name, Checked); + InputManager.StickyXorAdapter.SetButtonHold(Name, Checked); } if (!Checked) diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs index ed467df4bb..0eb8b857e9 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.cs @@ -125,7 +125,7 @@ namespace BizHawk.Client.EmuHawk private void lvDiscs_SelectedIndexChanged(object sender, EventArgs e) { // emergency measure: if no selection, set no disc - _inputManager.StickyXorAdapter.SetAxis(_discSelectName, lvDiscs.SelectedIndices.Count == 0 ? 0 : lvDiscs.SelectedIndices[0]); + _inputManager.StickyXorAdapter.SetAxisHold(_discSelectName, lvDiscs.SelectedIndices.Count == 0 ? 0 : lvDiscs.SelectedIndices[0]); } private void btnClose_Click(object sender, EventArgs e) diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs index b6371d204e..fb2c756b0b 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs @@ -58,8 +58,8 @@ namespace BizHawk.Client.EmuHawk public void Clear() { - _stickyXorAdapter.SetAxis(XName, null); - _stickyXorAdapter.SetAxis(YName, null); + _stickyXorAdapter.SetAxisHold(XName, null); + _stickyXorAdapter.SetAxisHold(YName, null); _overrideX = null; _overrideY = null; _isSet = false; @@ -196,7 +196,7 @@ namespace BizHawk.Client.EmuHawk XNumeric.Value = XNumeric.Maximum; } - _stickyXorAdapter.SetAxis(XName, (XNumeric.Value.ConvertToF32() * MultiplierX).RoundToInt()); + _stickyXorAdapter.SetAxisHold(XName, (XNumeric.Value.ConvertToF32() * MultiplierX).RoundToInt()); _isSet = true; } } @@ -218,7 +218,7 @@ namespace BizHawk.Client.EmuHawk YNumeric.Value = YNumeric.Maximum; } - _stickyXorAdapter.SetAxis(YName, (YNumeric.Value.ConvertToF32() * MultiplierY).RoundToInt()); + _stickyXorAdapter.SetAxisHold(YName, (YNumeric.Value.ConvertToF32() * MultiplierY).RoundToInt()); _isSet = true; } } diff --git a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs index 84f26da6ac..3e4c9afffb 100644 --- a/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs +++ b/src/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs @@ -170,8 +170,8 @@ namespace BizHawk.Client.EmuHawk private void SetAnalog() { - _stickyXorAdapter.SetAxis(XName, HasValue ? X : null); - _stickyXorAdapter.SetAxis(YName, HasValue ? Y : null); + _stickyXorAdapter.SetAxisHold(XName, HasValue ? X : null); + _stickyXorAdapter.SetAxisHold(YName, HasValue ? Y : null); Refresh(); }