Rename axis-related types, members, and locals

I left a few methods where they had an equivalent *Bool*() for buttons, and also
left some in TAStudio that get serialised.
This commit is contained in:
YoshiRulz 2020-03-31 17:28:06 +10:00
parent 19b1d0fa18
commit 0ba7a5a7df
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
96 changed files with 602 additions and 602 deletions

View File

@ -384,8 +384,8 @@ namespace BizHawk.Client.ApiHawk
var joypadAdaptor = Global.AutofireStickyXORAdapter;
for (var i = 1; i <= RunningSystem.MaxControllers; i++)
{
joypadAdaptor.SetFloat($"P{i} X Axis", _allJoyPads[i - 1].AnalogX);
joypadAdaptor.SetFloat($"P{i} Y Axis", _allJoyPads[i - 1].AnalogY);
joypadAdaptor.SetAxis($"P{i} X Axis", _allJoyPads[i - 1].AnalogX);
joypadAdaptor.SetAxis($"P{i} Y Axis", _allJoyPads[i - 1].AnalogY);
}
}
#endif
@ -437,8 +437,8 @@ namespace BizHawk.Client.ApiHawk
{
for (int i = 1; i <= RunningSystem.MaxControllers; i++)
{
_allJoyPads[i - 1].AnalogX = joypadAdapter.GetFloat($"P{i} X Axis");
_allJoyPads[i - 1].AnalogY = joypadAdapter.GetFloat($"P{i} Y Axis");
_allJoyPads[i - 1].AnalogX = joypadAdapter.AxisValue($"P{i} X Axis");
_allJoyPads[i - 1].AnalogY = joypadAdapter.AxisValue($"P{i} Y Axis");
}
}
}

View File

@ -39,7 +39,7 @@ namespace BizHawk.Client.Common
return;
}
foreach (var button in lg.Definition.BoolButtons) Global.InputManager.ButtonOverrideAdapter.SetButton(button, lg.IsPressed(button));
foreach (var floatButton in lg.Definition.FloatControls) Global.InputManager.ButtonOverrideAdapter.SetFloat(floatButton, lg.GetFloat(floatButton));
foreach (var floatButton in lg.Definition.AxisControls) Global.InputManager.ButtonOverrideAdapter.SetAxis(floatButton, lg.AxisValue(floatButton));
}
public void Set(Dictionary<string, bool> buttons, int? controller = null)
@ -76,7 +76,7 @@ namespace BizHawk.Client.Common
{
try
{
Global.InputManager.StickyXorAdapter.SetFloat(controller == null ? control : $"P{controller} {control}", value);
Global.InputManager.StickyXorAdapter.SetAxis(controller == null ? control : $"P{controller} {control}", value);
}
catch
{

View File

@ -47,7 +47,7 @@ namespace BizHawk.Client.Common
}
/// <exception cref="NotImplementedException">always</exception>
public float GetFloat(string name)
public float AxisValue(string name)
{
throw new NotImplementedException();
}

View File

@ -12,10 +12,10 @@ namespace BizHawk.Client.Common
public Controller(ControllerDefinition definition)
{
Definition = definition;
for (int i = 0; i < Definition.FloatControls.Count; i++)
for (int i = 0; i < Definition.AxisControls.Count; i++)
{
_floatButtons[Definition.FloatControls[i]] = Definition.FloatRanges[i].Mid;
_floatRanges[Definition.FloatControls[i]] = Definition.FloatRanges[i];
_axes[Definition.AxisControls[i]] = Definition.AxisRanges[i].Mid;
_axisRanges[Definition.AxisControls[i]] = Definition.AxisRanges[i];
}
}
@ -23,13 +23,13 @@ namespace BizHawk.Client.Common
public bool IsPressed(string button) => _buttons[button];
public float GetFloat(string name) => _floatButtons[name];
public float 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> _floatButtons = new WorkingDictionary<string, float>();
private readonly Dictionary<string, ControllerDefinition.AxisRange> _floatRanges = new WorkingDictionary<string, ControllerDefinition.AxisRange>();
private readonly Dictionary<string, AnalogBind> _floatBinds = new Dictionary<string, AnalogBind>();
private readonly WorkingDictionary<string, float> _axes = new WorkingDictionary<string, float>();
private readonly Dictionary<string, ControllerDefinition.AxisRange> _axisRanges = new WorkingDictionary<string, ControllerDefinition.AxisRange>();
private readonly Dictionary<string, AnalogBind> _axisBindings = new Dictionary<string, AnalogBind>();
/// <summary>don't do this</summary>
public void ForceType(ControllerDefinition newType) => Definition = newType;
@ -49,15 +49,15 @@ namespace BizHawk.Client.Common
.SelectMany(kvp => kvp.Value)
.Any(boundButton => boundButton == button);
public void NormalizeFloats(IController controller)
public void NormalizeAxes(IController controller)
{
foreach (var kvp in _floatBinds)
foreach (var kvp in _axisBindings)
{
var input = _floatButtons[kvp.Key];
var input = _axes[kvp.Key];
string outKey = kvp.Key;
float multiplier = kvp.Value.Mult;
float deadZone = kvp.Value.Deadzone;
if (_floatRanges.TryGetValue(outKey, out var range))
if (_axisRanges.TryGetValue(outKey, out var range))
{
// input range is assumed to be -10000,0,10000
@ -91,7 +91,7 @@ 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
_floatButtons[outKey] = output.ConstrainWithin(range.FloatRange);
_axes[outKey] = output.ConstrainWithin(range.FloatRange);
}
}
}
@ -116,22 +116,22 @@ namespace BizHawk.Client.Common
}
}
foreach (var kvp in _floatBinds)
foreach (var kvp in _axisBindings)
{
var input = controller.GetFloat(kvp.Value.Value);
var input = controller.AxisValue(kvp.Value.Value);
string outKey = kvp.Key;
if (_floatRanges.ContainsKey(outKey))
if (_axisRanges.ContainsKey(outKey))
{
_floatButtons[outKey] = input;
_axes[outKey] = input;
}
}
// it's not sure where this should happen, so for backwards compatibility.. do it every time
NormalizeFloats(controller);
NormalizeAxes(controller);
}
public void ApplyAxisConstraints(string constraintClass)
=> Definition.ApplyAxisConstraints(constraintClass, _floatButtons);
=> Definition.ApplyAxisConstraints(constraintClass, _axes);
/// <summary>
/// merges pressed logical buttons from the supplied controller, effectively ORing it with the current state
@ -159,9 +159,9 @@ namespace BizHawk.Client.Common
_buttons[button] = controller.IsPressed(button);
}
foreach (var button in controller.FloatOverrides)
foreach (var button in controller.AxisOverrides)
{
_floatButtons[button] = controller.GetFloat(button);
_axes[button] = controller.AxisValue(button);
}
foreach (var button in controller.InversedButtons)
@ -184,9 +184,9 @@ namespace BizHawk.Client.Common
}
}
public void BindFloat(string button, AnalogBind bind)
public void BindAxis(string button, AnalogBind bind)
{
_floatBinds[button] = bind;
_axisBindings[button] = bind;
}
public List<string> PressedButtons => _buttons

View File

@ -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 GetFloat(string name) => Source.GetFloat(name);
public float 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 GetFloat(string name) => Source.GetFloat(name);
public float 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 GetFloat(string name) => Source.GetFloat(name);
public float AxisValue(string name) => Source.AxisValue(name);
internal IController Source { get; set; }
internal IController SourceOr { get; set; }

View File

@ -17,7 +17,7 @@ namespace BizHawk.Client.Common
return _pressed.Contains(button);
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return 0.0f;
}

View File

@ -14,9 +14,9 @@ namespace BizHawk.Client.Common
return Curr.IsPressed(button);
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return Curr.GetFloat(name);
return Curr.AxisValue(name);
}
public IController Source { get; set; }

View File

@ -109,11 +109,11 @@ namespace BizHawk.Client.Common
if (analogBinds.TryGetValue(def.Name, out var aBinds))
{
foreach (var btn in def.FloatControls)
foreach (var btn in def.AxisControls)
{
if (aBinds.TryGetValue(btn, out var bind))
{
ret.BindFloat(btn, bind);
ret.BindAxis(btn, bind);
}
}
}

View File

@ -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> _floatOverrides = new Dictionary<string, float>();
private readonly Dictionary<string, float> _axisOverrides = new Dictionary<string, float>();
private readonly List<string> _inverses = new List<string>();
/// <exception cref="InvalidOperationException"><paramref name="button"/> not overridden</exception>
@ -28,27 +28,27 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
public float GetFloat(string name)
=> _floatOverrides.ContainsKey(name)
? _floatOverrides[name]
public float AxisValue(string name)
=> _axisOverrides.ContainsKey(name)
? _axisOverrides[name]
: 0.0F;
public IEnumerable<string> Overrides => _overrides.Select(kvp => kvp.Key);
public IEnumerable<string> FloatOverrides => _floatOverrides.Select(kvp => kvp.Key);
public IEnumerable<string> AxisOverrides => _axisOverrides.Select(kvp => kvp.Key);
public IEnumerable<string> InversedButtons => _inverses;
public void SetFloat(string name, float value)
public void SetAxis(string name, float value)
{
if (_floatOverrides.ContainsKey(name))
if (_axisOverrides.ContainsKey(name))
{
_floatOverrides[name] = value;
_axisOverrides[name] = value;
}
else
{
_floatOverrides.Add(name, value);
_axisOverrides.Add(name, value);
}
}
@ -80,7 +80,7 @@ namespace BizHawk.Client.Common
public void FrameTick()
{
_overrides.Clear();
_floatOverrides.Clear();
_axisOverrides.Clear();
_inverses.Clear();
}
}

View File

@ -14,12 +14,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> Floats { get; private set; } = new WorkingDictionary<string, float>();
protected WorkingDictionary<string, float> Axes { get; private set; } = new WorkingDictionary<string, float>();
public void Clear()
{
Buttons = new WorkingDictionary<string, bool>();
Floats = new WorkingDictionary<string, float>();
Axes = new WorkingDictionary<string, float>();
}
public bool this[string button]
@ -33,9 +33,9 @@ namespace BizHawk.Client.Common
return this[button];
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return Floats[name];
return Axes[name];
}
public IEnumerable<KeyValuePair<string, bool>> BoolButtons()
@ -43,16 +43,16 @@ namespace BizHawk.Client.Common
return Buttons;
}
public void AcceptNewFloat(Tuple<string, float> newValue)
public void AcceptNewAxes(Tuple<string, float> newValue)
{
Floats[newValue.Item1] = newValue.Item2;
Axes[newValue.Item1] = newValue.Item2;
}
public void AcceptNewFloats(IEnumerable<Tuple<string, float>> newValues)
public void AcceptNewAxes(IEnumerable<Tuple<string, float>> newValues)
{
foreach (var sv in newValues)
{
Floats[sv.Item1] = sv.Item2;
Axes[sv.Item1] = sv.Item2;
}
}
}

View File

@ -17,9 +17,9 @@ namespace BizHawk.Client.Common
return source;
}
public float GetFloat(string name)
public float AxisValue(string name)
{
var val = _floatSet[name];
var val = _axisSet[name];
if (val.HasValue)
{
@ -31,30 +31,30 @@ namespace BizHawk.Client.Common
return 0;
}
return Source.GetFloat(name);
return Source.AxisValue(name);
}
public IController Source { get; set; }
private List<string> _justPressed = new List<string>();
// if SetFloat() is called (typically virtual pads), then that float will entirely override the Source input
// 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?> _floatSet = new WorkingDictionary<string, float?>();
private readonly WorkingDictionary<string, float?> _axisSet = new WorkingDictionary<string, float?>();
public void SetFloat(string name, float? value)
public void SetAxis(string name, float? value)
{
if (value.HasValue)
{
_floatSet[name] = value;
_axisSet[name] = value;
}
else
{
_floatSet.Remove(name);
_axisSet.Remove(name);
}
}
public void ClearStickyFloats() => _floatSet.Clear();
public void ClearStickyAxes() => _axisSet.Clear();
public void SetSticky(string button, bool isSticky)
{
@ -71,7 +71,7 @@ namespace BizHawk.Client.Common
public void Unset(string button)
{
CurrentStickies.Remove(button);
_floatSet.Remove(button);
_axisSet.Remove(button);
}
public bool IsSticky(string button) => CurrentStickies.Contains(button);
@ -81,7 +81,7 @@ namespace BizHawk.Client.Common
public void ClearStickies()
{
CurrentStickies.Clear();
_floatSet.Clear();
_axisSet.Clear();
}
public void MassToggleStickyState(List<string> buttons)
@ -121,11 +121,11 @@ namespace BizHawk.Client.Common
return source;
}
public float GetFloat(string name)
public float AxisValue(string name)
{
if (_floatPatterns.ContainsKey(name))
if (_axisPatterns.ContainsKey(name))
{
return _floatPatterns[name].PeekNextValue();
return _axisPatterns[name].PeekNextValue();
}
if (Source == null)
@ -133,7 +133,7 @@ namespace BizHawk.Client.Common
return 0;
}
return Source.GetFloat(name);
return Source.AxisValue(name);
}
// TODO: Change the AutoHold adapter to be one of these, with an 'Off' value of 0?
@ -148,7 +148,7 @@ namespace BizHawk.Client.Common
}
private readonly WorkingDictionary<string, AutoPatternBool> _boolPatterns = new WorkingDictionary<string, AutoPatternBool>();
private readonly WorkingDictionary<string, AutoPatternFloat> _floatPatterns = new WorkingDictionary<string, AutoPatternFloat>();
private readonly WorkingDictionary<string, AutoPatternFloat> _axisPatterns = new WorkingDictionary<string, AutoPatternFloat>();
public AutoFireStickyXorAdapter()
{
@ -158,7 +158,7 @@ namespace BizHawk.Client.Common
public IController Source { get; set; }
public void SetFloat(string name, float? value, AutoPatternFloat pattern = null)
public void SetAxis(string name, float? value, AutoPatternFloat pattern = null)
{
if (value.HasValue)
{
@ -167,11 +167,11 @@ namespace BizHawk.Client.Common
pattern = new AutoPatternFloat(value.Value, _on, 0, _off);
}
_floatPatterns[name] = pattern;
_axisPatterns[name] = pattern;
}
else
{
_floatPatterns.Remove(name);
_axisPatterns.Remove(name);
}
}
@ -194,7 +194,7 @@ namespace BizHawk.Client.Common
public bool IsSticky(string button)
{
return _boolPatterns.ContainsKey(button) || _floatPatterns.ContainsKey(button);
return _boolPatterns.ContainsKey(button) || _axisPatterns.ContainsKey(button);
}
public HashSet<string> CurrentStickies => new HashSet<string>(_boolPatterns.Keys);
@ -202,7 +202,7 @@ namespace BizHawk.Client.Common
public void ClearStickies()
{
_boolPatterns.Clear();
_floatPatterns.Clear();
_axisPatterns.Clear();
}
public void IncrementLoops(bool lagged)
@ -212,9 +212,9 @@ namespace BizHawk.Client.Common
_boolPatterns.ElementAt(i).Value.GetNextValue(lagged);
}
for (int i = 0; i < _floatPatterns.Count; i++)
for (int i = 0; i < _axisPatterns.Count; i++)
{
_floatPatterns.ElementAt(i).Value.GetNextValue(lagged);
_axisPatterns.ElementAt(i).Value.GetNextValue(lagged);
}
}

