Change more input code to use int for axes instead of float
This probably breaks TAStudio or something, on the bright side a lot of the
float equality checks are gone. see e12b5d813
This commit is contained in:
parent
3e5aa1a65f
commit
33ff00714d
|
@ -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<string, bool> 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
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <exception cref="NotImplementedException">always</exception>
|
||||
public float AxisValue(string name)
|
||||
public int AxisValue(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -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<string, List<string>> _bindings = new WorkingDictionary<string, List<string>>();
|
||||
private readonly WorkingDictionary<string, bool> _buttons = new WorkingDictionary<string, bool>();
|
||||
private readonly WorkingDictionary<string, float> _axes = new WorkingDictionary<string, float>();
|
||||
private readonly WorkingDictionary<string, int> _axes = new WorkingDictionary<string, int>();
|
||||
private readonly Dictionary<string, ControllerDefinition.AxisRange> _axisRanges = new WorkingDictionary<string, ControllerDefinition.AxisRange>();
|
||||
private readonly Dictionary<string, AnalogBind> _axisBindings = new Dictionary<string, AnalogBind>();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,26 +68,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
public class AutoPatternFloat
|
||||
public class AutoPatternAxis
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoPatternFloat"/> class.
|
||||
/// Initializes a new instance of the <see cref="AutoPatternAxis"/> class.
|
||||
/// Defaults to 0.
|
||||
/// </summary>
|
||||
public AutoPatternFloat()
|
||||
public AutoPatternAxis()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoPatternFloat"/> class.
|
||||
/// Initializes a new instance of the <see cref="AutoPatternAxis"/> class.
|
||||
/// Simple on/off pattern, using the given values as on/off.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the next value and increments index.
|
||||
/// </summary>
|
||||
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 @@
|
|||
/// <summary>
|
||||
/// Gets the next value without incrementing index.
|
||||
/// </summary>
|
||||
public float PeekNextValue()
|
||||
public int PeekNextValue()
|
||||
{
|
||||
return Pattern[_index];
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Call this once per frame to do the timekeeping for the hold and release
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.Client.Common
|
|||
public ControllerDefinition Definition { get; private set; }
|
||||
|
||||
private readonly Dictionary<string, bool> _overrides = new Dictionary<string, bool>();
|
||||
private readonly Dictionary<string, float> _axisOverrides = new Dictionary<string, float>();
|
||||
private readonly Dictionary<string, int> _axisOverrides = new Dictionary<string, int>();
|
||||
private readonly List<string> _inverses = new List<string>();
|
||||
|
||||
/// <exception cref="InvalidOperationException"><paramref name="button"/> not overridden</exception>
|
||||
|
@ -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<string> Overrides => _overrides.Select(kvp => kvp.Key);
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public IEnumerable<string> InversedButtons => _inverses;
|
||||
|
||||
public void SetAxis(string name, float value)
|
||||
public void SetAxis(string name, int value)
|
||||
{
|
||||
if (_axisOverrides.ContainsKey(name))
|
||||
{
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace BizHawk.Client.Common
|
|||
public ControllerDefinition Definition { get; set; }
|
||||
|
||||
protected WorkingDictionary<string, bool> Buttons { get; private set; } = new WorkingDictionary<string, bool>();
|
||||
protected WorkingDictionary<string, float> Axes { get; private set; } = new WorkingDictionary<string, float>();
|
||||
protected WorkingDictionary<string, int> Axes { get; private set; } = new WorkingDictionary<string, int>();
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Buttons = new WorkingDictionary<string, bool>();
|
||||
Axes = new WorkingDictionary<string, float>();
|
||||
Axes = new WorkingDictionary<string, int>();
|
||||
}
|
||||
|
||||
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<string, bool> 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)
|
||||
{
|
||||
|
|
|
@ -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<string, float?> _axisSet = new WorkingDictionary<string, float?>();
|
||||
private readonly WorkingDictionary<string, int?> _axisSet = new WorkingDictionary<string, int?>();
|
||||
|
||||
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<string, AutoPatternBool> _boolPatterns = new WorkingDictionary<string, AutoPatternBool>();
|
||||
private readonly WorkingDictionary<string, AutoPatternFloat> _axisPatterns = new WorkingDictionary<string, AutoPatternFloat>();
|
||||
private readonly WorkingDictionary<string, AutoPatternAxis> _axisPatterns = new WorkingDictionary<string, AutoPatternAxis>();
|
||||
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace BizHawk.Client.Common
|
|||
internal class Bk2Controller : IMovieController
|
||||
{
|
||||
private readonly WorkingDictionary<string, bool> _myBoolButtons = new WorkingDictionary<string, bool>();
|
||||
private readonly WorkingDictionary<string, float> _myAxisControls = new WorkingDictionary<string, float>();
|
||||
private readonly WorkingDictionary<string, int> _myAxisControls = new WorkingDictionary<string, int>();
|
||||
|
||||
private readonly Bk2ControllerDefinition _type;
|
||||
private readonly List<ControlMap> _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;
|
||||
}
|
||||
|
|
|
@ -120,8 +120,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
controller.AcceptNewAxes(new[]
|
||||
{
|
||||
("TouchX", (float) touchX),
|
||||
("TouchY", (float) touchY)
|
||||
("TouchX", touchX),
|
||||
("TouchY", touchY)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -188,7 +188,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
private readonly WorkingDictionary<string, bool> _myBoolButtons = new WorkingDictionary<string, bool>();
|
||||
private readonly WorkingDictionary<string, float> _myFloatControls = new WorkingDictionary<string, float>();
|
||||
private readonly WorkingDictionary<string, int> _myAxisControls = new WorkingDictionary<string, int>();
|
||||
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,6 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Sets the given axis button to the given value
|
||||
/// </summary>
|
||||
void SetAxis(string buttonName, float value);
|
||||
void SetAxis(string buttonName, int value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<float> _oldState;
|
||||
private readonly float _newState;
|
||||
private readonly List<int> _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<float>(endFrame - startFrame + 1);
|
||||
_oldState = new List<int>(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<float>(endFrame - startFrame + 1);
|
||||
_isAxis = true;
|
||||
_oldState = new List<int>(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
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
void PreprocessHostGamepads();
|
||||
|
||||
void ProcessHostGamepads(Action<string?, bool, InputFocus> handleButton, Action<string?, float> handleAxis);
|
||||
void ProcessHostGamepads(Action<string?, bool, InputFocus> handleButton, Action<string?, int> handleAxis);
|
||||
|
||||
IEnumerable<KeyEvent> ProcessHostKeyboards();
|
||||
}
|
||||
|
@ -51,19 +51,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
GamePad360.UpdateAll();
|
||||
}
|
||||
|
||||
public void ProcessHostGamepads(Action<string?, bool, InputFocus> handleButton, Action<string?, float> handleAxis)
|
||||
public void ProcessHostGamepads(Action<string?, bool, InputFocus> handleButton, Action<string?, int> 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<string?, bool, InputFocus> handleButton, Action<string?, float> handleAxis)
|
||||
public void ProcessHostGamepads(Action<string?, bool, InputFocus> handleButton, Action<string?, int> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private readonly Dictionary<string, LogicalButton> _modifierState = new Dictionary<string, LogicalButton>();
|
||||
private readonly WorkingDictionary<string, bool> _lastState = new WorkingDictionary<string, bool>();
|
||||
private readonly WorkingDictionary<string, float> _axisValues = new WorkingDictionary<string, float>();
|
||||
private readonly WorkingDictionary<string, int> _axisValues = new WorkingDictionary<string, int>();
|
||||
private readonly WorkingDictionary<string, float> _axisDeltas = new WorkingDictionary<string, float>();
|
||||
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<string, float> GetAxisValues()
|
||||
public IDictionary<string, int> GetAxisValues()
|
||||
{
|
||||
lock (_axisValues)
|
||||
{
|
||||
|
|
|
@ -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<string, float>? mouseX = null, mouseY = null;
|
||||
KeyValuePair<string, int>? 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<float> p = new List<float>();
|
||||
var p = new List<int>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public Dictionary<string, string> CategoryLabels { get; } = new Dictionary<string, string>();
|
||||
|
||||
public void ApplyAxisConstraints(string constraintClass, IDictionary<string, float> floatButtons)
|
||||
public void ApplyAxisConstraints(string constraintClass, IDictionary<string, int> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
bool IsPressed(string button);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the state of a float control
|
||||
/// Returns the state of an axis control
|
||||
/// </summary>
|
||||
float AxisValue(string name);
|
||||
int AxisValue(string name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public class SaveController : IController
|
||||
{
|
||||
private readonly WorkingDictionary<string, float> _buttons = new WorkingDictionary<string, float>();
|
||||
private readonly WorkingDictionary<string, int> _buttons = new WorkingDictionary<string, int>();
|
||||
|
||||
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];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue