diff --git a/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs b/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs index c3478652ac..bb22db98a7 100644 --- a/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs @@ -39,7 +39,7 @@ namespace BizHawk.Client.Common return; } foreach (var button in controller.Definition.BoolButtons) Global.InputManager.ButtonOverrideAdapter.SetButton(button, controller.IsPressed(button)); - foreach (var floatButton in controller.Definition.AxisControls) Global.InputManager.ButtonOverrideAdapter.SetAxis(floatButton, controller.AxisValue(floatButton)); + foreach (var axis in controller.Definition.AxisControls) Global.InputManager.ButtonOverrideAdapter.SetAxis(axis, controller.AxisValue(axis)); } public void Set(Dictionary buttons, int? controller = null) @@ -76,7 +76,7 @@ namespace BizHawk.Client.Common { try { - Global.InputManager.StickyXorAdapter.SetAxis(controller == null ? control : $"P{controller} {control}", value); + Global.InputManager.StickyXorAdapter.SetAxis(controller == null ? control : $"P{controller} {control}", value == null ? (int?) null : (int) value.Value); // the time for changing the API will come --yoshi } catch { diff --git a/src/BizHawk.Client.Common/AutofireController.cs b/src/BizHawk.Client.Common/AutofireController.cs index 08ec65c5e9..60865ad75f 100644 --- a/src/BizHawk.Client.Common/AutofireController.cs +++ b/src/BizHawk.Client.Common/AutofireController.cs @@ -47,7 +47,7 @@ namespace BizHawk.Client.Common } /// always - public float AxisValue(string name) + public int AxisValue(string name) { throw new NotImplementedException(); } diff --git a/src/BizHawk.Client.Common/Controller.cs b/src/BizHawk.Client.Common/Controller.cs index 9b8d50a7e8..7e1f815f90 100644 --- a/src/BizHawk.Client.Common/Controller.cs +++ b/src/BizHawk.Client.Common/Controller.cs @@ -23,11 +23,11 @@ namespace BizHawk.Client.Common public bool IsPressed(string button) => _buttons[button]; - public float AxisValue(string name) => _axes[name]; + public int AxisValue(string name) => _axes[name]; private readonly WorkingDictionary> _bindings = new WorkingDictionary>(); private readonly WorkingDictionary _buttons = new WorkingDictionary(); - private readonly WorkingDictionary _axes = new WorkingDictionary(); + private readonly WorkingDictionary _axes = new WorkingDictionary(); private readonly Dictionary _axisRanges = new WorkingDictionary(); private readonly Dictionary _axisBindings = new Dictionary(); @@ -53,7 +53,7 @@ namespace BizHawk.Client.Common { foreach (var kvp in _axisBindings) { - var input = _axes[kvp.Key]; + var input = (float) _axes[kvp.Key]; string outKey = kvp.Key; float multiplier = kvp.Value.Mult; float deadZone = kvp.Value.Deadzone; @@ -91,7 +91,9 @@ namespace BizHawk.Client.Common // zero 09-mar-2015 - at this point, we should only have integers, since that's all 100% of consoles ever see // if this becomes a problem we can add flags to the range and update GUIs to be able to display floats - _axes[outKey] = output.ConstrainWithin(range.FloatRange); + // fixed maybe? --yoshi + + _axes[outKey] = (int) output.ConstrainWithin(range.FloatRange); } } } diff --git a/src/BizHawk.Client.Common/inputAdapters/AutoPattern.cs b/src/BizHawk.Client.Common/inputAdapters/AutoPattern.cs index 337504aa70..830ed2767f 100644 --- a/src/BizHawk.Client.Common/inputAdapters/AutoPattern.cs +++ b/src/BizHawk.Client.Common/inputAdapters/AutoPattern.cs @@ -68,26 +68,26 @@ } } - public class AutoPatternFloat + public class AutoPatternAxis { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// Defaults to 0. /// - public AutoPatternFloat() + public AutoPatternAxis() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// Simple on/off pattern, using the given values as on/off. /// - public AutoPatternFloat(float valueOn, int on, float valueOff, int off, bool skipLag = true, int offset = 0, int loop = 0) + public AutoPatternAxis(int valueOn, int on, int valueOff, int off, bool skipLag = true, int offset = 0, int loop = 0) { SkipsLag = skipLag; _index = offset; Loop = loop; - Pattern = new float[on + off]; + Pattern = new int[on + off]; for (int i = 0; i < on; i++) { Pattern[i] = valueOn; @@ -99,7 +99,7 @@ } } - public AutoPatternFloat(float[] pattern, bool skipLag = true, int offset = 0, int loop = 0) + public AutoPatternAxis(int[] pattern, bool skipLag = true, int offset = 0, int loop = 0) { SkipsLag = skipLag; Pattern = pattern; @@ -110,15 +110,15 @@ private int _index; public bool SkipsLag { get; } = true; - public float[] Pattern { get; } = { 0f }; + public int[] Pattern { get; } = { 0 }; public int Loop { get; } /// /// Gets the next value and increments index. /// - public float GetNextValue(bool isLag = false) + public int GetNextValue(bool isLag = false) { - float ret = Pattern[_index]; + int ret = Pattern[_index]; if (!isLag || !SkipsLag) { _index++; @@ -134,7 +134,7 @@ /// /// Gets the next value without incrementing index. /// - public float PeekNextValue() + public int PeekNextValue() { return Pattern[_index]; } diff --git a/src/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs b/src/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs index a87716ec5f..fac9b1f2c7 100644 --- a/src/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs +++ b/src/BizHawk.Client.Common/inputAdapters/BitwiseAdapters.cs @@ -18,7 +18,7 @@ namespace BizHawk.Client.Common // pass floats solely from the original source // this works in the code because SourceOr is the autofire controller - public float AxisValue(string name) => Source.AxisValue(name); + public int AxisValue(string name) => Source.AxisValue(name); internal IController Source { get; set; } internal IController SourceAnd { get; set; } @@ -40,7 +40,7 @@ namespace BizHawk.Client.Common // pass floats solely from the original source // this works in the code because SourceOr is the autofire controller - public float AxisValue(string name) => Source.AxisValue(name); + public int AxisValue(string name) => Source.AxisValue(name); internal IController Source { get; set; } internal IController SourceXor { get; set; } @@ -58,7 +58,7 @@ namespace BizHawk.Client.Common // pass floats solely from the original source // this works in the code because SourceOr is the autofire controller - public float AxisValue(string name) => Source.AxisValue(name); + public int AxisValue(string name) => Source.AxisValue(name); internal IController Source { get; set; } internal IController SourceOr { get; set; } diff --git a/src/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs b/src/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs index 7c0bcd0c3b..7eb943a5d6 100644 --- a/src/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs +++ b/src/BizHawk.Client.Common/inputAdapters/ClickyVirtualPadController.cs @@ -16,7 +16,7 @@ namespace BizHawk.Client.Common public bool IsPressed(string button) => _pressed.Contains(button); - public float AxisValue(string name) => 0.0f; + public int AxisValue(string name) => 0; /// /// Call this once per frame to do the timekeeping for the hold and release diff --git a/src/BizHawk.Client.Common/inputAdapters/CopyController.cs b/src/BizHawk.Client.Common/inputAdapters/CopyController.cs index 0885f692f5..c852a6cb18 100644 --- a/src/BizHawk.Client.Common/inputAdapters/CopyController.cs +++ b/src/BizHawk.Client.Common/inputAdapters/CopyController.cs @@ -11,7 +11,7 @@ namespace BizHawk.Client.Common public bool IsPressed(string button) => Curr.IsPressed(button); - public float AxisValue(string name) => Curr.AxisValue(name); + public int AxisValue(string name) => Curr.AxisValue(name); public IController Source { get; set; } diff --git a/src/BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs b/src/BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs index 1b66b91b74..2785a0ddc8 100644 --- a/src/BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs +++ b/src/BizHawk.Client.Common/inputAdapters/OverrideAdapter.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.Common public ControllerDefinition Definition { get; private set; } private readonly Dictionary _overrides = new Dictionary(); - private readonly Dictionary _axisOverrides = new Dictionary(); + private readonly Dictionary _axisOverrides = new Dictionary(); private readonly List _inverses = new List(); /// not overridden @@ -28,10 +28,10 @@ namespace BizHawk.Client.Common throw new InvalidOperationException(); } - public float AxisValue(string name) + public int AxisValue(string name) => _axisOverrides.ContainsKey(name) ? _axisOverrides[name] - : 0.0F; + : 0; public IEnumerable Overrides => _overrides.Select(kvp => kvp.Key); @@ -39,7 +39,7 @@ namespace BizHawk.Client.Common public IEnumerable InversedButtons => _inverses; - public void SetAxis(string name, float value) + public void SetAxis(string name, int value) { if (_axisOverrides.ContainsKey(name)) { diff --git a/src/BizHawk.Client.Common/inputAdapters/SimpleController.cs b/src/BizHawk.Client.Common/inputAdapters/SimpleController.cs index 70e403ca3b..e95fa5952d 100644 --- a/src/BizHawk.Client.Common/inputAdapters/SimpleController.cs +++ b/src/BizHawk.Client.Common/inputAdapters/SimpleController.cs @@ -13,12 +13,12 @@ namespace BizHawk.Client.Common public ControllerDefinition Definition { get; set; } protected WorkingDictionary Buttons { get; private set; } = new WorkingDictionary(); - protected WorkingDictionary Axes { get; private set; } = new WorkingDictionary(); + protected WorkingDictionary Axes { get; private set; } = new WorkingDictionary(); public void Clear() { Buttons = new WorkingDictionary(); - Axes = new WorkingDictionary(); + Axes = new WorkingDictionary(); } public bool this[string button] @@ -29,16 +29,16 @@ namespace BizHawk.Client.Common public virtual bool IsPressed(string button) => this[button]; - public float AxisValue(string name) => Axes[name]; + public int AxisValue(string name) => Axes[name]; public IDictionary BoolButtons() => Buttons; - public void AcceptNewAxis(string axisId, float value) + public void AcceptNewAxis(string axisId, int value) { Axes[axisId] = value; } - public void AcceptNewAxes(IEnumerable<(string AxisID, float Value)> newValues) + public void AcceptNewAxes(IEnumerable<(string AxisID, int Value)> newValues) { foreach (var (axisID, value) in newValues) { diff --git a/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs b/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs index 8df5667cae..26ee7c0d38 100644 --- a/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs +++ b/src/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs @@ -22,7 +22,7 @@ namespace BizHawk.Client.Common return source; } - public float AxisValue(string name) + public int AxisValue(string name) { var val = _axisSet[name]; @@ -45,9 +45,9 @@ namespace BizHawk.Client.Common // if SetAxis() is called (typically virtual pads), then that axis will entirely override the Source input // otherwise, the source is passed thru. - private readonly WorkingDictionary _axisSet = new WorkingDictionary(); + private readonly WorkingDictionary _axisSet = new WorkingDictionary(); - public void SetAxis(string name, float? value) + public void SetAxis(string name, int? value) { if (value.HasValue) { @@ -126,7 +126,7 @@ namespace BizHawk.Client.Common return source; } - public float AxisValue(string name) + public int AxisValue(string name) { if (_axisPatterns.ContainsKey(name)) { @@ -153,7 +153,7 @@ namespace BizHawk.Client.Common } private readonly WorkingDictionary _boolPatterns = new WorkingDictionary(); - private readonly WorkingDictionary _axisPatterns = new WorkingDictionary(); + private readonly WorkingDictionary _axisPatterns = new WorkingDictionary(); public AutoFireStickyXorAdapter() { @@ -163,11 +163,11 @@ namespace BizHawk.Client.Common public IController Source { get; set; } - public void SetAxis(string name, float? value, AutoPatternFloat pattern = null) + public void SetAxis(string name, int? value, AutoPatternAxis pattern = null) { if (value.HasValue) { - pattern ??= new AutoPatternFloat(value.Value, _on, 0, _off); + pattern ??= new AutoPatternAxis(value.Value, _on, 0, _off); _axisPatterns[name] = pattern; } else diff --git a/src/BizHawk.Client.Common/inputAdapters/UDLRController.cs b/src/BizHawk.Client.Common/inputAdapters/UDLRController.cs index 5d2ea6ea80..b73b56078a 100644 --- a/src/BizHawk.Client.Common/inputAdapters/UDLRController.cs +++ b/src/BizHawk.Client.Common/inputAdapters/UDLRController.cs @@ -144,7 +144,7 @@ namespace BizHawk.Client.Common } // The float format implies no U+D and no L+R no matter what, so just passthru - public float AxisValue(string name) + public int AxisValue(string name) { return Source.AxisValue(name); } diff --git a/src/BizHawk.Client.Common/movie/MultitrackRecording.cs b/src/BizHawk.Client.Common/movie/MultitrackRecording.cs index 01744c86aa..f832b30c98 100644 --- a/src/BizHawk.Client.Common/movie/MultitrackRecording.cs +++ b/src/BizHawk.Client.Common/movie/MultitrackRecording.cs @@ -97,9 +97,9 @@ namespace BizHawk.Client.Common return Source.IsPressed(RemapButtonName(button)); } - public float AxisValue(string button) + public int AxisValue(string name) { - return Source.AxisValue(RemapButtonName(button)); + return Source.AxisValue(RemapButtonName(name)); } private string RemapButtonName(string button) diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs index b4246da210..92a8acb5e1 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.Common internal class Bk2Controller : IMovieController { private readonly WorkingDictionary _myBoolButtons = new WorkingDictionary(); - private readonly WorkingDictionary _myAxisControls = new WorkingDictionary(); + private readonly WorkingDictionary _myAxisControls = new WorkingDictionary(); private readonly Bk2ControllerDefinition _type; private readonly List _controlsOrdered; @@ -44,7 +44,7 @@ namespace BizHawk.Client.Common public ControllerDefinition Definition => _type; public bool IsPressed(string button) => _myBoolButtons[button]; - public float AxisValue(string name) => _myAxisControls[name]; + public int AxisValue(string name) => _myAxisControls[name]; public void SetFrom(IController source) { @@ -135,7 +135,7 @@ namespace BizHawk.Client.Common _myBoolButtons[buttonName] = value; } - public void SetAxis(string buttonName, float value) + public void SetAxis(string buttonName, int value) { _myAxisControls[buttonName] = value; } diff --git a/src/BizHawk.Client.Common/movie/import/DsmImport.cs b/src/BizHawk.Client.Common/movie/import/DsmImport.cs index 89895041f4..ccc88e8e83 100644 --- a/src/BizHawk.Client.Common/movie/import/DsmImport.cs +++ b/src/BizHawk.Client.Common/movie/import/DsmImport.cs @@ -120,8 +120,8 @@ namespace BizHawk.Client.Common controller.AcceptNewAxes(new[] { - ("TouchX", (float) touchX), - ("TouchY", (float) touchY) + ("TouchX", touchX), + ("TouchY", touchY) }); } diff --git a/src/BizHawk.Client.Common/movie/import/PjmImport.cs b/src/BizHawk.Client.Common/movie/import/PjmImport.cs index 8f8ebce986..e0ccc1fd51 100644 --- a/src/BizHawk.Client.Common/movie/import/PjmImport.cs +++ b/src/BizHawk.Client.Common/movie/import/PjmImport.cs @@ -212,10 +212,10 @@ namespace BizHawk.Client.Common { controllers["P1 L3"] = (controllerState & 0x2) != 0; controllers["P1 R3"] = (controllerState & 0x4) != 0; - var leftX = ("P1 LStick X", (float) br.ReadByte()); - var leftY = ("P1 LStick Y", (float) br.ReadByte()); - var rightX = ("P1 RStick X", (float) br.ReadByte()); - var rightY = ("P1 RStick Y", (float) br.ReadByte()); + var leftX = ("P1 LStick X", (int) br.ReadByte()); + var leftY = ("P1 LStick Y", (int) br.ReadByte()); + var rightX = ("P1 RStick X", (int) br.ReadByte()); + var rightY = ("P1 RStick Y", (int) br.ReadByte()); controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY }); } @@ -235,10 +235,10 @@ namespace BizHawk.Client.Common if (info.Player2Type == OctoshockDll.ePeripheralType.DualShock) { - var leftX = ("P2 LStick X", (float) br.ReadByte()); - var leftY = ("P2 LStick Y", (float) br.ReadByte()); - var rightX = ("P2 RStick X", (float) br.ReadByte()); - var rightY = ("P2 RStick Y", (float) br.ReadByte()); + var leftX = ("P2 LStick X", (int) br.ReadByte()); + var leftY = ("P2 LStick Y", (int) br.ReadByte()); + var rightX = ("P2 RStick X", (int) br.ReadByte()); + var rightY = ("P2 RStick Y", (int) br.ReadByte()); controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY }); } @@ -266,7 +266,7 @@ namespace BizHawk.Client.Common controllers["Open"] = false; } - var discSelect = ("Disc Select", (float) cdNumber); + var discSelect = ("Disc Select", cdNumber); controllers.AcceptNewAxes(new[] { discSelect }); if ((controlState & 0xFC) != 0) @@ -350,10 +350,10 @@ namespace BizHawk.Client.Common string rightXRaw = player1Str.Substring(24, 4); string rightYRaw = player1Str.Substring(28, 4); - var leftX = ("P1 LStick X", float.Parse(leftXRaw)); - var leftY = ("P1 LStick Y", float.Parse(leftYRaw)); - var rightX = ("P1 RStick X", float.Parse(rightXRaw)); - var rightY = ("P1 RStick Y", float.Parse(rightYRaw)); + var leftX = ("P1 LStick X", (int) float.Parse(leftXRaw)); + var leftY = ("P1 LStick Y", (int) float.Parse(leftYRaw)); + var rightX = ("P1 RStick X", (int) float.Parse(rightXRaw)); + var rightY = ("P1 RStick Y", (int) float.Parse(rightYRaw)); controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY }); } @@ -385,10 +385,10 @@ namespace BizHawk.Client.Common string rightXRaw = player2Str.Substring(24, 4); string rightYRaw = player2Str.Substring(28, 4); - var leftX = ("P2 LStick X", float.Parse(leftXRaw)); - var leftY = ("P2 LStick Y", float.Parse(leftYRaw)); - var rightX = ("P2 RStick X", float.Parse(rightXRaw)); - var rightY = ("P2 RStick Y", float.Parse(rightYRaw)); + var leftX = ("P2 LStick X", (int) float.Parse(leftXRaw)); + var leftY = ("P2 LStick Y", (int) float.Parse(leftYRaw)); + var rightX = ("P2 RStick X", (int) float.Parse(rightXRaw)); + var rightY = ("P2 RStick Y", (int) float.Parse(rightYRaw)); controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY }); } @@ -416,7 +416,7 @@ namespace BizHawk.Client.Common controllers["Open"] = false; } - var discSelect = ("Disc Select", (float) cdNumber); + var discSelect = ("Disc Select", cdNumber); controllers.AcceptNewAxes(new[] { discSelect }); if ((controlState & 0xFC) != 0) diff --git a/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs b/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs index 3b33b03c9c..17a2d5b212 100644 --- a/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs +++ b/src/BizHawk.Client.Common/movie/import/bkm/BkmControllerAdapter.cs @@ -12,9 +12,9 @@ namespace BizHawk.Client.Common return _myBoolButtons[button]; } - public float AxisValue(string name) + public int AxisValue(string name) { - return _myFloatControls[name]; + return _myAxisControls[name]; } /// @@ -188,7 +188,7 @@ namespace BizHawk.Client.Common } private readonly WorkingDictionary _myBoolButtons = new WorkingDictionary(); - private readonly WorkingDictionary _myFloatControls = new WorkingDictionary(); + private readonly WorkingDictionary _myAxisControls = new WorkingDictionary(); private bool IsGenesis6Button() => Definition.BoolButtons.Contains("P1 X"); @@ -197,9 +197,9 @@ namespace BizHawk.Client.Common _myBoolButtons[button] = state; } - private void Force(string name, float state) + private void Force(string name, int state) { - _myFloatControls[name] = state; + _myAxisControls[name] = state; } private string ControlType => Definition.Name; diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs index db789e40ea..4f0af1bbce 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovie.cs @@ -295,7 +295,7 @@ namespace BizHawk.Client.Common public static bool BoolIsPressed(this IMovie movie, int frame, string buttonName) => movie.GetInputState(frame).IsPressed(buttonName); - public static float GetFloatState(this IMovie movie, int frame, string buttonName) + public static int GetAxisState(this IMovie movie, int frame, string buttonName) => movie.GetInputState(frame).AxisValue(buttonName); } } diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs index 8b0ab97f92..d6c2a27837 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs @@ -33,6 +33,6 @@ namespace BizHawk.Client.Common /// /// Sets the given axis button to the given value /// - void SetAxis(string buttonName, float value); + void SetAxis(string buttonName, int value); } } diff --git a/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs b/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs index 6529defbc4..757abb1a77 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/ITasMovie.cs @@ -30,8 +30,8 @@ namespace BizHawk.Client.Common void GreenzoneCurrentFrame(); void ToggleBoolState(int frame, string buttonName); - void SetFloatState(int frame, string buttonName, float val); - void SetFloatStates(int frame, int count, string buttonName, float val); + void SetAxisState(int frame, string buttonName, int val); + void SetAxisStates(int frame, int count, string buttonName, int val); void SetBoolState(int frame, string buttonName, bool val); void SetBoolStates(int frame, int count, string buttonName, bool val); void InsertInput(int frame, string inputState); diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs index 1ce5a1a28d..4b5c3ec471 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs @@ -366,7 +366,7 @@ namespace BizHawk.Client.Common ChangeLog.SetGeneralRedo(); } - public void SetFloatState(int frame, string buttonName, float val) + public void SetAxisState(int frame, string buttonName, int val) { if (frame >= Log.Count) // Insert blank frames up to this point { @@ -384,11 +384,11 @@ namespace BizHawk.Client.Common { InvalidateAfter(frame); Changes = true; - ChangeLog.AddFloatChange(frame, buttonName, old, val, $"Set {buttonName}({val}): {frame}"); + ChangeLog.AddAxisChange(frame, buttonName, old, val, $"Set {buttonName}({val}): {frame}"); } } - public void SetFloatStates(int frame, int count, string buttonName, float val) + public void SetAxisStates(int frame, int count, string buttonName, int val) { if (frame + count >= Log.Count) // Insert blank frames up to this point { @@ -401,7 +401,7 @@ namespace BizHawk.Client.Common for (int i = 0; i < count; i++) { var adapter = GetInputState(frame + i); - float old = adapter.AxisValue(buttonName); + var old = adapter.AxisValue(buttonName); adapter.SetAxis(buttonName, val); var lg = LogGeneratorInstance(adapter); diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs index 994e831d5a..ccd08904dc 100644 --- a/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/src/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.Common void AddGeneralUndo(int first, int last, string name = "", bool force = false); void SetGeneralRedo(bool force = false); void AddBoolToggle(int frame, string button, bool oldState, string name = "", bool force = false); - void AddFloatChange(int frame, string button, float oldState, float newState, string name = "", bool force = false); + void AddAxisChange(int frame, string button, int oldState, int newState, string name = "", bool force = false); void AddMarkerChange(TasMovieMarker newMarker, int oldPosition = -1, string oldMessage = "", string name = "", bool force = false); void AddInputBind(int frame, bool isDelete, string name = "", bool force = false); void AddInsertFrames(int frame, int count, string name = "", bool force = false); @@ -350,7 +350,7 @@ namespace BizHawk.Client.Common } } - public void AddFloatChange(int frame, string button, float oldState, float newState, string name = "", bool force = false) + public void AddAxisChange(int frame, string button, int oldState, int newState, string name = "", bool force = false) { if (IsRecording || force) { @@ -582,11 +582,11 @@ namespace BizHawk.Client.Common public int FirstFrame { get; } public int LastFrame => FirstFrame; - private readonly float _oldState; - private readonly float _newState; + private readonly int _oldState; + private readonly int _newState; private readonly string _buttonName; - private readonly bool _isFloat; + private readonly bool _isAxis; public MovieActionFrameEdit(int frame, string button, bool oldS, bool newS) { @@ -596,13 +596,13 @@ namespace BizHawk.Client.Common _buttonName = button; } - public MovieActionFrameEdit(int frame, string button, float oldS, float newS) + public MovieActionFrameEdit(int frame, string button, int oldS, int newS) { _oldState = oldS; _newState = newS; FirstFrame = frame; _buttonName = button; - _isFloat = true; + _isAxis = true; } public void Undo(ITasMovie movie) @@ -610,9 +610,9 @@ namespace BizHawk.Client.Common bool wasRecording = movie.ChangeLog.IsRecording; movie.ChangeLog.IsRecording = false; - if (_isFloat) + if (_isAxis) { - movie.SetFloatState(FirstFrame, _buttonName, _oldState); + movie.SetAxisState(FirstFrame, _buttonName, _oldState); } else { @@ -627,9 +627,9 @@ namespace BizHawk.Client.Common bool wasRecording = movie.ChangeLog.IsRecording; movie.ChangeLog.IsRecording = false; - if (_isFloat) + if (_isAxis) { - movie.SetFloatState(FirstFrame, _buttonName, _newState); + movie.SetAxisState(FirstFrame, _buttonName, _newState); } else { @@ -644,10 +644,10 @@ namespace BizHawk.Client.Common { public int FirstFrame { get; } public int LastFrame { get; } - private readonly List _oldState; - private readonly float _newState; + private readonly List _oldState; + private readonly int _newState; private readonly string _buttonName; - private readonly bool _isFloat = false; + private readonly bool _isAxis = false; public MovieActionPaint(int startFrame, int endFrame, string button, bool newS, ITasMovie movie) { @@ -655,7 +655,7 @@ namespace BizHawk.Client.Common FirstFrame = startFrame; LastFrame = endFrame; _buttonName = button; - _oldState = new List(endFrame - startFrame + 1); + _oldState = new List(endFrame - startFrame + 1); for (int i = 0; i < endFrame - startFrame + 1; i++) { @@ -663,14 +663,14 @@ namespace BizHawk.Client.Common } } - public MovieActionPaint(int startFrame, int endFrame, string button, float newS, ITasMovie movie) + public MovieActionPaint(int startFrame, int endFrame, string button, int newS, ITasMovie movie) { _newState = newS; FirstFrame = startFrame; LastFrame = endFrame; _buttonName = button; - _isFloat = true; - _oldState = new List(endFrame - startFrame + 1); + _isAxis = true; + _oldState = new List(endFrame - startFrame + 1); for (int i = 0; i < endFrame - startFrame + 1; i++) { @@ -683,11 +683,11 @@ namespace BizHawk.Client.Common bool wasRecording = movie.ChangeLog.IsRecording; movie.ChangeLog.IsRecording = false; - if (_isFloat) + if (_isAxis) { for (int i = 0; i < _oldState.Count; i++) { - movie.SetFloatState(FirstFrame + i, _buttonName, _oldState[i]); + movie.SetAxisState(FirstFrame + i, _buttonName, _oldState[i]); } } else @@ -706,9 +706,9 @@ namespace BizHawk.Client.Common bool wasRecording = movie.ChangeLog.IsRecording; movie.ChangeLog.IsRecording = false; - if (_isFloat) + if (_isAxis) { - movie.SetFloatStates(FirstFrame, LastFrame - FirstFrame + 1, _buttonName, _newState); + movie.SetAxisStates(FirstFrame, LastFrame - FirstFrame + 1, _buttonName, _newState); } else { diff --git a/src/BizHawk.Client.EmuHawk/Input/HostInputAdapters.cs b/src/BizHawk.Client.EmuHawk/Input/HostInputAdapters.cs index 13f80510b6..1deb46b213 100644 --- a/src/BizHawk.Client.EmuHawk/Input/HostInputAdapters.cs +++ b/src/BizHawk.Client.EmuHawk/Input/HostInputAdapters.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk void PreprocessHostGamepads(); - void ProcessHostGamepads(Action handleButton, Action handleAxis); + void ProcessHostGamepads(Action handleButton, Action handleAxis); IEnumerable ProcessHostKeyboards(); } @@ -51,19 +51,19 @@ namespace BizHawk.Client.EmuHawk GamePad360.UpdateAll(); } - public void ProcessHostGamepads(Action handleButton, Action handleAxis) + public void ProcessHostGamepads(Action handleButton, Action handleAxis) { foreach (var pad in GamePad360.EnumerateDevices()) { var inputNamePrefix = $"X{pad.PlayerNumber} "; for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(inputNamePrefix + pad.ButtonName(b), pad.Pressed(b), InputFocus.Pad); - foreach (var (axisName, f) in pad.GetAxes()) handleAxis(inputNamePrefix + axisName, f); + foreach (var (axisName, f) in pad.GetAxes()) handleAxis(inputNamePrefix + axisName, (int) f); } foreach (var pad in GamePad.EnumerateDevices()) { var inputNamePrefix = $"J{pad.PlayerNumber} "; for (int b = 0, n = pad.NumButtons; b < n; b++) handleButton(inputNamePrefix + pad.ButtonName(b), pad.Pressed(b), InputFocus.Pad); - foreach (var (axisName, f) in pad.GetAxes()) handleAxis(inputNamePrefix + axisName, f); + foreach (var (axisName, f) in pad.GetAxes()) handleAxis(inputNamePrefix + axisName, (int) f); } } @@ -84,12 +84,12 @@ namespace BizHawk.Client.EmuHawk public void PreprocessHostGamepads() => OTK_GamePad.UpdateAll(); - public void ProcessHostGamepads(Action handleButton, Action handleAxis) + public void ProcessHostGamepads(Action handleButton, Action handleAxis) { foreach (var pad in OTK_GamePad.EnumerateDevices()) { foreach (var but in pad.buttonObjects) handleButton(pad.InputNamePrefix + but.ButtonName, but.ButtonAction(), InputFocus.Pad); - foreach (var (axisID, f) in pad.GetAxes()) handleAxis($"{pad.InputNamePrefix}{axisID} Axis", f); + foreach (var (axisID, f) in pad.GetAxes()) handleAxis($"{pad.InputNamePrefix}{axisID} Axis", (int) f); } } diff --git a/src/BizHawk.Client.EmuHawk/Input/Input.cs b/src/BizHawk.Client.EmuHawk/Input/Input.cs index 9dc4275333..b9a9c9f43a 100644 --- a/src/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/src/BizHawk.Client.EmuHawk/Input/Input.cs @@ -200,7 +200,7 @@ namespace BizHawk.Client.EmuHawk private readonly Dictionary _modifierState = new Dictionary(); private readonly WorkingDictionary _lastState = new WorkingDictionary(); - private readonly WorkingDictionary _axisValues = new WorkingDictionary(); + private readonly WorkingDictionary _axisValues = new WorkingDictionary(); private readonly WorkingDictionary _axisDeltas = new WorkingDictionary(); private bool _trackDeltas; private bool _ignoreEventsNextPoll; @@ -269,7 +269,7 @@ namespace BizHawk.Client.EmuHawk } } - private void HandleAxis(string axis, float newValue) + private void HandleAxis(string axis, int newValue) { if (_trackDeltas) _axisDeltas[axis] += Math.Abs(newValue - _axisValues[axis]); _axisValues[axis] = newValue; @@ -322,7 +322,7 @@ namespace BizHawk.Client.EmuHawk } } - public IDictionary GetAxisValues() + public IDictionary GetAxisValues() { lock (_axisValues) { diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index cbd237ccaf..e759a12ad4 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -943,7 +943,7 @@ namespace BizHawk.Client.EmuHawk //also handle floats //we'll need to isolate the mouse coordinates so we can translate them - KeyValuePair? mouseX = null, mouseY = null; + KeyValuePair? mouseX = null, mouseY = null; foreach (var f in Input.Instance.GetAxisValues()) { if (f.Key == "WMouse X") @@ -960,8 +960,8 @@ namespace BizHawk.Client.EmuHawk var p = DisplayManager.UntransformPoint(new Point((int) mouseX.Value.Value, (int) mouseY.Value.Value)); float x = p.X / (float)_currentVideoProvider.BufferWidth; float y = p.Y / (float)_currentVideoProvider.BufferHeight; - conInput.AcceptNewAxis("WMouse X", (x * 20000) - 10000); - conInput.AcceptNewAxis("WMouse Y", (y * 20000) - 10000); + conInput.AcceptNewAxis("WMouse X", (int) ((x * 20000) - 10000)); + conInput.AcceptNewAxis("WMouse Y", (int) ((y * 20000) - 10000)); } } diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index 628fe6ce31..2ee2d3f2b9 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -34,7 +34,7 @@ namespace BizHawk.Client.EmuHawk public int Number; public string Button; public bool ValueBool; - public float ValueFloat; + public int ValueAxis; } public enum LuaChangeTypes @@ -212,13 +212,13 @@ namespace BizHawk.Client.EmuHawk if (frame < Tastudio.CurrentTasMovie.InputLogLength) { - if (Tastudio.CurrentTasMovie.GetFloatState(frame, button) != value) // Check if the button state is not already in the state the user set in the lua script + if (Tastudio.CurrentTasMovie.GetAxisState(frame, button) != (int) value) // Check if the button state is not already in the state the user set in the lua script { newChange.Type = LuaChangeTypes.InputChange; newChange.InputType = InputChangeTypes.Float; newChange.Frame = frame; newChange.Button = button; - newChange.ValueFloat = value; + newChange.ValueAxis = (int) value; _changeList.Add(newChange); } @@ -229,7 +229,7 @@ namespace BizHawk.Client.EmuHawk newChange.InputType = InputChangeTypes.Float; newChange.Frame = frame; newChange.Button = button; - newChange.ValueFloat = value; + newChange.ValueAxis = (int) value; _changeList.Add(newChange); } @@ -288,7 +288,7 @@ namespace BizHawk.Client.EmuHawk Tastudio.CurrentTasMovie.SetBoolState(_changeList[i].Frame, _changeList[i].Button, _changeList[i].ValueBool); break; case InputChangeTypes.Float: - Tastudio.CurrentTasMovie.SetFloatState(_changeList[i].Frame, _changeList[i].Button, _changeList[i].ValueFloat); + Tastudio.CurrentTasMovie.SetAxisState(_changeList[i].Frame, _changeList[i].Button, _changeList[i].ValueAxis); break; } break; diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs index bb3ab5216b..1a51b1620b 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs @@ -297,7 +297,7 @@ namespace BizHawk.Client.EmuHawk foreach (string name in latching.Definition.AxisControls) { - float sFloat = source.AxisValue(name); + var sFloat = source.AxisValue(name); int indexRange = source.Definition.AxisControls.IndexOf(name); if (sFloat == source.Definition.AxisRanges[indexRange].Mid) { diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs index 30f817f013..51abf10d22 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs @@ -199,14 +199,14 @@ namespace BizHawk.Client.EmuHawk { if (SelectedButton == "Default float Auto-Fire") { - index = _tastudio.FloatPatterns.Length - 1; + index = _tastudio.AxisPatterns.Length - 1; } else { index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton); } - LagBox.Checked = _tastudio.FloatPatterns[index].SkipsLag; + LagBox.Checked = _tastudio.AxisPatterns[index].SkipsLag; ValueNum.Value = Convert.ToDecimal(_values[PatternList.SelectedIndex]); CountNum.Value = _counts[PatternList.SelectedIndex]; } @@ -245,23 +245,23 @@ namespace BizHawk.Client.EmuHawk { if (SelectedButton == "Default float Auto-Fire") { - index = _tastudio.FloatPatterns.Length - 1; + index = _tastudio.AxisPatterns.Length - 1; } else { index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton); } - List p = new List(); + var p = new List(); for (int i = 0; i < _counts.Count; i++) { for (int c = 0; c < _counts[i]; c++) { - p.Add(Convert.ToSingle(_values[i])); + p.Add((int) Convert.ToSingle(_values[i])); } } - _tastudio.FloatPatterns[index] = new AutoPatternFloat(p.ToArray(), LagBox.Checked, 0, _loopAt); + _tastudio.AxisPatterns[index] = new AutoPatternAxis(p.ToArray(), LagBox.Checked, 0, _loopAt); } if ((SelectedButton != "Default float Auto-Fire") && (SelectedButton != "Default bool Auto-Fire")) @@ -307,15 +307,15 @@ namespace BizHawk.Client.EmuHawk { if (SelectedButton == "Default float Auto-Fire") { - index = _tastudio.FloatPatterns.Length - 1; + index = _tastudio.AxisPatterns.Length - 1; } else { index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton); } - float[] p = _tastudio.FloatPatterns[index].Pattern; - float lastValue = p[0]; + var p = _tastudio.AxisPatterns[index].Pattern; + var lastValue = p[0]; _counts.Clear(); _values.Clear(); _counts.Add(1); @@ -334,7 +334,7 @@ namespace BizHawk.Client.EmuHawk } } - _loopAt = _tastudio.FloatPatterns[index].Loop; + _loopAt = _tastudio.AxisPatterns[index].Loop; } } } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 56e1477943..9821ad3219 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -17,8 +17,8 @@ namespace BizHawk.Client.EmuHawk private string _startBoolDrawColumn = ""; private string _startFloatDrawColumn = ""; private bool _boolPaintState; - private float _axisPaintState; - private float _axisBackupState; + private int _axisPaintState; + private int _axisBackupState; private bool _patternPaint; private bool _startCursorDrag; private bool _startSelectionDrag; @@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk public bool WasRecording { get; set; } public AutoPatternBool[] BoolPatterns; - public AutoPatternFloat[] FloatPatterns; + public AutoPatternAxis[] AxisPatterns; public void JumpToGreenzone() { @@ -473,13 +473,13 @@ namespace BizHawk.Client.EmuHawk index += ControllerType.AxisControls.Count - 1; } - float? value = null; + int? value = null; if (isOn.Value) { - value = 0f; + value = 0; } - AutoPatternFloat p = FloatPatterns[index]; + AutoPatternAxis p = AxisPatterns[index]; Global.InputManager.AutofireStickyXorAdapter.SetAxis(button, value, p); } } @@ -569,7 +569,7 @@ namespace BizHawk.Client.EmuHawk } _axisEditYPos = e.Y; - _axisPaintState = CurrentTasMovie.GetFloatState(frame, buttonName); + _axisPaintState = CurrentTasMovie.GetAxisState(frame, buttonName); _triggerAutoRestore = true; JumpToGreenzone(); @@ -659,18 +659,18 @@ namespace BizHawk.Client.EmuHawk { if (frame >= CurrentTasMovie.InputLogLength) { - CurrentTasMovie.SetFloatState(frame, buttonName, 0); + CurrentTasMovie.SetAxisState(frame, buttonName, 0); RefreshDialog(); } JumpToGreenzone(); - _axisPaintState = CurrentTasMovie.GetFloatState(frame, buttonName); + _axisPaintState = CurrentTasMovie.GetAxisState(frame, buttonName); if (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked || TasView.CurrentCell.Column.Emphasis)) { - FloatPatterns[ControllerType.AxisControls.IndexOf(buttonName)].Reset(); - CurrentTasMovie.SetFloatState(frame, buttonName, FloatPatterns[ControllerType.AxisControls.IndexOf(buttonName)].GetNextValue()); + AxisPatterns[ControllerType.AxisControls.IndexOf(buttonName)].Reset(); + CurrentTasMovie.SetAxisState(frame, buttonName, AxisPatterns[ControllerType.AxisControls.IndexOf(buttonName)].GetNextValue()); _patternPaint = true; } else @@ -697,7 +697,7 @@ namespace BizHawk.Client.EmuHawk AxisEditRow = frame; _axisTypedValue = ""; _axisEditYPos = e.Y; - _axisBackupState = CurrentTasMovie.GetFloatState(_axisEditRow, _axisEditColumn); + _axisBackupState = CurrentTasMovie.GetAxisState(_axisEditRow, _axisEditColumn); } RefreshDialog(); @@ -783,7 +783,7 @@ namespace BizHawk.Client.EmuHawk TasView.ReleaseCurrentCell(); // Exit axis editing if value was changed with cursor - if (AxisEditingMode && _axisPaintState != CurrentTasMovie.GetFloatState(_axisEditRow, _axisEditColumn)) + if (AxisEditingMode && _axisPaintState != CurrentTasMovie.GetAxisState(_axisEditRow, _axisEditColumn)) { AxisEditRow = -1; _triggerAutoRestore = true; @@ -1143,20 +1143,20 @@ namespace BizHawk.Client.EmuHawk for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down) { - float setVal = _axisPaintState; + var setVal = _axisPaintState; if (_patternPaint) { if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value) { - setVal = CurrentTasMovie.GetFloatState(i - 1, _startFloatDrawColumn); + setVal = CurrentTasMovie.GetAxisState(i - 1, _startFloatDrawColumn); } else { - setVal = FloatPatterns[ControllerType.AxisControls.IndexOf(_startFloatDrawColumn)].GetNextValue(); + setVal = AxisPatterns[ControllerType.AxisControls.IndexOf(_startFloatDrawColumn)].GetNextValue(); } } - CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column + CurrentTasMovie.SetAxisState(i, _startFloatDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column JumpToGreenzone(); } } @@ -1182,8 +1182,8 @@ namespace BizHawk.Client.EmuHawk return; } - var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.AxisRanges[ControllerType.AxisControls.IndexOf(_axisEditColumn)].FloatRange); - CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, value); + var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.AxisRanges[ControllerType.AxisControls.IndexOf(_axisEditColumn)].Range); + CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, value); _axisTypedValue = value.ToString(); JumpToGreenzone(); @@ -1251,7 +1251,7 @@ namespace BizHawk.Client.EmuHawk return; } - float value = CurrentTasMovie.GetFloatState(_axisEditRow, _axisEditColumn); + float value = CurrentTasMovie.GetAxisState(_axisEditRow, _axisEditColumn); float prev = value; string prevTyped = _axisTypedValue; @@ -1336,7 +1336,7 @@ namespace BizHawk.Client.EmuHawk if (_axisBackupState != _axisPaintState) { - CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, _axisBackupState); + CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, _axisBackupState); _triggerAutoRestore = Emulator.Frame > _axisEditRow; JumpToGreenzone(); DoTriggeredAutoRestoreIfNeeded(); @@ -1379,7 +1379,7 @@ namespace BizHawk.Client.EmuHawk if (prevTyped != "") { value = 0f; - CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, value); + CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, (int) value); } } else @@ -1396,7 +1396,7 @@ namespace BizHawk.Client.EmuHawk } _axisTypedValue = value.ToString(); - CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, value); + CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, (int) value); } } @@ -1404,7 +1404,7 @@ namespace BizHawk.Client.EmuHawk { foreach (int row in _extraAxisRows) { - CurrentTasMovie.SetFloatState(row, _axisEditColumn, value); + CurrentTasMovie.SetAxisState(row, _axisEditColumn, (int) value); } } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 8ed43483e8..024be66eb7 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -489,14 +489,14 @@ namespace BizHawk.Client.EmuHawk if (BoolPatterns == null) { BoolPatterns = new AutoPatternBool[ControllerType.BoolButtons.Count + 2]; - FloatPatterns = new AutoPatternFloat[ControllerType.AxisControls.Count + 2]; + AxisPatterns = new AutoPatternAxis[ControllerType.AxisControls.Count + 2]; } else { bStart = BoolPatterns.Length - 2; - fStart = FloatPatterns.Length - 2; + fStart = AxisPatterns.Length - 2; Array.Resize(ref BoolPatterns, ControllerType.BoolButtons.Count + 2); - Array.Resize(ref FloatPatterns, ControllerType.AxisControls.Count + 2); + Array.Resize(ref AxisPatterns, ControllerType.AxisControls.Count + 2); } for (int i = bStart; i < BoolPatterns.Length - 2; i++) @@ -508,14 +508,13 @@ namespace BizHawk.Client.EmuHawk BoolPatterns[BoolPatterns.Length - 1] = new AutoPatternBool( Config.AutofireOn, Config.AutofireOff); - for (int i = fStart; i < FloatPatterns.Length - 2; i++) + for (int i = fStart; i < AxisPatterns.Length - 2; i++) { - FloatPatterns[i] = new AutoPatternFloat(new[] { 1f }); + AxisPatterns[i] = new AutoPatternAxis(new[] { 1 }); } - FloatPatterns[FloatPatterns.Length - 2] = new AutoPatternFloat(new[] { 1f }); - FloatPatterns[FloatPatterns.Length - 1] = new AutoPatternFloat( - 1f, Config.AutofireOn, 0f, Config.AutofireOff); + AxisPatterns[AxisPatterns.Length - 2] = new AutoPatternAxis(new[] { 1 }); + AxisPatterns[AxisPatterns.Length - 1] = new AutoPatternAxis(1, Config.AutofireOn, 0, Config.AutofireOff); SetUpToolStripColumns(); } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index 221b635ea3..ab8770ba5c 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Common /// public Dictionary CategoryLabels { get; } = new Dictionary(); - public void ApplyAxisConstraints(string constraintClass, IDictionary floatButtons) + public void ApplyAxisConstraints(string constraintClass, IDictionary axes) { if (AxisConstraints == null) { @@ -82,10 +82,10 @@ namespace BizHawk.Emulation.Common string xAxis = constraint.Params[0] as string ?? ""; string yAxis = constraint.Params[1] as string ?? ""; float range = (float)constraint.Params[2]; - if (!floatButtons.ContainsKey(xAxis)) break; - if (!floatButtons.ContainsKey(yAxis)) break; - double xVal = floatButtons[xAxis]; - double yVal = floatButtons[yAxis]; + if (!axes.ContainsKey(xAxis)) break; + if (!axes.ContainsKey(yAxis)) break; + double xVal = axes[xAxis]; + double yVal = axes[yAxis]; double length = Math.Sqrt((xVal * xVal) + (yVal * yVal)); if (length > range) { @@ -94,8 +94,8 @@ namespace BizHawk.Emulation.Common yVal *= ratio; } - floatButtons[xAxis] = (float)xVal; - floatButtons[yAxis] = (float)yVal; + axes[xAxis] = (int) xVal; + axes[yAxis] = (int) yVal; break; } } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs b/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs index ef20d3ceb7..1a7da7150c 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/NullController.cs @@ -14,7 +14,7 @@ public bool IsPressed(string button) => false; - public float AxisValue(string name) => 0f; + public int AxisValue(string name) => 0; public static readonly NullController Instance = new NullController(); } diff --git a/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs b/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs index 6bb075ec22..7522442d98 100644 --- a/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs +++ b/src/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs @@ -84,7 +84,7 @@ namespace BizHawk.Emulation.Common return _src.IsPressed(_remaps[button]); } - public float AxisValue(string name) + public int AxisValue(string name) { return _src.AxisValue(_remaps[name]); } diff --git a/src/BizHawk.Emulation.Common/Interfaces/IController.cs b/src/BizHawk.Emulation.Common/Interfaces/IController.cs index 113822ecb3..5f2977af37 100644 --- a/src/BizHawk.Emulation.Common/Interfaces/IController.cs +++ b/src/BizHawk.Emulation.Common/Interfaces/IController.cs @@ -13,8 +13,8 @@ bool IsPressed(string button); /// - /// Returns the state of a float control + /// Returns the state of an axis control /// - float AxisValue(string name); + int AxisValue(string name); } } diff --git a/src/BizHawk.Emulation.Common/SaveController.cs b/src/BizHawk.Emulation.Common/SaveController.cs index 2affa09d09..27a8ce5e00 100644 --- a/src/BizHawk.Emulation.Common/SaveController.cs +++ b/src/BizHawk.Emulation.Common/SaveController.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Common /// public class SaveController : IController { - private readonly WorkingDictionary _buttons = new WorkingDictionary(); + private readonly WorkingDictionary _buttons = new WorkingDictionary(); public SaveController() { @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Common { string k = b.ReadString(); float v = b.ReadSingle(); - _buttons.Add(k, v); + _buttons.Add(k, (int) v); } } @@ -62,7 +62,7 @@ namespace BizHawk.Emulation.Common _buttons.Clear(); foreach (var k in Definition.BoolButtons) { - _buttons.Add(k, source.IsPressed(k) ? 1.0f : 0); + _buttons.Add(k, source.IsPressed(k) ? 1 : 0); } foreach (var k in Definition.AxisControls) @@ -83,7 +83,7 @@ namespace BizHawk.Emulation.Common public void Set(string button) { - _buttons[button] = 1.0f; + _buttons[button] = 1; } public bool IsPressed(string button) @@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Common return _buttons[button] != 0; } - public float AxisValue(string name) + public int AxisValue(string name) { return _buttons[name]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs index cf94af71b1..438b88e167 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.Vectrex { @@ -43,10 +42,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex if (ControllerDefinition.Name == "Vectrex Analog Controller") { // joystick position is based on pot reading - joy1_LR = (byte)(255 - (Math.Floor(controller.AxisValue("P1 Stick X")) + 128)); - joy1_UD = (byte)(Math.Floor(controller.AxisValue("P1 Stick Y")) + 128); - joy2_LR = (byte)(255 - (Math.Floor(controller.AxisValue("P2 Stick X")) + 128)); - joy2_UD = (byte)(Math.Floor(controller.AxisValue("P2 Stick Y")) + 128); + joy1_LR = (byte)(255 - (controller.AxisValue("P1 Stick X") + 128)); + joy1_UD = (byte)(controller.AxisValue("P1 Stick Y") + 128); + joy2_LR = (byte)(255 - (controller.AxisValue("P2 Stick X") + 128)); + joy2_UD = (byte)(controller.AxisValue("P2 Stick Y") + 128); } else { diff --git a/src/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs b/src/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs index 548061fb28..3950dde0dd 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs @@ -291,7 +291,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK public ControllerDefinition Definition => null; - public float AxisValue(string name) + public int AxisValue(string name) { return _controller.AxisValue(_prefix + name); } diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs index abe8855b2d..ccccd2f794 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs @@ -128,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Waterbox )); _thunks.Add((c, b) => { - var val = (ushort)Math.Round(c.AxisValue(name)); + var val = c.AxisValue(name); b[byteStart] = (byte)val; b[byteStart + 1] = (byte)(val >> 8); }); @@ -143,7 +143,7 @@ namespace BizHawk.Emulation.Cores.Waterbox )); _thunks.Add((c, b) => { - var val = (short)Math.Round(c.AxisValue(name)); + var val = c.AxisValue(name); b[byteStart] = (byte)val; b[byteStart + 1] = (byte)(val >> 8); }); diff --git a/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs b/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs index 8fc6df67fb..eef2287b8d 100644 --- a/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs +++ b/src/BizHawk.Tests/Client.Common/Display/InputDisplayTests.cs @@ -10,7 +10,7 @@ namespace BizHawk.Tests.Client.Common.Display { private const int MidValue = 100; private SimpleController _boolController = null!; - private SimpleController _floatController = null!; + private SimpleController _axisController = null!; [TestInitialize] public void Initializer() @@ -20,7 +20,7 @@ namespace BizHawk.Tests.Client.Common.Display Definition = new ControllerDefinition { BoolButtons = { "A" } } }; - _floatController = new SimpleController + _axisController = new SimpleController { Definition = new ControllerDefinition { @@ -55,7 +55,7 @@ namespace BizHawk.Tests.Client.Common.Display [TestMethod] public void Generate_Floats() { - var displayGenerator = new Bk2InputDisplayGenerator("NES", _floatController); + var displayGenerator = new Bk2InputDisplayGenerator("NES", _axisController); var actual = displayGenerator.Generate(); Assert.AreEqual(" 0, 0,", actual); } @@ -63,8 +63,8 @@ namespace BizHawk.Tests.Client.Common.Display [TestMethod] public void Generate_MidRangeDisplaysEmpty() { - _floatController.AcceptNewAxis("StickX", MidValue); - var displayGenerator = new Bk2InputDisplayGenerator("NES", _floatController); + _axisController.AcceptNewAxis("StickX", MidValue); + var displayGenerator = new Bk2InputDisplayGenerator("NES", _axisController); var actual = displayGenerator.Generate(); Assert.AreEqual(" 0,", actual); }