View File

@ -144,9 +144,9 @@ namespace BizHawk.Client.Common
}
// The float format implies no U+D and no L+R no matter what, so just passthru
public float GetFloat(string name)
public float AxisValue(string name)
{
return Source.GetFloat(name);
return Source.AxisValue(name);
}
private readonly HashSet<string> _unpresses = new HashSet<string>();

View File

@ -102,9 +102,9 @@ namespace BizHawk.Client.Common
return Source.IsPressed(RemapButtonName(button));
}
public float GetFloat(string button)
public float AxisValue(string button)
{
return Source.GetFloat(RemapButtonName(button));
return Source.AxisValue(RemapButtonName(button));
}
private string RemapButtonName(string button)

View File

@ -2,7 +2,7 @@
namespace BizHawk.Client.Common
{
public class Bk2FloatConstants
public class Bk2AxisMnemonicConstants
{
public string this[string button]
{

View File

@ -13,14 +13,14 @@ namespace BizHawk.Client.Common
{
public string Name { get; set; }
public bool IsBool { get; set; }
public bool IsFloat { get; set; }
public bool IsAxis { get; set; }
}
private List<ControlMap> _controlsOrdered = new List<ControlMap>();
private readonly string _logKey = "";
private readonly WorkingDictionary<string, bool> _myBoolButtons = new WorkingDictionary<string, bool>();
private readonly WorkingDictionary<string, float> _myFloatControls = new WorkingDictionary<string, float>();
private readonly WorkingDictionary<string, float> _myAxisControls = new WorkingDictionary<string, float>();
public Bk2ControllerAdapter()
{
@ -65,9 +65,9 @@ namespace BizHawk.Client.Common
return _myBoolButtons[button];
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return _myFloatControls[name];
return _myAxisControls[name];
}
#endregion
@ -91,7 +91,7 @@ namespace BizHawk.Client.Common
{
Name = c,
IsBool = def.BoolButtons.Contains(c),
IsFloat = def.FloatControls.Contains(c)
IsAxis = def.AxisControls.Contains(c)
})
.ToList();
}
@ -115,7 +115,7 @@ namespace BizHawk.Client.Common
_myBoolButtons[button] = val;
}
foreach (var button in Definition.FloatControls)
foreach (var button in Definition.AxisControls)
{
var bnp = ButtonNameParser.Parse(button);
@ -124,9 +124,9 @@ namespace BizHawk.Client.Common
continue;
}
var val = playerSource.GetFloat(button);
var val = playerSource.AxisValue(button);
_myFloatControls[button] = val;
_myAxisControls[button] = val;
}
}
@ -140,9 +140,9 @@ namespace BizHawk.Client.Common
_myBoolButtons[button] = source.IsPressed(button);
}
foreach (var name in Definition.FloatControls)
foreach (var name in Definition.AxisControls)
{
_myFloatControls[name] = source.GetFloat(name);
_myAxisControls[name] = source.AxisValue(name);
}
}
@ -157,9 +157,9 @@ namespace BizHawk.Client.Common
}
// float controls don't have sticky logic, so latch default value
for (int i = 0; i < Definition.FloatControls.Count; i++)
for (int i = 0; i < Definition.AxisControls.Count; i++)
{
_myFloatControls[Definition.FloatControls[i]] = Definition.FloatRanges[i].Mid;
_myAxisControls[Definition.AxisControls[i]] = Definition.AxisRanges[i].Mid;
}
}
@ -180,12 +180,12 @@ namespace BizHawk.Client.Common
_myBoolButtons[key.Name] = trimmed[iterator] != '.';
iterator++;
}
else if (key.IsFloat)
else if (key.IsAxis)
{
var commaIndex = trimmed.Substring(iterator).IndexOf(',');
var temp = trimmed.Substring(iterator, commaIndex);
var val = int.Parse(temp.Trim());
_myFloatControls[key.Name] = val;
_myAxisControls[key.Name] = val;
iterator += commaIndex + 1;
}
@ -195,9 +195,9 @@ namespace BizHawk.Client.Common
#endregion
public void SetFloat(string buttonName, float value)
public void SetAxis(string buttonName, float value)
{
_myFloatControls[buttonName] = value;
_myAxisControls[buttonName] = value;
}
public class Bk2ControllerDefinition : ControllerDefinition

View File

@ -9,7 +9,7 @@ namespace BizHawk.Client.Common
public class Bk2LogEntryGenerator : ILogEntryGenerator
{
private readonly Bk2MnemonicConstants _mnemonics = new Bk2MnemonicConstants();
private readonly Bk2FloatConstants _floatLookup = new Bk2FloatConstants();
private readonly Bk2AxisMnemonicConstants _axisMnemonics = new Bk2AxisMnemonicConstants();
private readonly string _logKey;
private IController _source;
@ -61,9 +61,9 @@ namespace BizHawk.Client.Common
{
dict.Add(button, _mnemonics[button].ToString());
}
else if (_source.Definition.FloatControls.Contains(button))
else if (_source.Definition.AxisControls.Contains(button))
{
dict.Add(button, _floatLookup[button]);
dict.Add(button, _axisMnemonics[button]);
}
}
}
@ -86,11 +86,11 @@ namespace BizHawk.Client.Common
{
foreach (var button in group)
{
if (_source.Definition.FloatControls.Contains(button))
if (_source.Definition.AxisControls.Contains(button))
{
int val;
int i = _source.Definition.FloatControls.IndexOf(button);
var mid = _source.Definition.FloatRanges[i].Mid;
int i = _source.Definition.AxisControls.IndexOf(button);
var mid = _source.Definition.AxisRanges[i].Mid;
if (createEmpty)
{
@ -98,7 +98,7 @@ namespace BizHawk.Client.Common
}
else
{
val = (int)_source.GetFloat(button);
val = (int)_source.AxisValue(button);
}
if (forInputDisplay && val == mid)

View File

@ -93,10 +93,10 @@ namespace BizHawk.Client.Common
}
};
controller.Definition.FloatControls.Add("TouchX");
controller.Definition.FloatRanges.Add(new ControllerDefinition.AxisRange(0, 128, 255));
controller.Definition.FloatControls.Add("TouchY");
controller.Definition.FloatRanges.Add(new ControllerDefinition.AxisRange(0, 96, 191));
controller.Definition.AxisControls.Add("TouchX");
controller.Definition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 128, 255));
controller.Definition.AxisControls.Add("TouchY");
controller.Definition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 96, 191));
controller["LidOpen"] = false;
controller["LidOpen"] = false;
@ -120,7 +120,7 @@ namespace BizHawk.Client.Common
var touchX = int.Parse(sections[1].Substring(13, 3));
var touchY = int.Parse(sections[1].Substring(17, 3));
controller.AcceptNewFloats(new[]
controller.AcceptNewAxes(new[]
{
new Tuple<string, float>("TouchX", touchX),
new Tuple<string, float>("TouchY", touchY)

View File

@ -218,7 +218,7 @@ namespace BizHawk.Client.Common
var rightX = new Tuple<string, float>("P1 RStick X", br.ReadByte());
var rightY = new Tuple<string, float>("P1 RStick Y", br.ReadByte());
controllers.AcceptNewFloats(new[] { leftX, leftY, rightX, rightY });
controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY });
}
}
@ -241,7 +241,7 @@ namespace BizHawk.Client.Common
var rightX = new Tuple<string, float>("P2 RStick X", br.ReadByte());
var rightY = new Tuple<string, float>("P2 RStick Y", br.ReadByte());
controllers.AcceptNewFloats(new[] { leftX, leftY, rightX, rightY });
controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY });
}
}
@ -268,7 +268,7 @@ namespace BizHawk.Client.Common
}
Tuple<string, float> discSelect = new Tuple<string, float>("Disc Select", cdNumber);
controllers.AcceptNewFloats(new[] { discSelect });
controllers.AcceptNewAxes(new[] { discSelect });
if ((controlState & 0xFC) != 0)
{
@ -356,7 +356,7 @@ namespace BizHawk.Client.Common
Tuple<string, float> rightX = new Tuple<string, float>("P1 RStick X", float.Parse(rightXRaw));
Tuple<string, float> rightY = new Tuple<string, float>("P1 RStick Y", float.Parse(rightYRaw));
controllers.AcceptNewFloats(new[] { leftX, leftY, rightX, rightY });
controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY });
}
}
@ -391,7 +391,7 @@ namespace BizHawk.Client.Common
Tuple<string, float> rightX = new Tuple<string, float>("P2 RStick X", float.Parse(rightXRaw));
Tuple<string, float> rightY = new Tuple<string, float>("P2 RStick Y", float.Parse(rightYRaw));
controllers.AcceptNewFloats(new[] { leftX, leftY, rightX, rightY });
controllers.AcceptNewAxes(new[] { leftX, leftY, rightX, rightY });
}
}
@ -418,7 +418,7 @@ namespace BizHawk.Client.Common
}
Tuple<string, float> discSelect = new Tuple<string, float>("Disc Select", cdNumber);
controllers.AcceptNewFloats(new[] { discSelect });
controllers.AcceptNewAxes(new[] { discSelect });
if ((controlState & 0xFC) != 0)
{

View File

@ -16,7 +16,7 @@ namespace BizHawk.Client.Common
return _myBoolButtons[button];
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return _myFloatControls[name];
}

View File

@ -497,8 +497,8 @@ namespace BizHawk.Client.Common
}
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
var old = adapter.GetFloat(buttonName);
adapter.SetFloat(buttonName, val);
var old = adapter.AxisValue(buttonName);
adapter.SetAxis(buttonName, val);
var lg = LogGeneratorInstance();
lg.SetSource(adapter);
@ -525,8 +525,8 @@ namespace BizHawk.Client.Common
for (int i = 0; i < count; i++)
{
var adapter = GetInputState(frame + i) as Bk2ControllerAdapter;
float old = adapter.GetFloat(buttonName);
adapter.SetFloat(buttonName, val);
float old = adapter.AxisValue(buttonName);
adapter.SetAxis(buttonName, val);
var lg = LogGeneratorInstance();
lg.SetSource(adapter);

View File

@ -139,9 +139,9 @@ namespace BizHawk.Client.Common
: "";
}
if (adapter.Definition.FloatControls.Contains(buttonName))
if (adapter.Definition.AxisControls.Contains(buttonName))
{
return adapter.GetFloat(buttonName).ToString();
return adapter.AxisValue(buttonName).ToString();
}
return "!";
@ -156,7 +156,7 @@ namespace BizHawk.Client.Common
public float GetFloatState(int frame, string buttonName)
{
return ((Bk2ControllerAdapter)GetInputState(frame))
.GetFloat(buttonName);
.AxisValue(buttonName);
}
public void ClearGreenzone()

View File

@ -223,8 +223,8 @@ 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> _floatValues = new WorkingDictionary<string, float>();
private readonly WorkingDictionary<string, float> _floatDeltas = new WorkingDictionary<string, float>();
private readonly WorkingDictionary<string, float> _axisValues = new WorkingDictionary<string, float>();
private readonly WorkingDictionary<string, float> _axisDeltas = new WorkingDictionary<string, float>();
private bool _trackDeltas;
private bool _ignoreEventsNextPoll;
@ -338,18 +338,18 @@ namespace BizHawk.Client.EmuHawk
}
}
public List<Tuple<string, float>> GetFloats()
public List<Tuple<string, float>> GetAxisValues()
{
var floatValuesCopy = new List<Tuple<string,float>>();
lock (_floatValues)
var axisValuesCopy = new List<Tuple<string,float>>();
lock (_axisValues)
{
foreach (var kvp in _floatValues)
foreach (var kvp in _axisValues)
{
floatValuesCopy.Add(new Tuple<string, float>(kvp.Key, kvp.Value));
axisValuesCopy.Add(new Tuple<string, float>(kvp.Key, kvp.Value));
}
}
return floatValuesCopy;
return axisValuesCopy;
}
private void UpdateThreadProc()
@ -383,9 +383,9 @@ namespace BizHawk.Client.EmuHawk
foreach (var ke in keyEvents)
HandleButton(ke.Key.ToString(), ke.Pressed, InputFocus.Keyboard);
lock (_floatValues)
lock (_axisValues)
{
//FloatValues.Clear();
//_axisValues.Clear();
// analyze OpenTK xinput (or is it libinput?)
foreach (var pad in OTK_GamePad.EnumerateDevices())
@ -394,12 +394,12 @@ namespace BizHawk.Client.EmuHawk
{
HandleButton(pad.InputNamePrefix + but.ButtonName, but.ButtonAction(), InputFocus.Pad);
}
foreach (var sv in pad.GetFloats())
foreach (var sv in pad.GetAxes())
{
var n = $"{pad.InputNamePrefix}{sv.Item1} Axis";
var f = sv.Item2;
if (_trackDeltas) _floatDeltas[n] += Math.Abs(f - _floatValues[n]);
_floatValues[n] = f;
if (_trackDeltas) _axisDeltas[n] += Math.Abs(f - _axisValues[n]);
_axisValues[n] = f;
}
}
@ -410,13 +410,13 @@ namespace BizHawk.Client.EmuHawk
string xName = $"X{pad.PlayerNumber} ";
for (int b = 0; b < pad.NumButtons; b++)
HandleButton(xName + pad.ButtonName(b), pad.Pressed(b), InputFocus.Pad);
foreach (var sv in pad.GetFloats())
foreach (var sv in pad.GetAxes())
{
string n = xName + sv.Item1;
float f = sv.Item2;
if (_trackDeltas)
_floatDeltas[n] += Math.Abs(f - _floatValues[n]);
_floatValues[n] = f;
_axisDeltas[n] += Math.Abs(f - _axisValues[n]);
_axisValues[n] = f;
}
}
@ -426,15 +426,15 @@ namespace BizHawk.Client.EmuHawk
string jName = $"J{pad.PlayerNumber} ";
for (int b = 0; b < pad.NumButtons; b++)
HandleButton(jName + pad.ButtonName(b), pad.Pressed(b), InputFocus.Pad);
foreach (var sv in pad.GetFloats())
foreach (var sv in pad.GetAxes())
{
string n = jName + sv.Item1;
float f = sv.Item2;
//if (n == "J5 RotationZ")
// System.Diagnostics.Debugger.Break();
if (_trackDeltas)
_floatDeltas[n] += Math.Abs(f - _floatValues[n]);
_floatValues[n] = f;
_axisDeltas[n] += Math.Abs(f - _axisValues[n]);
_axisValues[n] = f;
}
}
#endif
@ -447,12 +447,12 @@ namespace BizHawk.Client.EmuHawk
if (_trackDeltas)
{
// these are relative to screen coordinates, but that's not terribly important
_floatDeltas["WMouse X"] += Math.Abs(mousePos.X - _floatValues["WMouse X"]) * 50;
_floatDeltas["WMouse Y"] += Math.Abs(mousePos.Y - _floatValues["WMouse Y"]) * 50;
_axisDeltas["WMouse X"] += Math.Abs(mousePos.X - _axisValues["WMouse X"]) * 50;
_axisDeltas["WMouse Y"] += Math.Abs(mousePos.Y - _axisValues["WMouse Y"]) * 50;
}
// coordinate translation happens later
_floatValues["WMouse X"] = mousePos.X;
_floatValues["WMouse Y"] = mousePos.Y;
_axisValues["WMouse X"] = mousePos.X;
_axisValues["WMouse Y"] = mousePos.Y;
var mouseBtns = Control.MouseButtons;
HandleButton("WMouse L", (mouseBtns & MouseButtons.Left) != 0, InputFocus.Mouse);
@ -504,20 +504,20 @@ namespace BizHawk.Client.EmuHawk
return allowInput == AllowInput.None || (allowInput == AllowInput.OnlyController && inputEvent.Source != InputFocus.Pad);
}
public void StartListeningForFloatEvents()
public void StartListeningForAxisEvents()
{
lock (_floatValues)
lock (_axisValues)
{
_floatDeltas.Clear();
_axisDeltas.Clear();
_trackDeltas = true;
}
}
public string GetNextFloatEvent()
public string GetNextAxisEvent()
{
lock (_floatValues)
lock (_axisValues)
{
foreach (var kvp in _floatDeltas)
foreach (var kvp in _axisDeltas)
{
// need to wiggle the stick a bit
if (kvp.Value >= 20000.0f)
@ -527,9 +527,9 @@ namespace BizHawk.Client.EmuHawk
return null;
}
public void StopListeningForFloatEvents()
public void StopListeningForAxisEvents()
{
lock (_floatValues)
lock (_axisValues)
{
_trackDeltas = false;
}

View File

@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
}
}
/// <summary>The things that use <see cref="GetFloats"/> (analog controls) appear to require values -10000.0..10000.0 rather than the -1.0..1.0 that OpenTK returns (although even then the results may be slightly outside of these bounds)</summary>
/// <summary>The things that use <see cref="GetAxes"/> (analog controls) appear to require values -10000.0..10000.0 rather than the -1.0..1.0 that OpenTK returns (although even then the results may be slightly outside of these bounds)</summary>
private static float ConstrainFloatInput(float num)
{
if (num > 1) return 10000.0f;
@ -168,7 +168,7 @@ namespace BizHawk.Client.EmuHawk
if (!tmpJstate.Equals(jState)) Debug.WriteLine($"Joystick State:\t{tmpJstate}");
}
public IEnumerable<Tuple<string, float>> GetFloats()
public IEnumerable<Tuple<string, float>> GetAxes()
{
if (MappedGamePad)
{

View File

@ -971,14 +971,14 @@ namespace BizHawk.Client.EmuHawk
//also handle floats
//we'll need to isolate the mouse coordinates so we can translate them
Tuple<string, float> mouseX = null, mouseY = null;
var floats = Input.Instance.GetFloats();
foreach (var f in Input.Instance.GetFloats())
var floats = Input.Instance.GetAxisValues();
foreach (var f in Input.Instance.GetAxisValues())
{
if (f.Item1 == "WMouse X")
mouseX = f;
else if (f.Item1 == "WMouse Y")
mouseY = f;
else conInput.AcceptNewFloat(f);
else conInput.AcceptNewAxes(f);
}
//if we found mouse coordinates (and why wouldn't we?) then translate them now
@ -988,8 +988,8 @@ namespace BizHawk.Client.EmuHawk
var p = DisplayManager.UntransformPoint(new Point((int)mouseX.Item2, (int)mouseY.Item2));
float x = p.X / (float)_currentVideoProvider.BufferWidth;
float y = p.Y / (float)_currentVideoProvider.BufferHeight;
conInput.AcceptNewFloat(new Tuple<string, float>("WMouse X", (x * 20000) - 10000));
conInput.AcceptNewFloat(new Tuple<string, float>("WMouse Y", (y * 20000) - 10000));
conInput.AcceptNewAxes(new Tuple<string, float>("WMouse X", (x * 20000) - 10000));
conInput.AcceptNewAxes(new Tuple<string, float>("WMouse Y", (y * 20000) - 10000));
}
}
@ -3822,7 +3822,7 @@ namespace BizHawk.Client.EmuHawk
Rewinder.Initialize();
Global.InputManager.StickyXorAdapter.ClearStickies();
Global.InputManager.StickyXorAdapter.ClearStickyFloats();
Global.InputManager.StickyXorAdapter.ClearStickyAxes();
Global.InputManager.AutofireStickyXorAdapter.ClearStickies();
RewireSound();

View File

@ -228,7 +228,7 @@ namespace BizHawk.Client.EmuHawk
{
LoadToPanel(NormalControlsTab, _emulator.ControllerDefinition.Name, _emulator.ControllerDefinition.BoolButtons, _emulator.ControllerDefinition.CategoryLabels, normal, "", CreateNormalPanel);
LoadToPanel(AutofireControlsTab, _emulator.ControllerDefinition.Name, _emulator.ControllerDefinition.BoolButtons, _emulator.ControllerDefinition.CategoryLabels, autofire, "", CreateNormalPanel);
LoadToPanel(AnalogControlsTab, _emulator.ControllerDefinition.Name, _emulator.ControllerDefinition.FloatControls, _emulator.ControllerDefinition.CategoryLabels, analog, new AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
LoadToPanel(AnalogControlsTab, _emulator.ControllerDefinition.Name, _emulator.ControllerDefinition.AxisControls, _emulator.ControllerDefinition.CategoryLabels, analog, new AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
if (AnalogControlsTab.Controls.Count == 0)
{

View File

@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk
private void Timer1_Tick(object sender, EventArgs e)
{
string bindValue = Input.Instance.GetNextFloatEvent();
string bindValue = Input.Instance.GetNextAxisEvent();
if (bindValue != null)
{
timer1.Stop();
@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk
_bind.Value = bindValue;
textBox1.Text = Bind.Value;
buttonBind.Text = "Bind!";
Input.Instance.StopListeningForFloatEvents();
Input.Instance.StopListeningForAxisEvents();
}
}
@ -52,11 +52,11 @@ namespace BizHawk.Client.EmuHawk
timer1.Stop();
_listening = false;
buttonBind.Text = "Bind!";
Input.Instance.StopListeningForFloatEvents();
Input.Instance.StopListeningForAxisEvents();
}
else
{
Input.Instance.StartListeningForFloatEvents();
Input.Instance.StartListeningForAxisEvents();
_listening = true;
buttonBind.Text = "Cancel!";
timer1.Start();

View File

@ -387,9 +387,9 @@ namespace BizHawk.Client.EmuHawk
table[button] = adapter.IsPressed(button);
}
foreach (var button in adapter.Definition.FloatControls)
foreach (var button in adapter.Definition.AxisControls)
{
table[button] = adapter.GetFloat(button);
table[button] = adapter.AxisValue(button);
}
}
}

View File

@ -11,18 +11,18 @@ namespace BizHawk.Client.EmuHawk
private void SetUpButtonBoxes()
{
var def = Emulator.ControllerDefinition;
int count = def.BoolButtons.Count + def.FloatControls.Count;
int count = def.BoolButtons.Count + def.AxisControls.Count;
_buttonBoxes = new CheckBox[count];
for (int i = 0; i < def.FloatControls.Count; i++)
for (int i = 0; i < def.AxisControls.Count; i++)
{
var box = new CheckBox { Text = def.FloatControls[i] };
var box = new CheckBox { Text = def.AxisControls[i] };
_buttonBoxes[i] = box;
}
for (int i = 0; i < def.BoolButtons.Count; i++)
{
var box = new CheckBox { Text = def.BoolButtons[i] };
_buttonBoxes[i + def.FloatControls.Count] = box;
_buttonBoxes[i + def.AxisControls.Count] = box;
}
foreach (var box in _buttonBoxes)

View File

@ -48,9 +48,9 @@ namespace BizHawk.Client.EmuHawk
}
else
{
d.FloatControls.Add(k);
int rangeIndex = _emulator.ControllerDefinition.FloatControls.IndexOf(k);
d.FloatRanges.Add(_emulator.ControllerDefinition.FloatRanges[rangeIndex]);
d.AxisControls.Add(k);
int rangeIndex = _emulator.ControllerDefinition.AxisControls.IndexOf(k);
d.AxisRanges.Add(_emulator.ControllerDefinition.AxisRanges[rangeIndex]);
}
}
@ -104,7 +104,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
d.FloatControls.Add(key);
d.AxisControls.Add(key);
}
}
@ -270,7 +270,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
d.FloatControls.Add(k);
d.AxisControls.Add(k);
}
}
@ -286,9 +286,9 @@ namespace BizHawk.Client.EmuHawk
latching[button] = source.IsPressed(button);
}
foreach (string name in source.Definition.FloatControls)
foreach (string name in source.Definition.AxisControls)
{
latching.SetFloat(name, source.GetFloat(name));
latching.SetAxis(name, source.AxisValue(name));
}
}
@ -299,13 +299,13 @@ namespace BizHawk.Client.EmuHawk
latching[button] |= source.IsPressed(button);
}
foreach (string name in latching.Definition.FloatControls)
foreach (string name in latching.Definition.AxisControls)
{
float sFloat = source.GetFloat(name);
int indexRange = source.Definition.FloatControls.IndexOf(name);
if (sFloat == source.Definition.FloatRanges[indexRange].Mid)
float sFloat = source.AxisValue(name);
int indexRange = source.Definition.AxisControls.IndexOf(name);
if (sFloat == source.Definition.AxisRanges[indexRange].Mid)
{
latching.SetFloat(name, sFloat);
latching.SetAxis(name, sFloat);
}
}
}

View File

@ -388,7 +388,7 @@ namespace BizHawk.Client.EmuHawk
public void LoadBranchExternal(int slot = -1)
{
if (Tastudio.FloatEditingMode)
if (Tastudio.AxisEditingMode)
{
return;
}
@ -411,7 +411,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateBranchExternal(int slot = -1)
{
if (Tastudio.FloatEditingMode)
if (Tastudio.AxisEditingMode)
{
return;
}
@ -440,7 +440,7 @@ namespace BizHawk.Client.EmuHawk
public void SelectBranchExternal(int slot)
{
if (Tastudio.FloatEditingMode)
if (Tastudio.AxisEditingMode)
{
return;
}

View File

@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
ButtonBox.Items.Add(button);
}
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.FloatControls)
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.AxisControls)
{
ButtonBox.Items.Add(button);
}
@ -202,7 +202,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.AxisControls.IndexOf(SelectedButton);
}
LagBox.Checked = _tastudio.FloatPatterns[index].SkipsLag;
@ -248,7 +248,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.AxisControls.IndexOf(SelectedButton);
}
List<float> p = new List<float>();
@ -310,7 +310,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.AxisControls.IndexOf(SelectedButton);
}
float[] p = _tastudio.FloatPatterns[index].Pattern;

View File

@ -17,8 +17,8 @@ namespace BizHawk.Client.EmuHawk
private string _startBoolDrawColumn = "";
private string _startFloatDrawColumn = "";
private bool _boolPaintState;
private float _floatPaintState;
private float _floatBackupState;
private float _axisPaintState;
private float _axisBackupState;
private bool _patternPaint;
private bool _startCursorDrag;
private bool _startSelectionDrag;
@ -28,22 +28,22 @@ namespace BizHawk.Client.EmuHawk
private int _paintingMinFrame = -1;
// Editing analog input
private string _floatEditColumn = "";
private int _floatEditRow = -1;
private string _floatTypedValue;
private int _floatEditYPos = -1;
private int FloatEditRow
private string _axisEditColumn = "";
private int _axisEditRow = -1;
private string _axisTypedValue;
private int _axisEditYPos = -1;
private int AxisEditRow
{
set
{
_floatEditRow = value;
TasView.SuspendHotkeys = FloatEditingMode;
_axisEditRow = value;
TasView.SuspendHotkeys = AxisEditingMode;
}
}
public bool FloatEditingMode => _floatEditRow != -1;
public bool AxisEditingMode => _axisEditRow != -1;
private readonly List<int> _extraFloatRows = new List<int>();
private readonly List<int> _extraAxisRows = new List<int>();
// Right-click dragging
private string[] _rightClickInput;
@ -246,9 +246,9 @@ namespace BizHawk.Client.EmuHawk
color = Color.FromArgb(0x60, 0xFF, 0xFF, 0xFF);
}
}
else if (FloatEditingMode
&& (index == _floatEditRow || _extraFloatRows.Contains(index))
&& columnName == _floatEditColumn)
else if (AxisEditingMode
&& (index == _axisEditRow || _extraAxisRows.Contains(index))
&& columnName == _axisEditColumn)
{
color = AnalogEdit_Col;
}
@ -329,9 +329,9 @@ namespace BizHawk.Client.EmuHawk
else
{
// Display typed float value (string "-" can't be parsed, so CurrentTasMovie.DisplayValue can't return it)
if (index == _floatEditRow && columnName == _floatEditColumn)
if (index == _axisEditRow && columnName == _axisEditColumn)
{
text = _floatTypedValue;
text = _axisTypedValue;
}
else if (index < CurrentTasMovie.InputLogLength)
{
@ -339,8 +339,8 @@ namespace BizHawk.Client.EmuHawk
if (column.Type == ColumnType.Float)
{
// feos: this could be cached, but I don't notice any slowdown this way either
ControllerDefinition.AxisRange range = ControllerType.FloatRanges
[ControllerType.FloatControls.IndexOf(columnName)];
ControllerDefinition.AxisRange range = ControllerType.AxisRanges
[ControllerType.AxisControls.IndexOf(columnName)];
if (text == ((float) range.Mid).ToString())
{
text = "";
@ -411,7 +411,7 @@ namespace BizHawk.Client.EmuHawk
else
{
// feos: there's no default value other than mid, and we can't go arbitrary here, so do nothing for now
// autohold is ignored for float input too for the same reasons: lack of demand + ambiguity
// autohold is ignored for axes too for the same reasons: lack of demand + ambiguity
}
_triggerAutoRestore = true;
@ -475,11 +475,11 @@ namespace BizHawk.Client.EmuHawk
{
if (index == 0)
{
index = ControllerType.FloatControls.IndexOf(button);
index = ControllerType.AxisControls.IndexOf(button);
}
else
{
index += ControllerType.FloatControls.Count - 1;
index += ControllerType.AxisControls.Count - 1;
}
float? value = null;
@ -489,7 +489,7 @@ namespace BizHawk.Client.EmuHawk
}
AutoPatternFloat p = FloatPatterns[index];
Global.InputManager.AutofireStickyXorAdapter.SetFloat(button, value, p);
Global.InputManager.AutofireStickyXorAdapter.SetAxis(button, value, p);
}
}
@ -550,35 +550,35 @@ namespace BizHawk.Client.EmuHawk
_leftButtonHeld = true;
_paintingMinFrame = frame;
// SuuperW: Exit float editing mode, or re-enter mouse editing
if (FloatEditingMode)
// SuuperW: Exit axis editing mode, or re-enter mouse editing
if (AxisEditingMode)
{
if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)
{
_extraFloatRows.Clear();
_extraFloatRows.AddRange(TasView.SelectedRows);
_extraAxisRows.Clear();
_extraAxisRows.AddRange(TasView.SelectedRows);
_startSelectionDrag = true;
_selectionDragState = TasView.SelectedRows.Contains(frame);
return;
}
if (_floatEditColumn != buttonName
|| !(_floatEditRow == frame || _extraFloatRows.Contains(frame)))
if (_axisEditColumn != buttonName
|| !(_axisEditRow == frame || _extraAxisRows.Contains(frame)))
{
_extraFloatRows.Clear();
FloatEditRow = -1;
_extraAxisRows.Clear();
AxisEditRow = -1;
RefreshTasView();
}
else
{
if (_extraFloatRows.Contains(frame))
if (_extraAxisRows.Contains(frame))
{
_extraFloatRows.Clear();
FloatEditRow = frame;
_extraAxisRows.Clear();
AxisEditRow = frame;
RefreshTasView();
}
_floatEditYPos = e.Y;
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
_axisEditYPos = e.Y;
_axisPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
_triggerAutoRestore = true;
JumpToGreenzone();
@ -674,12 +674,12 @@ namespace BizHawk.Client.EmuHawk
JumpToGreenzone();
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
_axisPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
if (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked
|| TasView.CurrentCell.Column.Emphasis))
{
FloatPatterns[ControllerType.FloatControls.IndexOf(buttonName)].Reset();
CurrentTasMovie.SetFloatState(frame, buttonName, FloatPatterns[ControllerType.FloatControls.IndexOf(buttonName)].GetNextValue());
FloatPatterns[ControllerType.AxisControls.IndexOf(buttonName)].Reset();
CurrentTasMovie.SetFloatState(frame, buttonName, FloatPatterns[ControllerType.AxisControls.IndexOf(buttonName)].GetNextValue());
_patternPaint = true;
}
else
@ -693,20 +693,20 @@ namespace BizHawk.Client.EmuHawk
CurrentTasMovie.ChangeLog.BeginNewBatch($"Paint Float {buttonName} from frame {frame}");
_startFloatDrawColumn = buttonName;
}
else // Double-click enters float editing mode
else // Double-click enters axis editing mode
{
if (_floatEditColumn == buttonName && _floatEditRow == frame)
if (_axisEditColumn == buttonName && _axisEditRow == frame)
{
FloatEditRow = -1;
AxisEditRow = -1;
}
else
{
CurrentTasMovie.ChangeLog.BeginNewBatch($"Float Edit: {frame}");
_floatEditColumn = buttonName;
FloatEditRow = frame;
_floatTypedValue = "";
_floatEditYPos = e.Y;
_floatBackupState = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn);
_axisEditColumn = buttonName;
AxisEditRow = frame;
_axisTypedValue = "";
_axisEditYPos = e.Y;
_axisBackupState = CurrentTasMovie.GetFloatState(_axisEditRow, _axisEditColumn);
}
RefreshDialog();
@ -791,20 +791,20 @@ namespace BizHawk.Client.EmuHawk
_paintingMinFrame = -1;
TasView.ReleaseCurrentCell();
// Exit float editing if value was changed with cursor
if (FloatEditingMode && _floatPaintState != CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn))
// Exit axis editing if value was changed with cursor
if (AxisEditingMode && _axisPaintState != CurrentTasMovie.GetFloatState(_axisEditRow, _axisEditColumn))
{
FloatEditRow = -1;
AxisEditRow = -1;
_triggerAutoRestore = true;
JumpToGreenzone();
DoTriggeredAutoRestoreIfNeeded();
RefreshDialog();
}
_floatPaintState = 0;
_floatEditYPos = -1;
_axisPaintState = 0;
_axisEditYPos = -1;
_leftButtonHeld = false;
if (!FloatEditingMode)
if (!AxisEditingMode)
{
CurrentTasMovie.ChangeLog?.EndBatch();
}
@ -830,7 +830,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (e.Button == MouseButtons.Left)
{
if (FloatEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
if (AxisEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
{
_leftButtonHeld = false;
_startSelectionDrag = false;
@ -912,7 +912,7 @@ namespace BizHawk.Client.EmuHawk
{
if (TasView.CurrentCell.RowIndex.HasValue &&
TasView.CurrentCell.Column.Name == FrameColumnName &&
!FloatEditingMode)
!AxisEditingMode)
{
var existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == TasView.CurrentCell.RowIndex.Value);
@ -992,15 +992,15 @@ namespace BizHawk.Client.EmuHawk
for (var i = startVal; i <= endVal; i++)
{
TasView.SelectRow(i, _selectionDragState);
if (FloatEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
if (AxisEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift))
{
if (_selectionDragState)
{
_extraFloatRows.Add(i);
_extraAxisRows.Add(i);
}
else
{
_extraFloatRows.Remove(i);
_extraAxisRows.Remove(i);
}
}
}
@ -1152,7 +1152,7 @@ namespace BizHawk.Client.EmuHawk
for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down)
{
float setVal = _floatPaintState;
float setVal = _axisPaintState;
if (_patternPaint)
{
if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value)
@ -1161,7 +1161,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
setVal = FloatPatterns[ControllerType.FloatControls.IndexOf(_startFloatDrawColumn)].GetNextValue();
setVal = FloatPatterns[ControllerType.AxisControls.IndexOf(_startFloatDrawColumn)].GetNextValue();
}
}
@ -1182,18 +1182,18 @@ namespace BizHawk.Client.EmuHawk
private void TasView_MouseMove(object sender, MouseEventArgs e)
{
// For float editing
if (FloatEditingMode)
// For axis editing
if (AxisEditingMode)
{
int increment = (_floatEditYPos - e.Y) / 4;
if (_floatEditYPos == -1)
int increment = (_axisEditYPos - e.Y) / 4;
if (_axisEditYPos == -1)
{
return;
}
var value = (_floatPaintState + increment).ConstrainWithin(ControllerType.FloatRanges[ControllerType.FloatControls.IndexOf(_floatEditColumn)].FloatRange);
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
_floatTypedValue = value.ToString();
var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.AxisRanges[ControllerType.AxisControls.IndexOf(_axisEditColumn)].FloatRange);
CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, value);
_axisTypedValue = value.ToString();
JumpToGreenzone();
RefreshDialog();
@ -1207,7 +1207,7 @@ namespace BizHawk.Client.EmuHawk
public void AnalogIncrementByOne()
{
if (FloatEditingMode)
if (AxisEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Up));
}
@ -1215,7 +1215,7 @@ namespace BizHawk.Client.EmuHawk
public void AnalogDecrementByOne()
{
if (FloatEditingMode)
if (AxisEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Down));
}
@ -1223,7 +1223,7 @@ namespace BizHawk.Client.EmuHawk
public void AnalogIncrementByTen()
{
if (FloatEditingMode)
if (AxisEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Up | Keys.Shift));
}
@ -1231,7 +1231,7 @@ namespace BizHawk.Client.EmuHawk
public void AnalogDecrementByTen()
{
if (FloatEditingMode)
if (AxisEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Down | Keys.Shift));
}
@ -1239,7 +1239,7 @@ namespace BizHawk.Client.EmuHawk
public void AnalogMax()
{
if (FloatEditingMode)
if (AxisEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Right));
}
@ -1247,7 +1247,7 @@ namespace BizHawk.Client.EmuHawk
public void AnalogMin()
{
if (FloatEditingMode)
if (AxisEditingMode)
{
EditAnalogProgrammatically(new KeyEventArgs(Keys.Left));
}
@ -1255,25 +1255,25 @@ namespace BizHawk.Client.EmuHawk
public void EditAnalogProgrammatically(KeyEventArgs e)
{
if (!FloatEditingMode)
if (!AxisEditingMode)
{
return;
}
float value = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn);
float value = CurrentTasMovie.GetFloatState(_axisEditRow, _axisEditColumn);
float prev = value;
string prevTyped = _floatTypedValue;
string prevTyped = _axisTypedValue;
var range = ControllerType.FloatRanges[ControllerType.FloatControls.IndexOf(_floatEditColumn)];
var range = ControllerType.AxisRanges[ControllerType.AxisControls.IndexOf(_axisEditColumn)];
var (rMin, rMax) = range.FloatRange;
// feos: typing past max digits overwrites existing value, not touching the sign
// but doesn't handle situations where the range is like -50 through 100, where minimum is negative and has less digits
// it just uses 3 as maxDigits there too, leaving room for typing impossible values (that are still ignored by the game and then clamped)
int maxDigits = range.MaxDigits;
int curDigits = _floatTypedValue.Length;
int curDigits = _axisTypedValue.Length;
string curMinus;
if (_floatTypedValue.StartsWith("-"))
if (_axisTypedValue.StartsWith("-"))
{
curDigits -= 1;
curMinus = "-";
@ -1286,79 +1286,79 @@ namespace BizHawk.Client.EmuHawk
if (e.KeyCode == Keys.Right)
{
value = rMax;
_floatTypedValue = value.ToString();
_axisTypedValue = value.ToString();
}
else if (e.KeyCode == Keys.Left)
{
value = rMin;
_floatTypedValue = value.ToString();
_axisTypedValue = value.ToString();
}
else if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
{
if (curDigits >= maxDigits)
{
_floatTypedValue = curMinus;
_axisTypedValue = curMinus;
}
_floatTypedValue += e.KeyCode - Keys.D0;
_axisTypedValue += e.KeyCode - Keys.D0;
}
else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
{
if (curDigits >= maxDigits)
{
_floatTypedValue = curMinus;
_axisTypedValue = curMinus;
}
_floatTypedValue += e.KeyCode - Keys.NumPad0;
_axisTypedValue += e.KeyCode - Keys.NumPad0;
}
else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract)
{
_floatTypedValue = _floatTypedValue.StartsWith("-")
? _floatTypedValue.Substring(1)
: $"-{_floatTypedValue}";
_axisTypedValue = _axisTypedValue.StartsWith("-")
? _axisTypedValue.Substring(1)
: $"-{_axisTypedValue}";
}
else if (e.KeyCode == Keys.Back)
{
if (_floatTypedValue == "") // Very first key press is backspace?
if (_axisTypedValue == "") // Very first key press is backspace?
{
_floatTypedValue = value.ToString();
_axisTypedValue = value.ToString();
}
_floatTypedValue = _floatTypedValue.Substring(0, _floatTypedValue.Length - 1);
if (_floatTypedValue == "" || _floatTypedValue == "-")
_axisTypedValue = _axisTypedValue.Substring(0, _axisTypedValue.Length - 1);
if (_axisTypedValue == "" || _axisTypedValue == "-")
{
value = 0f;
}
else
{
value = Convert.ToSingle(_floatTypedValue);
value = Convert.ToSingle(_axisTypedValue);
}
}
else if (e.KeyCode == Keys.Enter)
{
_floatEditYPos = -1;
FloatEditRow = -1;
_axisEditYPos = -1;
AxisEditRow = -1;
}
else if (e.KeyCode == Keys.Escape)
{
_floatEditYPos = -1;
_axisEditYPos = -1;
if (_floatBackupState != _floatPaintState)
if (_axisBackupState != _axisPaintState)
{
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, _floatBackupState);
_triggerAutoRestore = Emulator.Frame > _floatEditRow;
CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, _axisBackupState);
_triggerAutoRestore = Emulator.Frame > _axisEditRow;
JumpToGreenzone();
DoTriggeredAutoRestoreIfNeeded();
}
FloatEditRow = -1;
AxisEditRow = -1;
}
else
{
float changeBy = 0;
if (e.KeyCode == Keys.Up)
{
changeBy = 1; // We're assuming for now that ALL float controls should contain integers.
changeBy = 1; // We're assuming for now that ALL axis controls should contain integers.
}
else if (e.KeyCode == Keys.Down)
{
@ -1373,27 +1373,27 @@ namespace BizHawk.Client.EmuHawk
value += changeBy;
if (changeBy != 0)
{
_floatTypedValue = value.ToString();
_axisTypedValue = value.ToString();
}
}
if (!FloatEditingMode)
if (!AxisEditingMode)
{
CurrentTasMovie.ChangeLog.EndBatch();
}
else
{
if (_floatTypedValue == "")
if (_axisTypedValue == "")
{
if (prevTyped != "")
{
value = 0f;
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, value);
}
}
else
{
if (float.TryParse(_floatTypedValue, out value)) // String "-" can't be parsed.
if (float.TryParse(_axisTypedValue, out value)) // String "-" can't be parsed.
{
if (value > rMax)
{
@ -1404,22 +1404,22 @@ namespace BizHawk.Client.EmuHawk
value = rMin;
}
_floatTypedValue = value.ToString();
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
_axisTypedValue = value.ToString();
CurrentTasMovie.SetFloatState(_axisEditRow, _axisEditColumn, value);
}
}
if (_extraFloatRows.Any())
if (_extraAxisRows.Any())
{
foreach (int row in _extraFloatRows)
foreach (int row in _extraAxisRows)
{
CurrentTasMovie.SetFloatState(row, _floatEditColumn, value);
CurrentTasMovie.SetFloatState(row, _axisEditColumn, value);
}
}
if (value != prev) // Auto-restore
{
_triggerAutoRestore = Emulator.Frame > _floatEditRow;
_triggerAutoRestore = Emulator.Frame > _axisEditRow;
JumpToGreenzone();
DoTriggeredAutoRestoreIfNeeded();
}
@ -1448,7 +1448,7 @@ namespace BizHawk.Client.EmuHawk
GoToFrame(CurrentTasMovie.InputLogLength-1);
}
if (FloatEditingMode
if (AxisEditingMode
&& e.KeyCode != Keys.Right
&& e.KeyCode != Keys.Left
&& e.KeyCode != Keys.Up

View File

@ -426,10 +426,10 @@ namespace BizHawk.Client.EmuHawk
{
ColumnType type;
int digits;
if (ControllerType.FloatControls.Contains(kvp.Key))
if (ControllerType.AxisControls.Contains(kvp.Key))
{
ControllerDefinition.AxisRange range = ControllerType.FloatRanges
[ControllerType.FloatControls.IndexOf(kvp.Key)];
ControllerDefinition.AxisRange range = ControllerType.AxisRanges
[ControllerType.AxisControls.IndexOf(kvp.Key)];
type = ColumnType.Float;
digits = Math.Max(kvp.Value.Length, range.MaxDigits);
}
@ -488,14 +488,14 @@ namespace BizHawk.Client.EmuHawk
if (BoolPatterns == null)
{
BoolPatterns = new AutoPatternBool[ControllerType.BoolButtons.Count + 2];
FloatPatterns = new AutoPatternFloat[ControllerType.FloatControls.Count + 2];
FloatPatterns = new AutoPatternFloat[ControllerType.AxisControls.Count + 2];
}
else
{
bStart = BoolPatterns.Length - 2;
fStart = FloatPatterns.Length - 2;
Array.Resize(ref BoolPatterns, ControllerType.BoolButtons.Count + 2);
Array.Resize(ref FloatPatterns, ControllerType.FloatControls.Count + 2);
Array.Resize(ref FloatPatterns, ControllerType.AxisControls.Count + 2);
}
for (int i = bStart; i < BoolPatterns.Length - 2; i++)

View File

@ -35,9 +35,9 @@ namespace BizHawk.Client.EmuHawk
Global.InputManager.ButtonOverrideAdapter.SetButton(button, lg.IsPressed(button));
}
foreach (var floatButton in lg.Definition.FloatControls)
foreach (var floatButton in lg.Definition.AxisControls)
{
Global.InputManager.ButtonOverrideAdapter.SetFloat(floatButton, lg.GetFloat(floatButton));
Global.InputManager.ButtonOverrideAdapter.SetAxis(floatButton, lg.AxisValue(floatButton));
}
return lg;

View File

@ -104,7 +104,7 @@ namespace BizHawk.Client.EmuHawk
RangeY = button.MaxValue // TODO: ability to have a different Y than X
});
break;
case PadInputType.SingleFloat:
case PadInputType.SingleAxis:
PadBox.Controls.Add(new VirtualPadAnalogButton
{
Name = button.Name,

View File

@ -119,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
private void CheckPads(IEnumerable<PadSchema> schemas, ControllerDefinition def)
{
var analogs = new HashSet<string>(def.FloatControls);
var analogs = new HashSet<string>(def.AxisControls);
var bools = new HashSet<string>(def.BoolButtons);
foreach (var schema in schemas)
@ -130,7 +130,7 @@ namespace BizHawk.Client.EmuHawk
switch (button.Type)
{
case PadInputType.AnalogStick:
case PadInputType.SingleFloat:
case PadInputType.SingleAxis:
case PadInputType.TargetedPair:
// analog
searchSet = analogs;

View File

@ -34,7 +34,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues()
{
if (AnalogTrackBar.Value != (int)Global.InputManager.StickyXorAdapter.GetFloat(Name))
if (AnalogTrackBar.Value != (int)Global.InputManager.StickyXorAdapter.AxisValue(Name))
{
RefreshWidgets();
}
@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk
public void Set(IController controller)
{
var newVal = (int)controller.GetFloat(Name);
var newVal = (int)controller.AxisValue(Name);
var changed = AnalogTrackBar.Value != newVal;
if (changed)
{
@ -217,7 +217,7 @@ namespace BizHawk.Client.EmuHawk
if (!_programmaticallyChangingValue)
{
CurrentValue = AnalogTrackBar.Value;
Global.InputManager.StickyXorAdapter.SetFloat(Name, AnalogTrackBar.Value);
Global.InputManager.StickyXorAdapter.SetAxis(Name, AnalogTrackBar.Value);
}
}
@ -226,7 +226,7 @@ namespace BizHawk.Client.EmuHawk
if (!_isSet)
{
_programmaticallyChangingValue = true;
AnalogTrackBar.Value = (int)Global.InputManager.StickyXorAdapter.GetFloat(Name);
AnalogTrackBar.Value = (int)Global.InputManager.StickyXorAdapter.AxisValue(Name);
ValueLabel.Text = AnalogTrackBar.Value.ToString();
_programmaticallyChangingValue = false;
}

View File

@ -127,7 +127,7 @@ namespace BizHawk.Client.EmuHawk
public void Set(IController controller)
{
//controller.GetFloat("Disc Select")
//controller.AxisValue("Disc Select")
}
public bool ReadOnly { get; set; }
@ -137,7 +137,7 @@ namespace BizHawk.Client.EmuHawk
private void lvDiscs_SelectedIndexChanged(object sender, EventArgs e)
{
// emergency measure: if no selection, set no disc
Global.InputManager.StickyXorAdapter.SetFloat(_discSelectName, lvDiscs.SelectedIndices.Count == 0 ? 0 : lvDiscs.SelectedIndices[0]);
Global.InputManager.StickyXorAdapter.SetAxis(_discSelectName, lvDiscs.SelectedIndices.Count == 0 ? 0 : lvDiscs.SelectedIndices[0]);
}
private void btnClose_Click(object sender, EventArgs e)

View File

@ -51,8 +51,8 @@ namespace BizHawk.Client.EmuHawk
public void Set(IController controller)
{
var newX = controller.GetFloat(XName) / MultiplierX;
var newY = controller.GetFloat(YName) / MultiplierY;
var newX = controller.AxisValue(XName) / MultiplierX;
var newY = controller.AxisValue(YName) / MultiplierY;
var oldX = X / MultiplierX;
var oldY = Y / MultiplierY;
@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk
public int X
{
get => _overrideX ?? (int)(Global.InputManager.StickyXorAdapter.GetFloat(XName) / MultiplierX);
get => _overrideX ?? (int)(Global.InputManager.StickyXorAdapter.AxisValue(XName) / MultiplierX);
set
{
if (value < 0)
@ -181,13 +181,13 @@ namespace BizHawk.Client.EmuHawk
XNumeric.Value = XNumeric.Maximum;
}
Global.InputManager.StickyXorAdapter.SetFloat(XName, (int)((float)XNumeric.Value * MultiplierX));
Global.InputManager.StickyXorAdapter.SetAxis(XName, (int)((float)XNumeric.Value * MultiplierX));
_isSet = true;
}
}
public int Y
{
get => _overrideY ?? (int)(Global.InputManager.StickyXorAdapter.GetFloat(YName) / MultiplierY);
get => _overrideY ?? (int)(Global.InputManager.StickyXorAdapter.AxisValue(YName) / MultiplierY);
set
{
if (value < 0)
@ -203,7 +203,7 @@ namespace BizHawk.Client.EmuHawk
YNumeric.Value = YNumeric.Maximum;
}
Global.InputManager.StickyXorAdapter.SetFloat(YName, (int)((float)YNumeric.Value * MultiplierY));
Global.InputManager.StickyXorAdapter.SetAxis(YName, (int)((float)YNumeric.Value * MultiplierY));
_isSet = true;
}
}

View File

@ -164,8 +164,8 @@ namespace BizHawk.Client.EmuHawk
private void SetAnalog()
{
Global.InputManager.StickyXorAdapter.SetFloat(XName, HasValue ? X : (int?)null);
Global.InputManager.StickyXorAdapter.SetFloat(YName, HasValue ? Y : (int?)null);
Global.InputManager.StickyXorAdapter.SetAxis(XName, HasValue ? X : (int?)null);
Global.InputManager.StickyXorAdapter.SetAxis(YName, HasValue ? Y : (int?)null);
Refresh();
}
@ -185,8 +185,8 @@ namespace BizHawk.Client.EmuHawk
// Previous frame
if (_previous != null)
{
var pX = (int)_previous.GetFloat(XName);
var pY = (int)_previous.GetFloat(YName);
var pX = (int)_previous.AxisValue(XName);
var pY = (int)_previous.AxisValue(YName);
e.Graphics.DrawLine(_grayPen, PixelMidX, PixelMidY, RealToGfxX(pX), RealToGfxY(pY));
e.Graphics.DrawImage(_grayDot, RealToGfxX(pX) - 3, RealToGfxY(_rangeY.EndInclusive) - RealToGfxY(pY) - 3);
}
@ -262,8 +262,8 @@ namespace BizHawk.Client.EmuHawk
public void Set(IController controller)
{
var newX = (int) controller.GetFloat(XName);
var newY = (int) controller.GetFloat(YName);
var newX = (int) controller.AxisValue(XName);
var newY = (int) controller.AxisValue(YName);
if (newX != X || newY != Y) SetPosition(newX, newY);
}

View File

@ -76,13 +76,13 @@ namespace BizHawk.Client.EmuHawk
{
DisplayName = "B2"
},
new SingleFloatSchema(55, 17, controller, "Paddle X 1")
new SingleAxisSchema(55, 17, controller, "Paddle X 1")
{
TargetSize = new Size(128, 69),
MaxValue = 127,
MinValue = -127
},
new SingleFloatSchema(193, 17, controller, "Paddle X 2")
new SingleAxisSchema(193, 17, controller, "Paddle X 2")
{
TargetSize = new Size(128, 69),
MaxValue = 127,
@ -123,13 +123,13 @@ namespace BizHawk.Client.EmuHawk
{
DisplayName = "B1"
},
new SingleFloatSchema(55, 17, controller, "Wheel X 1")
new SingleAxisSchema(55, 17, controller, "Wheel X 1")
{
TargetSize = new Size(128, 69),
MaxValue = 127,
MinValue = -127
},
new SingleFloatSchema(193, 17, controller, "Wheel X 2")
new SingleAxisSchema(193, 17, controller, "Wheel X 2")
{
TargetSize = new Size(128, 69),
MaxValue = 127,

View File

@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
{
Boolean, // A single on/off button
AnalogStick, // An analog stick X,Y Pair
SingleFloat, // A single analog button (pressure sensitive button for instance)
SingleAxis, // A single analog control (pressure sensitive button for instance)
TargetedPair, // A X,Y pair intended to be a screen coordinate (for zappers, mouse, stylus, etc)
DiscManager
}
@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
public int MinValueSec { get; set; }
public object OwnerEmulator { get; set; }
public Orientation Orientation { get; set; } // For Single Float controls
public Orientation Orientation { get; set; } // For SingleAxis controls
// for Analog Stick controls
public ControllerDefinition.AxisRange? AxisRange { get; set; }
@ -99,18 +99,18 @@ namespace BizHawk.Client.EmuHawk
};
}
public class SingleFloatSchema : ButtonSchema
public class SingleAxisSchema : ButtonSchema
{
public SingleFloatSchema(int x, int y, string name)
public SingleAxisSchema(int x, int y, string name)
: base(x, y, name)
{
Type = PadInputType.SingleFloat;
Type = PadInputType.SingleAxis;
}
public SingleFloatSchema(int x, int y, int controller, string name)
public SingleAxisSchema(int x, int y, int controller, string name)
: base(x, y, controller, name)
{
Type = PadInputType.SingleFloat;
Type = PadInputType.SingleAxis;
}
}

View File

@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk
private static PadSchema TurboController(int controller)
{
var controllerDefRanges = new ColecoTurboController(controller).Definition.FloatRanges;
var controllerDefRanges = new ColecoTurboController(controller).Definition.AxisRanges;
return new PadSchema
{
Size = new Size(275, 260),
@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(195, 260),
Buttons = StandardButtons(controller).Concat(new[]
{
new SingleFloatSchema(6, 200, controller, "Disc X")
new SingleAxisSchema(6, 200, controller, "Disc X")
{
DisplayName = "Disc",
TargetSize = new Size(180, 55),

View File

@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
Tilt(10, 15, "X"),
Tilt(10, 94, "Y"),
Tilt(10, 173, "Z"),
new SingleFloatSchema(10, 252, "Light Sensor")
new SingleAxisSchema(10, 252, "Light Sensor")
{
TargetSize = new Size(226, 69),
MaxValue = byte.MaxValue
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
}
private static ButtonSchema Tilt(int x, int y, string direction)
=> new SingleFloatSchema(x, y, "Tilt " + direction)
=> new SingleAxisSchema(x, y, "Tilt " + direction)
{
TargetSize = new Size(226, 69),
MinValue = short.MinValue,

View File

@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk
private static PadSchema AnalogController(int controller)
{
var controllerDefRanges = new FakeAnalogController(controller).Definition.FloatRanges;
var controllerDefRanges = new FakeAnalogController(controller).Definition.AxisRanges;
return new PadSchema
{
DisplayName = $"Player {controller}",

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
private static PadSchema StandardController(int controller)
{
var controllerDefRanges = N64Input.N64ControllerDefinition.FloatRanges;
var controllerDefRanges = N64Input.N64ControllerDefinition.AxisRanges;
return new PadSchema
{
Size = new Size(275, 316),

View File

@ -271,7 +271,7 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(380, 110),
Buttons = new[]
{
new SingleFloatSchema(14, 17, controller, "Paddle")
new SingleAxisSchema(14, 17, controller, "Paddle")
{
DisplayName = "Arkanoid Paddle",
TargetSize = new Size(380, 69),

View File

@ -161,27 +161,27 @@ namespace BizHawk.Client.EmuHawk
new ButtonSchema(278, 38, controller, "B"),
new ButtonSchema(308, 55, controller, "A"),
new ButtonSchema(308, 15, controller, "R"),
new SingleFloatSchema(5, 15, controller, "L")
new SingleAxisSchema(5, 15, controller, "L")
{
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
},
new SingleFloatSchema(125, 15, controller, "Twist")
new SingleAxisSchema(125, 15, controller, "Twist")
{
TargetSize = new Size(64, 178),
MinValue = 0,
MaxValue = 255,
Orientation = Orientation.Vertical
},
new SingleFloatSchema(180, 60, controller, "2")
new SingleAxisSchema(180, 60, controller, "2")
{
DisplayName = "II",
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
},
new SingleFloatSchema(220, 120, controller, "1")
new SingleAxisSchema(220, 120, controller, "1")
{
DisplayName = "I",
TargetSize = new Size(128, 55),

View File

@ -115,14 +115,14 @@ namespace BizHawk.Client.EmuHawk
AxisRange = axisRanges[0],
SecondaryAxisRange = axisRanges[1]
},
new SingleFloatSchema(8, 12, controller, "Left Shoulder")
new SingleAxisSchema(8, 12, controller, "Left Shoulder")
{
DisplayName = "L",
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
},
new SingleFloatSchema(328, 12, controller, "Right Shoulder")
new SingleAxisSchema(328, 12, controller, "Right Shoulder")
{
DisplayName = "R",
TargetSize = new Size(128, 55),
@ -170,7 +170,7 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(325, 100),
Buttons = new[]
{
new SingleFloatSchema(8, 12, controller, "Wheel")
new SingleAxisSchema(8, 12, controller, "Wheel")
{
TargetSize = new Size(128, 55),
MinValue = 0,
@ -213,7 +213,7 @@ namespace BizHawk.Client.EmuHawk
AxisRange = axisRanges[0],
SecondaryAxisRange = axisRanges[1]
},
new SingleFloatSchema(135, 13, controller, "Throttle")
new SingleAxisSchema(135, 13, controller, "Throttle")
{
TargetSize = new Size(64, 178),
MinValue = 0,
@ -239,7 +239,7 @@ namespace BizHawk.Client.EmuHawk
AxisRange = axisRanges[3],
SecondaryAxisRange = axisRanges[4]
},
new SingleFloatSchema(8, 13, controller, "Left Throttle")
new SingleAxisSchema(8, 13, controller, "Left Throttle")
{
DisplayName = "Throttle",
TargetSize = new Size(64, 178),
@ -253,7 +253,7 @@ namespace BizHawk.Client.EmuHawk
AxisRange = axisRanges[0],
SecondaryAxisRange = axisRanges[1]
},
new SingleFloatSchema(350, 13, controller, "Right Throttle")
new SingleAxisSchema(350, 13, controller, "Right Throttle")
{
DisplayName = "Throttle",
TargetSize = new Size(64, 178),

View File

@ -133,7 +133,7 @@ namespace BizHawk.Client.EmuHawk
private static PadSchema Mouse(int controller)
{
var controllerDefRanges = new SnesMouseController().Definition.FloatRanges;
var controllerDefRanges = new SnesMouseController().Definition.AxisRanges;
return new PadSchema
{
Size = new Size(345, 225),

View File

@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk
private static PadSchema AnalogController(int controller)
{
var controllerDefRanges = new AnalogControls(controller).Definition.FloatRanges;
var controllerDefRanges = new AnalogControls(controller).Definition.AxisRanges;
return new PadSchema
{
Size = new Size(280, 300),

View File

@ -22,8 +22,8 @@ namespace BizHawk.Emulation.Common
{
Name = source.Name;
BoolButtons.AddRange(source.BoolButtons);
FloatControls.AddRange(source.FloatControls);
FloatRanges.AddRange(source.FloatRanges);
AxisControls.AddRange(source.AxisControls);
AxisRanges.AddRange(source.AxisRanges);
AxisConstraints.AddRange(source.AxisConstraints);
CategoryLabels = source.CategoryLabels;
}
@ -41,13 +41,13 @@ namespace BizHawk.Emulation.Common
/// <summary>
/// Gets a list of all non-boolean types, that can be represented by a numerical value (such as analog controls, stylus coordinates, etc
/// </summary>
public List<string> FloatControls { get; } = new List<string>();
public List<string> AxisControls { get; } = new List<string>();
/// <summary>
/// Gets a list of all float ranges for each float control (must be one to one with FloatControls)
/// FloatRanges include the min/max/default values
/// Gets a list of all axis ranges for each axis control (must be one to one with AxisControls)
/// AxisRanges include the min/max/default values
/// </summary>
public List<AxisRange> FloatRanges { get; set; } = new List<AxisRange>();
public List<AxisRange> AxisRanges { get; set; } = new List<AxisRange>();
/// <summary>
/// Gets the axis constraints that apply artificial constraints to float values
@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Common
{
get
{
List<string> list = new List<string>(FloatControls);
List<string> list = new List<string>(AxisControls);
list.AddRange(BoolButtons);
// starts with console buttons, then each player's buttons individually
@ -201,7 +201,7 @@ namespace BizHawk.Emulation.Common
{
get
{
var allNames = FloatControls.Concat(BoolButtons).ToList();
var allNames = AxisControls.Concat(BoolButtons).ToList();
var player = allNames
.Select(PlayerNumber)
.DefaultIfEmpty(0)
@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Common
public bool Any()
{
return BoolButtons.Any() || FloatControls.Any();
return BoolButtons.Any() || AxisControls.Any();
}
}
}

View File

@ -17,7 +17,7 @@
return false;
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return 0f;
}

View File

@ -40,14 +40,14 @@ namespace BizHawk.Emulation.Common
remaps[s] = r;
}
foreach (string s in def.FloatControls)
foreach (string s in def.AxisControls)
{
string r = Allocate(s, ref plr, ref playerNext);
ret.FloatControls.Add(r);
ret.AxisControls.Add(r);
remaps[s] = r;
}
ret.FloatRanges.AddRange(def.FloatRanges);
ret.AxisRanges.AddRange(def.AxisRanges);
plr = playerNext;
unmergers.Add(new ControlDefUnMerger(remaps));
}
@ -84,9 +84,9 @@ namespace BizHawk.Emulation.Common
return _src.IsPressed(_remaps[button]);
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return _src.GetFloat(_remaps[name]);
return _src.AxisValue(_remaps[name]);
}
}

View File

@ -334,7 +334,7 @@ namespace BizHawk.Emulation.Common
/// </summary>
public static List<string> ToFloatControlNameList(this IController controller, int? controllerNum = null)
{
return ToControlNameList(controller.Definition.FloatControls, controllerNum);
return ToControlNameList(controller.Definition.AxisControls, controllerNum);
}
private static List<string> ToControlNameList(List<string> buttonList, int? controllerNum = null)
@ -371,16 +371,16 @@ namespace BizHawk.Emulation.Common
buttons[sub] = controller.IsPressed($"P{controllerNum} {sub}");
}
}
foreach (var button in controller.Definition.FloatControls)
foreach (var button in controller.Definition.AxisControls)
{
if (controllerNum == null)
{
buttons[button] = controller.GetFloat(button);
buttons[button] = controller.AxisValue(button);
}
else if (button.Length > 2 && button.Substring(0, 2) == $"P{controllerNum}")
{
var sub = button.Substring(3);
buttons[sub] = controller.GetFloat($"P{controllerNum} {sub}");
buttons[sub] = controller.AxisValue($"P{controllerNum} {sub}");
}
}

View File

@ -15,6 +15,6 @@
/// <summary>
/// Returns the state of a float control
/// </summary>
float GetFloat(string name);
float AxisValue(string name);
}
}

View File

@ -65,14 +65,14 @@ namespace BizHawk.Emulation.Common
_buttons.Add(k, source.IsPressed(k) ? 1.0f : 0);
}
foreach (var k in Definition.FloatControls)
foreach (var k in Definition.AxisControls)
{
if (_buttons.Keys.Contains(k))
{
throw new Exception("name collision between bool and float lists!");
}
_buttons.Add(k, source.GetFloat(k));
_buttons.Add(k, source.AxisValue(k));
}
}
@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Common
return _buttons[button] != 0;
}
public float GetFloat(string name)
public float AxisValue(string name)
{
return _buttons[name];
}

View File

@ -37,11 +37,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -120,8 +120,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
BoolButtons = BaseDefinition
.Select(b => $"P{PortNum} " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Paddle X 1" , "P" + PortNum + " Paddle X 2" },
FloatRanges = { new ControllerDefinition.AxisRange(-127, 0, 127), new ControllerDefinition.AxisRange(-127, 0, 127) }
AxisControls = { "P" + PortNum + " Paddle X 1" , "P" + PortNum + " Paddle X 2" },
AxisRanges = { new ControllerDefinition.AxisRange(-127, 0, 127), new ControllerDefinition.AxisRange(-127, 0, 127) }
};
}
@ -152,7 +152,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public int Read_Pot(IController c, int pot)
{
int x = (int)c.GetFloat(Definition.FloatControls[pot]);
int x = (int)c.AxisValue(Definition.AxisControls[pot]);
x = -x;
x += 127;
@ -237,8 +237,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
BoolButtons = BaseDefinition
.Select(b => $"P{PortNum} " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Wheel X 1", "P" + PortNum + " Wheel X 2" },
FloatRanges = { new ControllerDefinition.AxisRange(-127, 0, 127), new ControllerDefinition.AxisRange(-127, 0, 127) }
AxisControls = { "P" + PortNum + " Wheel X 1", "P" + PortNum + " Wheel X 2" },
AxisRanges = { new ControllerDefinition.AxisRange(-127, 0, 127), new ControllerDefinition.AxisRange(-127, 0, 127) }
};
}
@ -262,8 +262,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (c.IsPressed($"P{PortNum} Button")) { result &= 0xF7; }
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float x = c.AxisValue(Definition.AxisControls[0]);
float y = c.AxisValue(Definition.AxisControls[1]);
float angle = CalcDirection(x, y);

View File

@ -43,11 +43,11 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -275,8 +275,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
BoolButtons = BaseDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " X", "P" + PortNum + " Y" },
FloatRanges = { new ControllerDefinition.AxisRange(1, 160, 320), new ControllerDefinition.AxisRange(1, 121, 242) }
AxisControls = { "P" + PortNum + " X", "P" + PortNum + " Y" },
AxisRanges = { new ControllerDefinition.AxisRange(1, 160, 320), new ControllerDefinition.AxisRange(1, 121, 242) }
};
}
@ -315,8 +315,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public bool Is_LightGun(IController c, out float x, out float y)
{
x = c.GetFloat(Definition.FloatControls[0]);
y = c.GetFloat(Definition.FloatControls[1]);
x = c.AxisValue(Definition.AxisControls[0]);
y = c.AxisValue(Definition.AxisControls[1]);
return true;
}

View File

@ -61,11 +61,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic
{
"P1 Mouse Left", "P1 Mouse Right", "Power"
},
FloatControls =
AxisControls =
{
"P1 Mouse X", "P1 Mouse Y"
},
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
private static readonly string[] PadBits =
@ -121,8 +121,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic
var ret = new LibUzem.FrameInfo();
if (_mouseEnabled)
{
ret.ButtonsP1 = EncodeDelta(controller.GetFloat("P1 Mouse X")) << 24
| EncodeDelta(controller.GetFloat("P1 Mouse Y")) << 16
ret.ButtonsP1 = EncodeDelta(controller.AxisValue("P1 Mouse X")) << 24
| EncodeDelta(controller.AxisValue("P1 Mouse Y")) << 16
| 0x8000;
if (controller.IsPressed("P1 Mouse Left"))
ret.ButtonsP1 |= 0x200;

View File

@ -37,11 +37,11 @@ namespace BizHawk.Emulation.Cores.ColecoVision
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
}
public float wheel1;

View File

@ -135,8 +135,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
BoolButtons = BaseBoolDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
}
@ -152,8 +152,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
if (c.IsPressed(Definition.BoolButtons[0])) retVal &= 0x3F;
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float x = c.AxisValue(Definition.AxisControls[0]);
float y = c.AxisValue(Definition.AxisControls[1]);
var angle = updateWheel ? wheelAngle : CalcDirection(x, y);
@ -223,8 +223,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
public float UpdateWheel(IController c)
{
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float x = c.AxisValue(Definition.AxisControls[0]);
float y = c.AxisValue(Definition.AxisControls[1]);
return CalcDirection(x, y);
}
}
@ -240,8 +240,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
BoolButtons = BaseBoolDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
}
@ -260,8 +260,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
if (c.IsPressed(Definition.BoolButtons[3])) retVal &= 0xF7;
if (c.IsPressed(Definition.BoolButtons[4])) retVal &= 0x3F;
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float x = c.AxisValue(Definition.AxisControls[0]);
float y = c.AxisValue(Definition.AxisControls[1]);
var angle = updateWheel ? wheelAngle : CalcDirection(x, y);
@ -358,8 +358,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
public float UpdateWheel(IController c)
{
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float x = c.AxisValue(Definition.AxisControls[0]);
float y = c.AxisValue(Definition.AxisControls[1]);
return CalcDirection(x, y);
}
}

View File

@ -43,10 +43,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.GetFloat("P1 Stick X")) + 128));
joy1_UD = (byte)(Math.Floor(controller.GetFloat("P1 Stick Y")) + 128);
joy2_LR = (byte)(255 - (Math.Floor(controller.GetFloat("P2 Stick X")) + 128));
joy2_UD = (byte)(Math.Floor(controller.GetFloat("P2 Stick Y")) + 128);
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);
}
else
{

View File

@ -38,11 +38,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -81,8 +81,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
BoolButtons = BaseDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Stick X", "P" + PortNum + " Stick Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-128, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp)
AxisControls = { "P" + PortNum + " Stick X", "P" + PortNum + " Stick Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-128, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp)
};
}

View File

@ -38,11 +38,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -144,8 +144,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
BoolButtons = BaseBoolDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
}
@ -164,8 +164,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
}
}
int x = (int)c.GetFloat(Definition.FloatControls[0]);
int y = (int)c.GetFloat(Definition.FloatControls[1]);
int x = (int)c.AxisValue(Definition.AxisControls[0]);
int y = (int)c.AxisValue(Definition.AxisControls[1]);
result |= CalcDirection(x, y);
return result;

View File

@ -43,9 +43,9 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -139,16 +139,16 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX
private static readonly ControllerDefinition _definition = new ControllerDefinition
{
BoolButtons = { "0Mouse Left", "0Mouse Right" },
FloatControls = { "0X", "0Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisControls = { "0X", "0Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
public ControllerDefinition Definition => _definition;
public uint GetData(IController c)
{
var dx = (byte)(int)c.GetFloat("0X");
var dy = (byte)(int)c.GetFloat("0Y");
var dx = (byte)(int)c.AxisValue("0X");
var dy = (byte)(int)c.AxisValue("0Y");
uint ret = 0;
if (c.IsPressed("0Mouse Left"))
ret |= 0x10000;

View File

@ -13,12 +13,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
{
"Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power"
},
FloatControls =
AxisControls =
{
"Tilt X", "Tilt Y", "Tilt Z",
"Light Sensor"
},
FloatRanges =
AxisRanges =
{
TiltRange, TiltRange, TiltRange,
new ControllerDefinition.AxisRange(0, 100, 200),

View File

@ -119,10 +119,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
ref _nsamp,
rendersound ? _soundbuff : _dummysoundbuff,
RTCTime(),
(short)controller.GetFloat("Tilt X"),
(short)controller.GetFloat("Tilt Y"),
(short)controller.GetFloat("Tilt Z"),
(byte)(255 - controller.GetFloat("Light Sensor")));
(short)controller.AxisValue("Tilt X"),
(short)controller.AxisValue("Tilt Y"),
(short)controller.AxisValue("Tilt Z"),
(byte)(255 - controller.AxisValue("Light Sensor")));
if (IsLagFrame)
{

View File

@ -26,9 +26,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -117,8 +117,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
BoolButtons = BaseDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Tilt X", "P" + PortNum + " Tilt Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-45, 0, 45, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisControls = { "P" + PortNum + " Tilt X", "P" + PortNum + " Tilt Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-45, 0, 45, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
}
@ -175,8 +175,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
theta_prev = theta;
phi_prev = phi;
theta = (float)(c.GetFloat(Definition.FloatControls[1]) * Math.PI / 180.0);
phi = (float)(c.GetFloat(Definition.FloatControls[0]) * Math.PI / 180.0);
theta = (float)(c.AxisValue(Definition.AxisControls[1]) * Math.PI / 180.0);
phi = (float)(c.AxisValue(Definition.AxisControls[0]) * Math.PI / 180.0);
float temp = (float)(Math.Cos(theta) * Math.Sin(phi));

View File

@ -26,9 +26,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkNew
.ToList()
};
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
}
public byte ReadPort1(IController c)

View File

@ -117,8 +117,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkNew
BoolButtons = BaseDefinition
.Select(b => "P" + PortNum + " " + b)
.ToList(),
FloatControls = { "P" + PortNum + " Tilt X", "P" + PortNum + " Tilt Y" },
FloatRanges = ControllerDefinition.CreateAxisRangePair(-45, 0, 45, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisControls = { "P" + PortNum + " Tilt X", "P" + PortNum + " Tilt Y" },
AxisRanges = ControllerDefinition.CreateAxisRangePair(-45, 0, 45, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
}
@ -175,8 +175,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkNew
theta_prev = theta;
phi_prev = phi;
theta = (float)(c.GetFloat(Definition.FloatControls[1]) * Math.PI / 180.0);
phi = (float)(c.GetFloat(Definition.FloatControls[0]) * Math.PI / 180.0);
theta = (float)(c.AxisValue(Definition.AxisControls[1]) * Math.PI / 180.0);
phi = (float)(c.AxisValue(Definition.AxisControls[0]) * Math.PI / 180.0);
float temp = (float)(Math.Cos(theta) * Math.Sin(phi));

View File

@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
private void SetControllerButtons()
{
ControllerDefinition.BoolButtons.Clear();
ControllerDefinition.FloatControls.Clear();
ControllerDefinition.AxisControls.Clear();
ControllerDefinition.BoolButtons.AddRange(new[]
{
@ -64,7 +64,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
"P" + (i + 1) + " R",
});
ControllerDefinition.FloatControls.AddRange(new[]
ControllerDefinition.AxisControls.AddRange(new[]
{
"P" + (i + 1) + " X Axis",
"P" + (i + 1) + " Y Axis",

View File

@ -25,11 +25,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
"P1 A Up", "P1 A Down", "P1 A Left", "P1 A Right", "P1 DPad U", "P1 DPad D", "P1 DPad L", "P1 DPad R", "P1 Start", "P1 Z", "P1 B", "P1 A", "P1 C Up", "P1 C Down", "P1 C Right", "P1 C Left", "P1 L", "P1 R",
"Reset", "Power"
},
FloatControls =
AxisControls =
{
"P1 X Axis", "P1 Y Axis",
},
FloatRanges = AnalogStickRanges.Concat(AnalogStickRanges).Concat(AnalogStickRanges).Concat(AnalogStickRanges).ToList(), //TODO is this supposed to be duplicated? docs say FloatRanges.Count should equal FloatControls.Count --yoshi
AxisRanges = AnalogStickRanges.Concat(AnalogStickRanges).Concat(AnalogStickRanges).Concat(AnalogStickRanges).ToList(), //TODO is this supposed to be duplicated? docs say AxisRanges.Count should equal AxisControls.Count --yoshi
AxisConstraints =
{
new ControllerDefinition.AxisConstraint { Class = "Natural Circle", Type = ControllerDefinition.AxisConstraintType.Circular, Params = new object[] {"P1 X Axis", "P1 Y Axis", 127.0f} }
@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
}
else
{
x = (sbyte)Controller.GetFloat(p + " X Axis");
x = (sbyte)Controller.AxisValue(p + " X Axis");
}
sbyte y;
@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
}
else
{
y = (sbyte)Controller.GetFloat(p + " Y Axis");
y = (sbyte)Controller.AxisValue(p + " Y Axis");
}
int value = ReadController(i + 1);

View File

@ -38,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
| (controller.IsPressed("X") ? 0x400 : 0) | (controller.IsPressed("Y") ? 0x800 : 0)
| (controller.IsPressed("Touch") ? 0x2000 : 0)
| (controller.IsPressed("LidOpen") ? 0x4000 : 0) | (controller.IsPressed("LidClose") ? 0x8000 : 0);
FrameAdvance((short)buttons, (byte)controller.GetFloat("TouchX"), (byte)controller.GetFloat("TouchY"));
FrameAdvance((short)buttons, (byte)controller.AxisValue("TouchX"), (byte)controller.AxisValue("TouchY"));
_getNewBuffer = true;
return true;
}
@ -90,10 +90,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
ControllerDefinition.BoolButtons.Add("LidClose");
ControllerDefinition.BoolButtons.Add("Touch");
ControllerDefinition.FloatControls.Add("TouchX");
ControllerDefinition.FloatRanges.Add(new ControllerDefinition.AxisRange(0, 128, 255));
ControllerDefinition.FloatControls.Add("TouchY");
ControllerDefinition.FloatRanges.Add(new ControllerDefinition.AxisRange(0, 96, 191));
ControllerDefinition.AxisControls.Add("TouchX");
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 128, 255));
ControllerDefinition.AxisControls.Add("TouchY");
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 96, 191));
CoreComm = comm;
resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DEFAULT, 32768, 44100, 32768, 44100);

View File

@ -162,10 +162,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
// Add in the reset timing float control for subneshawk
if (using_reset_timing && ControllerDefinition.FloatControls.Count == 0)
if (using_reset_timing && ControllerDefinition.AxisControls.Count == 0)
{
ControllerDefinition.FloatControls.Add("Reset Cycle");
ControllerDefinition.FloatRanges.Add(new ControllerDefinition.AxisRange(0, 0, 500000));
ControllerDefinition.AxisControls.Add("Reset Cycle");
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 0, 500000));
}
// don't replace the magicSoundProvider on reset, as it's not needed

View File

@ -395,8 +395,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static ControllerDefinition Definition = new ControllerDefinition
{
BoolButtons = { "0Fire" },
FloatControls = { "0Paddle" },
FloatRanges = { NesDeck.ArkanoidPaddleRange }
AxisControls = { "0Paddle" },
AxisRanges = { NesDeck.ArkanoidPaddleRange }
};
public void Strobe(StrobeInfo s, IController c)
@ -406,7 +406,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
shiftidx = 0;
if (s.OUT0 > s.OUT0old)
{
latchedvalue = (byte)(0x54 + (int)c.GetFloat("0Paddle"));
latchedvalue = (byte)(0x54 + (int)c.AxisValue("0Paddle"));
latchedvalue ^= 0xff;
}
}
@ -560,8 +560,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static ControllerDefinition Definition = new ControllerDefinition
{
BoolButtons = { "0Fire" },
FloatControls = { "0Zapper X", "0Zapper Y" },
FloatRanges = NesDeck.ZapperRanges
AxisControls = { "0Zapper X", "0Zapper Y" },
AxisRanges = NesDeck.ZapperRanges
};
public void Strobe(StrobeInfo s, IController c)
@ -574,7 +574,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
byte ret = 0;
if (c.IsPressed("0Fire"))
ret |= 0x10;
if (!PPUCallback((int)c.GetFloat("0Zapper X"), (int)c.GetFloat("0Zapper Y")))
if (!PPUCallback((int)c.AxisValue("0Zapper X"), (int)c.AxisValue("0Zapper Y")))
ret |= 0x08;
return ret;
}
@ -613,8 +613,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static ControllerDefinition Definition = new ControllerDefinition
{
BoolButtons = { "0Fire" },
FloatControls = { "0Zapper X", "0Zapper Y" },
FloatRanges = NesDeck.ZapperRanges
AxisControls = { "0Zapper X", "0Zapper Y" },
AxisRanges = NesDeck.ZapperRanges
};
void Latch(IController c)
@ -622,7 +622,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
byte ret = 0;
if (c.IsPressed("0Fire"))
ret |= 0x80;
if (PPUCallback((int)c.GetFloat("0Zapper X"), (int)c.GetFloat("0Zapper Y")))
if (PPUCallback((int)c.AxisValue("0Zapper X"), (int)c.AxisValue("0Zapper Y")))
ret |= 0x40;
ret |= 0x10; // always 1
@ -755,8 +755,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static ControllerDefinition Definition = new ControllerDefinition
{
BoolButtons = { "0Fire" },
FloatControls = { "0Paddle" },
FloatRanges = { NesDeck.ArkanoidPaddleRange }
AxisControls = { "0Paddle" },
AxisRanges = { NesDeck.ArkanoidPaddleRange }
};
public void Strobe(StrobeInfo s, IController c)
@ -766,7 +766,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
shiftidx = 0;
if (s.OUT0 > s.OUT0old)
{
latchedvalue = (byte)(0x54 + (int)c.GetFloat("0Paddle"));
latchedvalue = (byte)(0x54 + (int)c.AxisValue("0Paddle"));
latchedvalue ^= 0xff;
}
}
@ -1015,8 +1015,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static ControllerDefinition Definition = new ControllerDefinition
{
BoolButtons = { "0Click", "0Touch" },
FloatControls = { "0Pen X", "0Pen Y" },
FloatRanges = NesDeck.ZapperRanges // why would a tablet have the same resolution as a CRT monitor? --yoshi
AxisControls = { "0Pen X", "0Pen Y" },
AxisRanges = NesDeck.ZapperRanges // why would a tablet have the same resolution as a CRT monitor? --yoshi
};
bool resetting;
@ -1028,8 +1028,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
resetting = s.OUT0 == 0;
if (s.OUT0 < s.OUT0old) // H->L: latch
{
int x = (int)c.GetFloat("0Pen X");
int y = (int)c.GetFloat("0Pen Y");
int x = (int)c.AxisValue("0Pen X");
int y = (int)c.AxisValue("0Pen Y");
// http://forums.nesdev.com/viewtopic.php?p=19454#19454
// it almost feels like the hardware guys got the request for
// a tablet that returned x in [0, 255] and y in [0, 239] and then

View File

@ -286,12 +286,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
"0Mouse Left",
"0Mouse Right"
},
FloatControls =
AxisControls =
{
"0Mouse X",
"0Mouse Y"
},
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
public ControllerDefinition Definition => _definition;
@ -305,7 +305,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
default:
return 0;
case 0:
var x = (int)controller.GetFloat("0Mouse X");
var x = (int)controller.AxisValue("0Mouse X");
if (LimitAnalogChangeSensitivity)
{
x = x.Clamp(-10, 10);
@ -313,7 +313,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
return (short)x;
case 1:
var y = (int)controller.GetFloat("0Mouse Y");
var y = (int)controller.AxisValue("0Mouse Y");
if (LimitAnalogChangeSensitivity)
{
y = y.Clamp(-10, 10);
@ -341,12 +341,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
"0Turbo",
"0Pause"
},
FloatControls =
AxisControls =
{
"0Scope X",
"0Scope Y"
},
FloatRanges = LibsnesControllerDeck.LightGunRanges
AxisRanges = LibsnesControllerDeck.LightGunRanges
};
public ControllerDefinition Definition => _definition;
@ -358,10 +358,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
default:
return 0;
case 0:
var x = (int)controller.GetFloat("0Scope X");
var x = (int)controller.AxisValue("0Scope X");
return (short)x;
case 1:
var y = (int)controller.GetFloat("0Scope Y");
var y = (int)controller.AxisValue("0Scope Y");
return (short)y;
case 2:
return (short)(controller.IsPressed("0Trigger") ? 1 : 0);
@ -388,14 +388,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
"1Trigger",
"1Start"
},
FloatControls =
AxisControls =
{
"0Justifier X",
"0Justifier Y",
"1Justifier X",
"1Justifier Y",
},
FloatRanges = LibsnesControllerDeck.LightGunRanges.Concat(LibsnesControllerDeck.LightGunRanges).ToList()
AxisRanges = LibsnesControllerDeck.LightGunRanges.Concat(LibsnesControllerDeck.LightGunRanges).ToList()
};
public ControllerDefinition Definition => _definition;
@ -407,10 +407,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
default:
return 0;
case 0:
var x = (int)controller.GetFloat(index + "Justifier X");
var x = (int)controller.AxisValue(index + "Justifier X");
return (short)x;
case 1:
var y = (int)controller.GetFloat(index + "Justifier Y");
var y = (int)controller.AxisValue(index + "Justifier Y");
return (short)y;
case 2:
return (short)(controller.IsPressed(index + "Trigger") ? 1 : 0);

View File

@ -193,8 +193,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public void ApplyState(IController controller, short[] input, int offset)
{
foreach (var s in Definition.FloatControls)
input[offset++] = (short)(controller.GetFloat(s));
foreach (var s in Definition.AxisControls)
input[offset++] = (short)(controller.AxisValue(s));
foreach (var s in Definition.BoolButtons)
input[offset++] = (short)(controller.IsPressed(s) ? 1 : 0);
}
@ -209,12 +209,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
"0Mouse Left",
"0Mouse Right"
},
FloatControls =
AxisControls =
{
"0Mouse X",
"0Mouse Y"
},
FloatRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
};
public override ControllerDefinition Definition => _definition;
@ -231,12 +231,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
"0Turbo",
"0Pause"
},
FloatControls =
AxisControls =
{
"0Scope X",
"0Scope Y"
},
FloatRanges = SNES.LibsnesControllerDeck.LightGunRanges
AxisRanges = SNES.LibsnesControllerDeck.LightGunRanges
};
public override ControllerDefinition Definition => _definition;
@ -251,12 +251,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
"0Trigger",
"0Start",
},
FloatControls =
AxisControls =
{
"0Justifier X",
"0Justifier Y",
},
FloatRanges = SNES.LibsnesControllerDeck.LightGunRanges
AxisRanges = SNES.LibsnesControllerDeck.LightGunRanges
};
public override ControllerDefinition Definition => _definition;

View File

@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
reset_frame = true;
}
input_frame_length = controller.GetFloat("Input Cycle");
input_frame_length = controller.AxisValue("Input Cycle");
input_frame_length_int = (int)Math.Floor(input_frame_length);
if (input_frame_length_int == 0)

View File

@ -42,8 +42,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
_tracer = new TraceBuffer { Header = _GBCore.cpu.TraceHeader };
ser.Register(_tracer);
_GBCore.ControllerDefinition.FloatControls.Add("Input Cycle");
_GBCore.ControllerDefinition.FloatRanges.Add(new ControllerDefinition.AxisRange(0, 70224, 70224));
_GBCore.ControllerDefinition.AxisControls.Add("Input Cycle");
_GBCore.ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 70224, 70224));
}
public GBHawk.GBHawk _GBCore;

View File

@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
reset_frame = true;
}
reset_cycle = controller.GetFloat("Reset Cycle");
reset_cycle = controller.AxisValue("Reset Cycle");
reset_cycle_int = (int)Math.Floor(reset_cycle);
_isLag = true;

View File

@ -44,17 +44,17 @@ namespace BizHawk.Emulation.Cores.PCEngine
.ToList()
};
Definition.FloatControls.AddRange(_port1.Definition.FloatControls);
Definition.FloatControls.AddRange(_port2.Definition.FloatControls);
Definition.FloatControls.AddRange(_port3.Definition.FloatControls);
Definition.FloatControls.AddRange(_port4.Definition.FloatControls);
Definition.FloatControls.AddRange(_port5.Definition.FloatControls);
Definition.AxisControls.AddRange(_port1.Definition.AxisControls);
Definition.AxisControls.AddRange(_port2.Definition.AxisControls);
Definition.AxisControls.AddRange(_port3.Definition.AxisControls);
Definition.AxisControls.AddRange(_port4.Definition.AxisControls);
Definition.AxisControls.AddRange(_port5.Definition.AxisControls);
Definition.FloatRanges.AddRange(_port1.Definition.FloatRanges);
Definition.FloatRanges.AddRange(_port2.Definition.FloatRanges);
Definition.FloatRanges.AddRange(_port3.Definition.FloatRanges);
Definition.FloatRanges.AddRange(_port4.Definition.FloatRanges);
Definition.FloatRanges.AddRange(_port5.Definition.FloatRanges);
Definition.AxisRanges.AddRange(_port1.Definition.AxisRanges);
Definition.AxisRanges.AddRange(_port2.Definition.AxisRanges);
Definition.AxisRanges.AddRange(_port3.Definition.AxisRanges);
Definition.AxisRanges.AddRange(_port4.Definition.AxisRanges);
Definition.AxisRanges.AddRange(_port5.Definition.AxisRanges);
}
private readonly IPort _port1;

View File

@ -293,9 +293,9 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
public ControllerDefinition Definition => null;
public float GetFloat(string name)
public float AxisValue(string name)
{
return _controller.GetFloat(_prefix + name);
return _controller.AxisValue(_prefix + name);
}
public bool IsPressed(string button)

View File

@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
return SMSPaddleController;
case SmsSyncSettings.ControllerTypes.LightPhaser:
// scale the vertical to the display mode
SMSLightPhaserController.FloatRanges[1] = new ControllerDefinition.AxisRange(0, Vdp.FrameHeight / 2, Vdp.FrameHeight - 1);
SMSLightPhaserController.AxisRanges[1] = new ControllerDefinition.AxisRange(0, Vdp.FrameHeight / 2, Vdp.FrameHeight - 1);
return SMSLightPhaserController;
case SmsSyncSettings.ControllerTypes.SportsPad:

View File

@ -37,12 +37,12 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
"P1 Left", "P1 Right", "P1 B1",
"P2 Left", "P2 Right", "P2 B1",
},
FloatControls =
AxisControls =
{
"P1 Paddle",
"P2 Paddle"
},
FloatRanges =
AxisRanges =
{
new ControllerDefinition.AxisRange(0, 128, 255),
new ControllerDefinition.AxisRange(0, 128, 255)
@ -57,11 +57,11 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
"Reset", "Pause",
"P1 Trigger",
},
FloatControls =
AxisControls =
{
"P1 X", "P1 Y",
},
FloatRanges =
AxisRanges =
{
new ControllerDefinition.AxisRange(0, 64, 127),
new ControllerDefinition.AxisRange(0, 500, 1000)
@ -80,12 +80,12 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
"P1 Left", "P1 Right", "P1 Up", "P1 Down", "P1 B1", "P1 B2",
"P2 Left", "P2 Right", "P2 Up", "P2 Down", "P2 B1", "P2 B2"
},
FloatControls =
AxisControls =
{
"P1 X", "P1 Y",
"P2 X", "P2 Y"
},
FloatRanges = SportsPadTrackballRanges.Concat(SportsPadTrackballRanges).ToList()
AxisRanges = SportsPadTrackballRanges.Concat(SportsPadTrackballRanges).ToList()
};
public static readonly ControllerDefinition SMSKeyboardController = new ControllerDefinition
@ -151,7 +151,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P1 Right"))
paddle1Pos = PaddleMax;
else
paddle1Pos = (int)_controller.GetFloat("P1 Paddle");
paddle1Pos = (int)_controller.AxisValue("P1 Paddle");
int paddle2Pos;
if (_controller.IsPressed("P2 Left"))
@ -159,7 +159,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P2 Right"))
paddle2Pos = PaddleMax;
else
paddle2Pos = (int)_controller.GetFloat("P2 Paddle");
paddle2Pos = (int)_controller.AxisValue("P2 Paddle");
PresetControllerState(1);
// Hard-wired together?
@ -210,7 +210,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P1 Right"))
p1X = SportsPadMax;
else
p1X = (int)_controller.GetFloat("P1 X");
p1X = (int)_controller.AxisValue("P1 X");
int p1Y;
if (_controller.IsPressed("P1 Up"))
@ -218,7 +218,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P1 Down"))
p1Y = SportsPadMax;
else
p1Y = (int)_controller.GetFloat("P1 Y");
p1Y = (int)_controller.AxisValue("P1 Y");
int p2X;
if (_controller.IsPressed("P2 Left"))
@ -226,7 +226,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P2 Right"))
p2X = SportsPadMax;
else
p2X = (int)_controller.GetFloat("P2 X");
p2X = (int)_controller.AxisValue("P2 X");
int p2Y;
if (_controller.IsPressed("P2 Up"))
@ -234,7 +234,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P2 Down"))
p2Y = SportsPadMax;
else
p2Y = (int)_controller.GetFloat("P2 Y");
p2Y = (int)_controller.AxisValue("P2 Y");
if (_region == SmsSyncSettings.Regions.Japan)
{
@ -403,7 +403,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P2 Right"))
paddle2Pos = PaddleMax;
else
paddle2Pos = (int)_controller.GetFloat("P2 Paddle");
paddle2Pos = (int)_controller.AxisValue("P2 Paddle");
PresetControllerState(2);
@ -441,7 +441,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P2 Right"))
p2X = SportsPadMax;
else
p2X = (int)_controller.GetFloat("P2 X");
p2X = (int)_controller.AxisValue("P2 X");
int p2Y;
if (_controller.IsPressed("P2 Down"))
@ -449,7 +449,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
else if (_controller.IsPressed("P2 Up"))
p2Y = SportsPadMax;
else
p2Y = (int)_controller.GetFloat("P2 Y");
p2Y = (int)_controller.AxisValue("P2 Y");
if (_region == SmsSyncSettings.Regions.Japan)
{
@ -563,8 +563,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
// specifically lightgun needs to do things on a per-line basis
if (SyncSettings.ControllerType == SmsSyncSettings.ControllerTypes.LightPhaser)
{
byte phaserX = (byte)(_controller.GetFloat("P1 X") + 20);
int phaserY = (int)_controller.GetFloat("P1 Y");
byte phaserX = (byte)(_controller.AxisValue("P1 X") + 20);
int phaserY = (int)_controller.AxisValue("P1 Y");
int scanline = Vdp.ScanLine;
if (!LatchLightPhaser && phaserY >= scanline - phaserRadius && phaserY <= scanline + phaserRadius)

View File

@ -120,11 +120,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
.Select(a => a.s)
.ToList(),
};
Definition.FloatControls.AddRange(_bakedAnalogNames
Definition.AxisControls.AddRange(_bakedAnalogNames
.Select((s, i) => new { s, i })
.OrderBy(a => AnalogOrdinal(AnalogNames[a.i]))
.Select(a => a.s));
Definition.FloatRanges.AddRange(_bakedAnalogNames.Select(s => MiscAxisRange));
Definition.AxisRanges.AddRange(_bakedAnalogNames.Select(s => MiscAxisRange));
}
private readonly string[] _bakedButtonNames;
@ -170,7 +170,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
int pos = offset + AnalogByteOffset;
for (int i = 0; i < _bakedAnalogNames.Length; i++)
{
var data = (byte)(int)controller.GetFloat(_bakedAnalogNames[i]);
var data = (byte)(int)controller.AxisValue(_bakedAnalogNames[i]);
dest[pos++] = data;
}
}
@ -242,7 +242,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
public ThreeDeeGamepad()
{
Definition.FloatRanges = ThreeDeeAxisRanges;
Definition.AxisRanges = ThreeDeeAxisRanges;
}
public override void Update(IController controller, byte[] dest, int offset)
@ -368,7 +368,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
public Mission()
{
Definition.FloatRanges = MissionAxisRanges;
Definition.AxisRanges = MissionAxisRanges;
}
protected override int ButtonOrdinal(string name)
@ -413,7 +413,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
public DualMission()
{
Definition.FloatRanges = DualMissionAxisRanges;
Definition.AxisRanges = DualMissionAxisRanges;
}
}

View File

@ -128,14 +128,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
{
string nx = $"P{player} Mouse X";
string ny = $"P{player} Mouse Y";
ControllerDef.FloatControls.Add(nx);
ControllerDef.FloatControls.Add(ny);
ControllerDef.FloatRanges.Add(MouseRange);
ControllerDef.FloatRanges.Add(MouseRange);
ControllerDef.AxisControls.Add(nx);
ControllerDef.AxisControls.Add(ny);
ControllerDef.AxisRanges.Add(MouseRange);
ControllerDef.AxisRanges.Add(MouseRange);
_converts.Add(delegate
{
_target.analog[(2 * idx) + 0] = (short)_source.GetFloat(nx);
_target.analog[(2 * idx) + 1] = (short)_source.GetFloat(ny);
_target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
_target.analog[(2 * idx) + 1] = (short)_source.AxisValue(ny);
});
}
@ -143,14 +143,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
{
string nx = $"P{player} Lightgun X";
string ny = $"P{player} Lightgun Y";
ControllerDef.FloatControls.Add(nx);
ControllerDef.FloatControls.Add(ny);
ControllerDef.FloatRanges.Add(LightgunRange);
ControllerDef.FloatRanges.Add(LightgunRange);
ControllerDef.AxisControls.Add(nx);
ControllerDef.AxisControls.Add(ny);
ControllerDef.AxisRanges.Add(LightgunRange);
ControllerDef.AxisRanges.Add(LightgunRange);
_converts.Add(delegate
{
_target.analog[(2 * idx) + 0] = (short)(_source.GetFloat(nx) / 10000.0f * (ScreenWidth - 1));
_target.analog[(2 * idx) + 1] = (short)(_source.GetFloat(ny) / 10000.0f * (ScreenHeight - 1));
_target.analog[(2 * idx) + 0] = (short)(_source.AxisValue(nx) / 10000.0f * (ScreenWidth - 1));
_target.analog[(2 * idx) + 1] = (short)(_source.AxisValue(ny) / 10000.0f * (ScreenHeight - 1));
});
}
@ -159,19 +159,19 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
string nx = $"P{player} Stick X";
string ny = $"P{player} Stick Y";
string nz = $"P{player} Stick Z";
ControllerDef.FloatControls.Add(nx);
ControllerDef.FloatControls.Add(ny);
ControllerDef.FloatControls.Add(nz);
ControllerDef.FloatRanges.Add(Xea1PRange);
ControllerDef.FloatRanges.Add(Xea1PRange);
ControllerDef.FloatRanges.Add(Xea1PRange);
ControllerDef.AxisControls.Add(nx);
ControllerDef.AxisControls.Add(ny);
ControllerDef.AxisControls.Add(nz);
ControllerDef.AxisRanges.Add(Xea1PRange);
ControllerDef.AxisRanges.Add(Xea1PRange);
ControllerDef.AxisRanges.Add(Xea1PRange);
_converts.Add(delegate
{
_target.analog[(2 * idx) + 0] = (short)_source.GetFloat(nx);
_target.analog[(2 * idx) + 1] = (short)_source.GetFloat(ny);
_target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
_target.analog[(2 * idx) + 1] = (short)_source.AxisValue(ny);
// +2 is correct in how gpgx internally does this
_target.analog[(2 * idx) + 2] = (short)(_source.GetFloat(nz));
_target.analog[(2 * idx) + 2] = (short)(_source.AxisValue(nz));
});
}

View File

@ -247,7 +247,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
"P" + pnum + " A",
});
definition.FloatControls.AddRange(new[]
definition.AxisControls.AddRange(new[]
{
"P" + pnum + " Twist",
"P" + pnum + " 1",
@ -256,10 +256,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
});
var axisRange = new ControllerDefinition.AxisRange(0, 128, 255);
definition.FloatRanges.Add(axisRange);
definition.FloatRanges.Add(axisRange);
definition.FloatRanges.Add(axisRange);
definition.FloatRanges.Add(axisRange);
definition.AxisRanges.Add(axisRange);
definition.AxisRanges.Add(axisRange);
definition.AxisRanges.Add(axisRange);
definition.AxisRanges.Add(axisRange);
}
else
{
@ -288,7 +288,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
definition.BoolButtons.Add("P" + pnum + " R3");
definition.BoolButtons.Add("P" + pnum + " MODE");
definition.FloatControls.AddRange(new[]
definition.AxisControls.AddRange(new[]
{
"P" + pnum + " LStick X",
"P" + pnum + " LStick Y",
@ -296,7 +296,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
"P" + pnum + " RStick Y"
});
definition.FloatRanges.AddRange(DualShockStickRanges.Concat(DualShockStickRanges).ToList());
definition.AxisRanges.AddRange(DualShockStickRanges.Concat(DualShockStickRanges).ToList());
}
}
}
@ -308,9 +308,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
"Reset"
});
definition.FloatControls.Add("Disc Select");
definition.AxisControls.Add("Disc Select");
definition.FloatRanges.Add(
definition.AxisRanges.Add(
//new ControllerDefinition.AxisRange(-1, -1, -1) //this is carefully chosen so that we end up with a -1 disc by default (indicating that it's never been set)
//hmm.. I don't see why this wouldn't work
new ControllerDefinition.AxisRange(0, 1, 1)
@ -521,10 +521,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
if (_controller.IsPressed(pstring + "B")) buttons |= 4096;
if (_controller.IsPressed(pstring + "A")) buttons |= 8192;
byte twist = (byte)_controller.GetFloat(pstring + "Twist");
byte analog1 = (byte)_controller.GetFloat(pstring + "1");
byte analog2 = (byte)_controller.GetFloat(pstring + "2");
byte analogL = (byte)_controller.GetFloat(pstring + "L");
byte twist = (byte)_controller.AxisValue(pstring + "Twist");
byte analog1 = (byte)_controller.AxisValue(pstring + "1");
byte analog2 = (byte)_controller.AxisValue(pstring + "2");
byte analogL = (byte)_controller.AxisValue(pstring + "L");
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, twist, analog1, analog2, analogL);
}
@ -552,10 +552,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
if (_controller.IsPressed(pstring + "R3")) buttons |= 4;
if (_controller.IsPressed(pstring + "MODE")) buttons |= 65536;
left_x = (byte)_controller.GetFloat(pstring + "LStick X");
left_y = (byte)_controller.GetFloat(pstring + "LStick Y");
right_x = (byte)_controller.GetFloat(pstring + "RStick X");
right_y = (byte)_controller.GetFloat(pstring + "RStick Y");
left_x = (byte)_controller.AxisValue(pstring + "LStick X");
left_y = (byte)_controller.AxisValue(pstring + "LStick Y");
right_x = (byte)_controller.AxisValue(pstring + "RStick X");
right_y = (byte)_controller.AxisValue(pstring + "RStick Y");
}
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, left_x, left_y, right_x, right_y);
@ -716,7 +716,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
//change the disc if needed, and valid
//also if frame is 0, we need to set a disc no matter what
int requestedDisc = (int)_controller.GetFloat("Disc Select");
int requestedDisc = (int)_controller.AxisValue("Disc Select");
if (requestedDisc != CurrentDiscIndexMounted && CurrentTrayOpen
|| Frame == 0
)

View File

@ -257,9 +257,9 @@ namespace BizHawk.Emulation.Cores.Libretro
definition.BoolButtons.Add(string.Format(item,"RetroPad"));
definition.BoolButtons.Add("Pointer Pressed"); //TODO: this isnt showing up in the binding panel. I don't want to find out why.
definition.FloatControls.Add("Pointer X");
definition.FloatControls.Add("Pointer Y");
definition.FloatRanges.AddRange(ControllerDefinition.CreateAxisRangePair(-32767, 0, 32767, ControllerDefinition.AxisPairOrientation.RightAndUp));
definition.AxisControls.Add("Pointer X");
definition.AxisControls.Add("Pointer Y");
definition.AxisRanges.AddRange(ControllerDefinition.CreateAxisRangePair(-32767, 0, 32767, ControllerDefinition.AxisPairOrientation.RightAndUp));
foreach (var key in new[]{
"Key Backspace", "Key Tab", "Key Clear", "Key Return", "Key Pause", "Key Escape",

View File

@ -18,8 +18,8 @@
{
switch ((LibretroApi.RETRO_DEVICE_ID_POINTER)id)
{
case LibretroApi.RETRO_DEVICE_ID_POINTER.X: return (short)_controller.GetFloat("Pointer X");
case LibretroApi.RETRO_DEVICE_ID_POINTER.Y: return (short)_controller.GetFloat("Pointer Y");
case LibretroApi.RETRO_DEVICE_ID_POINTER.X: return (short)_controller.AxisValue("Pointer X");
case LibretroApi.RETRO_DEVICE_ID_POINTER.Y: return (short)_controller.AxisValue("Pointer Y");
case LibretroApi.RETRO_DEVICE_ID_POINTER.PRESSED: return (short)(_controller.IsPressed("Pointer Pressed") ? 1 : 0);
}
return 0;