Merge AxisControls, AxisRanges, and AxisConstraints into a single dict
This commit is contained in:
parent
af2649d9a0
commit
6cb60aa9fd
|
@ -12,10 +12,10 @@ namespace BizHawk.Client.Common
|
|||
public Controller(ControllerDefinition definition)
|
||||
{
|
||||
Definition = definition;
|
||||
for (int i = 0; i < Definition.AxisControls.Count; i++)
|
||||
foreach (var kvp in Definition.Axes)
|
||||
{
|
||||
_axes[Definition.AxisControls[i]] = Definition.AxisRanges[i].Mid;
|
||||
_axisRanges[Definition.AxisControls[i]] = Definition.AxisRanges[i];
|
||||
_axes[kvp.Key] = kvp.Value.Range.Mid;
|
||||
_axisRanges[kvp.Key] = kvp.Value.Range;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
foreach (var button in group)
|
||||
{
|
||||
if (_source.Definition.AxisControls.Contains(button))
|
||||
if (_source.Definition.Axes.TryGetValue(button, out var range))
|
||||
{
|
||||
int i = _source.Definition.AxisControls.IndexOf(button);
|
||||
var mid = _source.Definition.AxisRanges[i].Mid;
|
||||
|
||||
var val = (int)_source.AxisValue(button);
|
||||
|
||||
if (val == mid)
|
||||
if (val == range.Range.Mid)
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (analogBinds.TryGetValue(def.Name, out var aBinds))
|
||||
{
|
||||
foreach (var btn in def.AxisControls)
|
||||
foreach (var btn in def.Axes.Keys)
|
||||
{
|
||||
if (aBinds.TryGetValue(btn, out var bind))
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
Name = c,
|
||||
IsBool = _type.BoolButtons.Contains(c),
|
||||
IsAxis = _type.AxisControls.Contains(c)
|
||||
IsAxis = _type.Axes.ContainsKey(c)
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace BizHawk.Client.Common
|
|||
_myBoolButtons[button] = source.IsPressed(button);
|
||||
}
|
||||
|
||||
foreach (var name in Definition.AxisControls)
|
||||
foreach (var name in Definition.Axes.Keys)
|
||||
{
|
||||
_myAxisControls[name] = source.AxisValue(name);
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// axes don't have sticky logic, so latch default value
|
||||
for (int i = 0; i < Definition.AxisControls.Count; i++)
|
||||
foreach (var kvp in Definition.Axes)
|
||||
{
|
||||
_myAxisControls[Definition.AxisControls[i]] = Definition.AxisRanges[i].Mid;
|
||||
_myAxisControls[kvp.Key] = kvp.Value.Range.Mid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
dict.Add(button, Bk2MnemonicLookup.Lookup(button, _systemId).ToString());
|
||||
}
|
||||
else if (_source.Definition.AxisControls.Contains(button))
|
||||
else if (_source.Definition.Axes.ContainsKey(button))
|
||||
{
|
||||
dict.Add(button, Bk2MnemonicLookup.LookupAxis(button, _systemId));
|
||||
}
|
||||
|
@ -73,15 +73,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
foreach (var button in group)
|
||||
{
|
||||
if (_source.Definition.AxisControls.Contains(button))
|
||||
if (_source.Definition.Axes.TryGetValue(button, out var range))
|
||||
{
|
||||
int val;
|
||||
int i = _source.Definition.AxisControls.IndexOf(button);
|
||||
var mid = _source.Definition.AxisRanges[i].Mid;
|
||||
|
||||
if (createEmpty)
|
||||
{
|
||||
val = mid;
|
||||
val = range.Range.Mid;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -88,14 +88,9 @@ namespace BizHawk.Client.Common
|
|||
"Right", "Left", "Down", "Up", "Start", "Select",
|
||||
"B", "A", "X", "Y", "L", "R", "LidOpen", "LidClose", "Touch"
|
||||
}
|
||||
}
|
||||
}.AddXYPair("Touch{0}", ControllerDefinition.AxisPairOrientation.RightAndUp, (0, 128, 255), (0, 96, 191)) //TODO verify direction against hardware
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace BizHawk.Client.Common
|
|||
: "";
|
||||
}
|
||||
|
||||
if (adapter.Definition.AxisControls.Contains(buttonName))
|
||||
if (adapter.Definition.Axes.ContainsKey(buttonName))
|
||||
{
|
||||
return adapter.AxisValue(buttonName).ToString();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
foreach (var button in controller.Definition.BoolButtons) GlobalWin.InputManager.ButtonOverrideAdapter.SetButton(button, controller.IsPressed(button));
|
||||
foreach (var axis in controller.Definition.AxisControls) GlobalWin.InputManager.ButtonOverrideAdapter.SetAxis(axis, controller.AxisValue(axis));
|
||||
foreach (var axis in controller.Definition.Axes.Keys) GlobalWin.InputManager.ButtonOverrideAdapter.SetAxis(axis, controller.AxisValue(axis));
|
||||
}
|
||||
|
||||
public void Set(Dictionary<string, bool> buttons, int? controller = null)
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static readonly Regex ButtonMatchesPlayer = new Regex("^P(\\d+)\\s");
|
||||
|
||||
private void LoadToPanel<T>(Control dest, string controllerName, IList<string> controllerButtons, Dictionary<string,string> categoryLabels, IDictionary<string, Dictionary<string, T>> settingsBlock, T defaultValue, PanelCreator<T> createPanel)
|
||||
private void LoadToPanel<T>(Control dest, string controllerName, IReadOnlyCollection<string> controllerButtons, Dictionary<string,string> categoryLabels, IDictionary<string, Dictionary<string, T>> settingsBlock, T defaultValue, PanelCreator<T> createPanel)
|
||||
{
|
||||
if (!settingsBlock.TryGetValue(controllerName, out var settings))
|
||||
{
|
||||
|
@ -193,7 +193,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.AxisControls, _emulator.ControllerDefinition.CategoryLabels, analog, new AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
|
||||
LoadToPanel(AnalogControlsTab, _emulator.ControllerDefinition.Name, _emulator.ControllerDefinition.Axes.Keys.ToList(), _emulator.ControllerDefinition.CategoryLabels, analog, new AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
|
||||
|
||||
if (AnalogControlsTab.Controls.Count == 0)
|
||||
{
|
||||
|
|
|
@ -385,7 +385,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
table[button] = controller.IsPressed(button);
|
||||
}
|
||||
|
||||
foreach (var button in controller.Definition.AxisControls)
|
||||
foreach (var button in controller.Definition.Axes.Keys)
|
||||
{
|
||||
table[button] = controller.AxisValue(button);
|
||||
}
|
||||
|
|
|
@ -10,18 +10,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void SetUpButtonBoxes()
|
||||
{
|
||||
var def = Emulator.ControllerDefinition;
|
||||
int count = def.BoolButtons.Count + def.AxisControls.Count;
|
||||
int count = def.BoolButtons.Count + def.Axes.Count;
|
||||
_buttonBoxes = new CheckBox[count];
|
||||
|
||||
for (int i = 0; i < def.AxisControls.Count; i++)
|
||||
for (int i = 0; i < def.Axes.Count; i++)
|
||||
{
|
||||
var box = new CheckBox { Text = def.AxisControls[i] };
|
||||
var box = new CheckBox { Text = def.Axes[i] };
|
||||
_buttonBoxes[i] = box;
|
||||
}
|
||||
for (int i = 0; i < def.BoolButtons.Count; i++)
|
||||
{
|
||||
var box = new CheckBox { Text = def.BoolButtons[i] };
|
||||
_buttonBoxes[i + def.AxisControls.Count] = box;
|
||||
_buttonBoxes[i + def.Axes.Count] = box;
|
||||
}
|
||||
|
||||
foreach (var box in _buttonBoxes)
|
||||
|
|
|
@ -49,9 +49,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
d.AxisControls.Add(k);
|
||||
int rangeIndex = _emulator.ControllerDefinition.AxisControls.IndexOf(k);
|
||||
d.AxisRanges.Add(_emulator.ControllerDefinition.AxisRanges[rangeIndex]);
|
||||
d.Axes.Add(k, _emulator.ControllerDefinition.Axes[k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +102,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
d.AxisControls.Add(key);
|
||||
d.Axes.Add(key, _emulator.ControllerDefinition.Axes[key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +266,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
d.AxisControls.Add(k);
|
||||
d.Axes.Add(k, _emulator.ControllerDefinition.Axes[key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,7 +280,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
latching.SetBool(button, source.IsPressed(button));
|
||||
}
|
||||
|
||||
foreach (string name in source.Definition.AxisControls)
|
||||
foreach (string name in source.Definition.Axes.Keys)
|
||||
{
|
||||
latching.SetAxis(name, source.AxisValue(name));
|
||||
}
|
||||
|
@ -295,11 +293,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
latching.SetBool(button, latching.IsPressed(button) | source.IsPressed(button));
|
||||
}
|
||||
|
||||
foreach (string name in latching.Definition.AxisControls)
|
||||
foreach (string name in latching.Definition.Axes.Keys)
|
||||
{
|
||||
var axisValue = source.AxisValue(name);
|
||||
int indexRange = source.Definition.AxisControls.IndexOf(name);
|
||||
if (axisValue == source.Definition.AxisRanges[indexRange].Mid)
|
||||
if (axisValue == source.Definition.Axes[name].Range.Mid)
|
||||
{
|
||||
latching.SetAxis(name, axisValue);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
ButtonBox.Items.Add(button);
|
||||
}
|
||||
|
||||
foreach (var button in _tastudio.MovieSession.MovieController.Definition.AxisControls)
|
||||
foreach (var button in _tastudio.MovieSession.MovieController.Definition.Axes.Keys)
|
||||
{
|
||||
ButtonBox.Items.Add(button);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton);
|
||||
index = _tastudio.MovieSession.MovieController.Definition.Axes.IndexOf(SelectedButton);
|
||||
}
|
||||
|
||||
LagBox.Checked = _tastudio.AxisPatterns[index].SkipsLag;
|
||||
|
@ -249,7 +249,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton);
|
||||
index = _tastudio.MovieSession.MovieController.Definition.Axes.IndexOf(SelectedButton);
|
||||
}
|
||||
|
||||
var p = new List<int>();
|
||||
|
@ -311,7 +311,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton);
|
||||
index = _tastudio.MovieSession.MovieController.Definition.Axes.IndexOf(SelectedButton);
|
||||
}
|
||||
|
||||
var p = _tastudio.AxisPatterns[index].Pattern;
|
||||
|
|
|
@ -358,9 +358,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (column.Type == ColumnType.Axis)
|
||||
{
|
||||
// feos: this could be cached, but I don't notice any slowdown this way either
|
||||
ControllerDefinition.AxisRange range = ControllerType.AxisRanges
|
||||
[ControllerType.AxisControls.IndexOf(columnName)];
|
||||
if (text == ((float) range.Mid).ToString())
|
||||
if (text == ((float) ControllerType.Axes[columnName].Range.Mid).ToString())
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
|
@ -487,11 +485,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (index == 0)
|
||||
{
|
||||
index = ControllerType.AxisControls.IndexOf(button);
|
||||
index = ControllerType.Axes.IndexOf(button);
|
||||
}
|
||||
else
|
||||
{
|
||||
index += ControllerType.AxisControls.Count - 1;
|
||||
index += ControllerType.Axes.Count - 1;
|
||||
}
|
||||
|
||||
int? value = null;
|
||||
|
@ -690,8 +688,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked
|
||||
|| TasView.CurrentCell.Column.Emphasis))
|
||||
{
|
||||
AxisPatterns[ControllerType.AxisControls.IndexOf(buttonName)].Reset();
|
||||
CurrentTasMovie.SetAxisState(frame, buttonName, AxisPatterns[ControllerType.AxisControls.IndexOf(buttonName)].GetNextValue());
|
||||
AxisPatterns[ControllerType.Axes.IndexOf(buttonName)].Reset();
|
||||
CurrentTasMovie.SetAxisState(frame, buttonName, AxisPatterns[ControllerType.Axes.IndexOf(buttonName)].GetNextValue());
|
||||
_patternPaint = true;
|
||||
}
|
||||
else
|
||||
|
@ -1173,7 +1171,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
setVal = AxisPatterns[ControllerType.AxisControls.IndexOf(_startAxisDrawColumn)].GetNextValue();
|
||||
setVal = AxisPatterns[ControllerType.Axes.IndexOf(_startAxisDrawColumn)].GetNextValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1201,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.AxisRanges[ControllerType.AxisControls.IndexOf(_axisEditColumn)].Range);
|
||||
var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.Axes[_axisEditColumn].Range.Range);
|
||||
CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, value);
|
||||
_axisTypedValue = value.ToString();
|
||||
|
||||
|
@ -1276,13 +1274,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
float prev = value;
|
||||
string prevTyped = _axisTypedValue;
|
||||
|
||||
var range = ControllerType.AxisRanges[ControllerType.AxisControls.IndexOf(_axisEditColumn)];
|
||||
var (rMin, rMax) = range.FloatRange;
|
||||
var range = ControllerType.Axes[_axisEditColumn];
|
||||
var (rMin, rMax) = range.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 maxDigits = range.Range.MaxDigits;
|
||||
int curDigits = _axisTypedValue.Length;
|
||||
string curMinus;
|
||||
if (_axisTypedValue.StartsWith("-"))
|
||||
|
|
|
@ -421,12 +421,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
ColumnType type;
|
||||
int digits;
|
||||
if (ControllerType.AxisControls.Contains(kvp.Key))
|
||||
if (ControllerType.Axes.TryGetValue(kvp.Key, out var range))
|
||||
{
|
||||
var range = ControllerType.AxisRanges
|
||||
[ControllerType.AxisControls.IndexOf(kvp.Key)];
|
||||
type = ColumnType.Axis;
|
||||
digits = Math.Max(kvp.Value.Length, range.MaxDigits);
|
||||
digits = Math.Max(kvp.Value.Length, range.Range.MaxDigits);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -490,14 +488,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (BoolPatterns == null)
|
||||
{
|
||||
BoolPatterns = new AutoPatternBool[ControllerType.BoolButtons.Count + 2];
|
||||
AxisPatterns = new AutoPatternAxis[ControllerType.AxisControls.Count + 2];
|
||||
AxisPatterns = new AutoPatternAxis[ControllerType.Axes.Count + 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
bStart = BoolPatterns.Length - 2;
|
||||
fStart = AxisPatterns.Length - 2;
|
||||
Array.Resize(ref BoolPatterns, ControllerType.BoolButtons.Count + 2);
|
||||
Array.Resize(ref AxisPatterns, ControllerType.AxisControls.Count + 2);
|
||||
Array.Resize(ref AxisPatterns, ControllerType.Axes.Count + 2);
|
||||
}
|
||||
|
||||
for (int i = bStart; i < BoolPatterns.Length - 2; i++)
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.InputManager.ButtonOverrideAdapter.SetButton(button, controller.IsPressed(button));
|
||||
}
|
||||
|
||||
foreach (var axisName in controller.Definition.AxisControls)
|
||||
foreach (var axisName in controller.Definition.Axes.Keys)
|
||||
{
|
||||
GlobalWin.InputManager.ButtonOverrideAdapter.SetAxis(axisName, controller.AxisValue(axisName));
|
||||
}
|
||||
|
|
|
@ -90,14 +90,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (VersionInfo.DeveloperBuild)
|
||||
{
|
||||
var buttonControls = Emulator.ControllerDefinition.BoolButtons;
|
||||
var axisControls = Emulator.ControllerDefinition.AxisControls;
|
||||
var axisControls = Emulator.ControllerDefinition.Axes;
|
||||
foreach (var schema in padSchemata) foreach (var controlSchema in schema.Buttons)
|
||||
{
|
||||
Predicate<string> searchSetContains = controlSchema switch
|
||||
{
|
||||
ButtonSchema _ => buttonControls.Contains,
|
||||
DiscManagerSchema _ => s => buttonControls.Contains(s) || axisControls.Contains(s),
|
||||
_ => axisControls.Contains
|
||||
DiscManagerSchema _ => s => buttonControls.Contains(s) || axisControls.ContainsKey(s),
|
||||
_ => axisControls.ContainsKey
|
||||
};
|
||||
if (!searchSetContains(controlSchema.Name))
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema TurboController(int controller)
|
||||
{
|
||||
var controllerDefRanges = new ColecoTurboController(controller).Definition.AxisRanges;
|
||||
var defAxes = new ColecoTurboController(controller).Definition.Axes;
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(275, 260),
|
||||
|
@ -56,8 +56,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
new AnalogSchema(6, 14, $"P{controller} Disc X")
|
||||
{
|
||||
AxisRange = controllerDefRanges[0],
|
||||
SecondaryAxisRange = controllerDefRanges[1]
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
},
|
||||
new ButtonSchema(6, 224, controller, "Pedal")
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema AnalogController(int controller)
|
||||
{
|
||||
var controllerDefRanges = new FakeAnalogController(controller).Definition.AxisRanges;
|
||||
var defAxes = new FakeAnalogController(controller).Definition.Axes;
|
||||
return new PadSchema
|
||||
{
|
||||
DisplayName = $"Player {controller}",
|
||||
|
@ -79,8 +79,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
new AnalogSchema(1, 121, $"P{controller} Disc X")
|
||||
{
|
||||
AxisRange = controllerDefRanges[0],
|
||||
SecondaryAxisRange = controllerDefRanges[1]
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
}
|
||||
})
|
||||
};
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema Mouse(int controller)
|
||||
{
|
||||
var controllerDefRanges = new SnesMouseController().Definition.AxisRanges;
|
||||
var defAxes = new SnesMouseController().Definition.Axes;
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(345, 225),
|
||||
|
@ -167,8 +167,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
new AnalogSchema(6, 14, $"P{controller} Mouse X")
|
||||
{
|
||||
AxisRange = controllerDefRanges[0],
|
||||
SecondaryAxisRange = controllerDefRanges[1]
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
},
|
||||
new ButtonSchema(275, 15, controller, "Mouse Left")
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema AnalogController(int controller)
|
||||
{
|
||||
var controllerDefRanges = new AnalogControls(controller).Definition.AxisRanges;
|
||||
var defAxes = new AnalogControls(controller).Definition.Axes;
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(280, 300),
|
||||
|
@ -72,8 +72,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
Button(146, 34, controller, 4),
|
||||
new AnalogSchema(2, 80, $"P{controller} Stick X")
|
||||
{
|
||||
AxisRange = controllerDefRanges[0],
|
||||
SecondaryAxisRange = controllerDefRanges[1]
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -22,9 +23,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
Name = source.Name;
|
||||
BoolButtons.AddRange(source.BoolButtons);
|
||||
AxisControls.AddRange(source.AxisControls);
|
||||
AxisRanges.AddRange(source.AxisRanges);
|
||||
AxisConstraints.AddRange(source.AxisConstraints);
|
||||
foreach (var kvp in source.Axes) Axes.Add(kvp);
|
||||
CategoryLabels = source.CategoryLabels;
|
||||
}
|
||||
|
||||
|
@ -38,23 +37,76 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public List<string> BoolButtons { get; set; } = new List<string>();
|
||||
|
||||
/// <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> AxisControls { get; } = new List<string>();
|
||||
public sealed class AxisDict : IReadOnlyDictionary<string, AxisSpec>
|
||||
{
|
||||
private readonly IList<string> _keys = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 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> AxisRanges { get; set; } = new List<AxisRange>();
|
||||
private readonly IDictionary<string, AxisSpec> _specs = new Dictionary<string, AxisSpec>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis constraints that apply artificial constraints to float values
|
||||
/// For instance, a N64 controller's analog range is actually larger than the amount allowed by the plastic that artificially constrains it to lower values
|
||||
/// Axis constraints provide a way to technically allow the full range but have a user option to constrain down to typical values that a real control would have
|
||||
/// </summary>
|
||||
public List<AxisConstraint> AxisConstraints { get; } = new List<AxisConstraint>();
|
||||
public int Count => _keys.Count;
|
||||
|
||||
public bool HasContraints { get; private set; }
|
||||
|
||||
public IEnumerable<string> Keys => _keys;
|
||||
|
||||
public IEnumerable<AxisSpec> Values => _specs.Values;
|
||||
|
||||
public string this[int index] => _keys[index];
|
||||
|
||||
public AxisSpec this[string index]
|
||||
{
|
||||
get => _specs[index];
|
||||
set => _specs[index] = value;
|
||||
}
|
||||
|
||||
public void Add(string key, AxisSpec value)
|
||||
{
|
||||
_keys.Add(key);
|
||||
_specs.Add(key, value);
|
||||
if (value.Constraint != null) HasContraints = true;
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<string, AxisSpec> item) => Add(item.Key, item.Value);
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_keys.Clear();
|
||||
_specs.Clear();
|
||||
HasContraints = false;
|
||||
}
|
||||
|
||||
public bool ContainsKey(string key) => _keys.Contains(key);
|
||||
|
||||
public IEnumerator<KeyValuePair<string, AxisSpec>> GetEnumerator() => _specs.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
public int IndexOf(string key) => _keys.IndexOf(key);
|
||||
|
||||
public AxisSpec SpecAtIndex(int index) => this[_keys[index]];
|
||||
|
||||
public bool TryGetValue(string key, out AxisSpec value) => _specs.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public readonly AxisDict Axes = new AxisDict();
|
||||
|
||||
public readonly struct AxisSpec
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the axis constraints that apply artificial constraints to float values
|
||||
/// For instance, a N64 controller's analog range is actually larger than the amount allowed by the plastic that artificially constrains it to lower values
|
||||
/// Axis constraints provide a way to technically allow the full range but have a user option to constrain down to typical values that a real control would have
|
||||
/// </summary>
|
||||
public readonly AxisConstraint? Constraint;
|
||||
|
||||
public readonly AxisRange Range;
|
||||
|
||||
public AxisSpec(AxisRange range, AxisConstraint? constraint = null)
|
||||
{
|
||||
Constraint = constraint;
|
||||
Range = range;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category labels. These labels provide a means of categorizing controls in various controller display and config screens
|
||||
|
@ -63,17 +115,14 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public void ApplyAxisConstraints(string constraintClass, IDictionary<string, int> axes)
|
||||
{
|
||||
if (AxisConstraints == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Axes.HasContraints) return;
|
||||
|
||||
foreach (var constraint in AxisConstraints)
|
||||
foreach (var kvp in Axes)
|
||||
{
|
||||
if (constraint.Class != constraintClass)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (kvp.Value.Constraint == null) continue;
|
||||
var constraint = kvp.Value.Constraint.Value;
|
||||
|
||||
if (constraint.Class != constraintClass) continue;
|
||||
|
||||
switch (constraint.Type)
|
||||
{
|
||||
|
@ -168,7 +217,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
var list = new List<string>(AxisControls);
|
||||
var list = new List<string>(Axes.Keys);
|
||||
list.AddRange(BoolButtons);
|
||||
|
||||
// starts with console buttons, then each player's buttons individually
|
||||
|
@ -201,7 +250,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
var allNames = AxisControls.Concat(BoolButtons).ToList();
|
||||
var allNames = Axes.Keys.Concat(BoolButtons).ToList();
|
||||
var player = allNames
|
||||
.Select(PlayerNumber)
|
||||
.DefaultIfEmpty(0)
|
||||
|
@ -219,7 +268,7 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public bool Any()
|
||||
{
|
||||
return BoolButtons.Any() || AxisControls.Any();
|
||||
return BoolButtons.Any() || Axes.Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,14 +40,13 @@ namespace BizHawk.Emulation.Common
|
|||
remaps[s] = r;
|
||||
}
|
||||
|
||||
foreach (string s in def.AxisControls)
|
||||
foreach (var kvp in def.Axes)
|
||||
{
|
||||
string r = Allocate(s, ref plr, ref playerNext);
|
||||
ret.AxisControls.Add(r);
|
||||
remaps[s] = r;
|
||||
string r = Allocate(kvp.Key, ref plr, ref playerNext);
|
||||
ret.Axes.Add(r, kvp.Value);
|
||||
remaps[kvp.Key] = r;
|
||||
}
|
||||
|
||||
ret.AxisRanges.AddRange(def.AxisRanges);
|
||||
plr = playerNext;
|
||||
unmergers.Add(new ControlDefUnMerger(remaps));
|
||||
}
|
||||
|
|
|
@ -335,10 +335,10 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public static List<string> ToAxisControlNameList(this IController controller, int? controllerNum = null)
|
||||
{
|
||||
return ToControlNameList(controller.Definition.AxisControls, controllerNum);
|
||||
return ToControlNameList(controller.Definition.Axes.Keys, controllerNum);
|
||||
}
|
||||
|
||||
private static List<string> ToControlNameList(List<string> buttonList, int? controllerNum = null)
|
||||
private static List<string> ToControlNameList(IEnumerable<string> buttonList, int? controllerNum = null)
|
||||
{
|
||||
var buttons = new List<string>();
|
||||
foreach (var button in buttonList)
|
||||
|
@ -372,7 +372,7 @@ namespace BizHawk.Emulation.Common
|
|||
buttons[sub] = controller.IsPressed($"P{controllerNum} {sub}");
|
||||
}
|
||||
}
|
||||
foreach (var button in controller.Definition.AxisControls)
|
||||
foreach (var button in controller.Definition.Axes.Keys)
|
||||
{
|
||||
if (controllerNum == null)
|
||||
{
|
||||
|
@ -404,27 +404,32 @@ namespace BizHawk.Emulation.Common
|
|||
/// Adds an axis to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
/// The new axis will appear after any that were previously defined.
|
||||
/// </summary>
|
||||
/// <param name="constraint">pass only for one axis in a pair, by convention the X axis</param>
|
||||
/// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
|
||||
public static ControllerDefinition AddAxis(this ControllerDefinition def, string name, int min, int mid, int max, bool isReversed = false)
|
||||
public static ControllerDefinition AddAxis(this ControllerDefinition def, string name, AxisRange range, AxisConstraint? constraint = null)
|
||||
{
|
||||
def.AxisControls.Add(name);
|
||||
def.AxisRanges.Add(new AxisRange(min, mid, max, isReversed));
|
||||
def.Axes.Add(name, new AxisSpec(range, constraint));
|
||||
return def;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an axis to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
/// The new axis will appear after any that were previously defined.
|
||||
/// </summary>
|
||||
/// <param name="constraint">pass only for one axis in a pair, by convention the X axis</param>
|
||||
/// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
|
||||
public static ControllerDefinition AddAxis(this ControllerDefinition def, string name, int min, int mid, int max, bool isReversed = false, AxisConstraint? constraint = null)
|
||||
=> def.AddAxis(name, new AxisRange(min, mid, max, isReversed), constraint);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
/// The new axes will appear after any that were previously defined.
|
||||
/// </summary>
|
||||
/// <param name="nameFormat">format string e.g. <c>"P1 Left {0}"</c> (will be used to interpolate <c>"X"</c> and <c>"Y"</c>)</param>
|
||||
/// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
|
||||
public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, int minBoth, int midBoth, int maxBoth)
|
||||
{
|
||||
def.AxisControls.Add(string.Format(nameFormat, "X"));
|
||||
def.AxisControls.Add(string.Format(nameFormat, "Y"));
|
||||
def.AxisRanges.AddRange(CreateAxisRangePair(minBoth, midBoth, maxBoth, pDir));
|
||||
return def;
|
||||
}
|
||||
public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, (int Min, int Mid, int Max) rangeX, (int Min, int Mid, int Max) rangeY, AxisConstraint? constraint = null)
|
||||
=> def.AddAxis(string.Format(nameFormat, "X"), rangeX.Min, rangeX.Mid, rangeX.Max, ((byte) pDir & 2) != 0, constraint)
|
||||
.AddAxis(string.Format(nameFormat, "Y"), rangeY.Min, rangeY.Mid, rangeY.Max, ((byte) pDir & 1) != 0);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
|
@ -432,14 +437,8 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
/// <param name="nameFormat">format string e.g. <c>"P1 Left {0}"</c> (will be used to interpolate <c>"X"</c> and <c>"Y"</c>)</param>
|
||||
/// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
|
||||
public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, (int Min, int Mid, int Max) rangeX, (int Min, int Mid, int Max) rangeY)
|
||||
{
|
||||
def.AxisControls.Add(string.Format(nameFormat, "X"));
|
||||
def.AxisControls.Add(string.Format(nameFormat, "Y"));
|
||||
def.AxisRanges.Add(new AxisRange(rangeX.Min, rangeX.Mid, rangeX.Max, ((byte) pDir & 2) != 0));
|
||||
def.AxisRanges.Add(new AxisRange(rangeY.Min, rangeY.Mid, rangeY.Max, ((byte) pDir & 1) != 0));
|
||||
return def;
|
||||
}
|
||||
public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, int minBoth, int midBoth, int maxBoth, AxisConstraint? constraint = null)
|
||||
=> def.AddXYPair(nameFormat, pDir, (minBoth, midBoth, maxBoth), (minBoth, midBoth, maxBoth), constraint);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an X/Y/Z triple of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
|
@ -449,14 +448,12 @@ namespace BizHawk.Emulation.Common
|
|||
/// <returns>identical reference to <paramref name="def"/>; the object is mutated</returns>
|
||||
public static ControllerDefinition AddXYZTriple(this ControllerDefinition def, string nameFormat, int minAll, int midAll, int maxAll)
|
||||
{
|
||||
def.AxisControls.Add(string.Format(nameFormat, "X"));
|
||||
def.AxisControls.Add(string.Format(nameFormat, "Y"));
|
||||
def.AxisControls.Add(string.Format(nameFormat, "Z"));
|
||||
var range = new AxisRange(minAll, midAll, maxAll);
|
||||
def.AxisRanges.Add(range);
|
||||
def.AxisRanges.Add(range);
|
||||
def.AxisRanges.Add(range);
|
||||
return def;
|
||||
return def.AddAxis(string.Format(nameFormat, "X"), range)
|
||||
.AddAxis(string.Format(nameFormat, "Y"), range)
|
||||
.AddAxis(string.Format(nameFormat, "Z"), range);
|
||||
}
|
||||
|
||||
public static AxisSpec With(this in AxisSpec spec, AxisRange range) => new AxisSpec(range, spec.Constraint);
|
||||
}
|
||||
}
|
|
@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Common
|
|||
_buttons.Add(k, source.IsPressed(k) ? 1 : 0);
|
||||
}
|
||||
|
||||
foreach (var k in Definition.AxisControls)
|
||||
foreach (var k in Definition.Axes.Keys)
|
||||
{
|
||||
if (_buttons.Keys.Contains(k))
|
||||
{
|
||||
|
|
|
@ -37,11 +37,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in Port2.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
|
|
|
@ -119,10 +119,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
{
|
||||
BoolButtons = BaseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Paddle X 1" , "P" + PortNum + " Paddle X 2" },
|
||||
AxisRanges = { new ControllerDefinition.AxisRange(-127, 0, 127), new ControllerDefinition.AxisRange(-127, 0, 127) }
|
||||
};
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Paddle X 1", -127, 0, 127)
|
||||
.AddAxis($"P{PortNum} Paddle X 2", -127, 0, 127);
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
@ -152,7 +151,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
public int Read_Pot(IController c, int pot)
|
||||
{
|
||||
int x = (int)c.AxisValue(Definition.AxisControls[pot]);
|
||||
int x = (int)c.AxisValue(Definition.Axes[pot]);
|
||||
|
||||
x = -x;
|
||||
x += 127;
|
||||
|
@ -236,10 +235,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
{
|
||||
BoolButtons = BaseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Wheel X 1", "P" + PortNum + " Wheel X 2" },
|
||||
AxisRanges = { new ControllerDefinition.AxisRange(-127, 0, 127), new ControllerDefinition.AxisRange(-127, 0, 127) }
|
||||
};
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Wheel X 1", -127, 0, 127)
|
||||
.AddAxis($"P{PortNum} Wheel X 2", -127, 0, 127);
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
@ -262,8 +260,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
if (c.IsPressed($"P{PortNum} Button")) { result &= 0xF7; }
|
||||
|
||||
float x = c.AxisValue(Definition.AxisControls[0]);
|
||||
float y = c.AxisValue(Definition.AxisControls[1]);
|
||||
float x = c.AxisValue(Definition.Axes[0]);
|
||||
float y = c.AxisValue(Definition.Axes[1]);
|
||||
|
||||
float angle = CalcDirection(x, y);
|
||||
|
||||
|
|
|
@ -43,11 +43,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in Port2.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
|
|
|
@ -313,8 +313,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
|
||||
public bool Is_LightGun(IController c, out float x, out float y)
|
||||
{
|
||||
x = c.AxisValue(Definition.AxisControls[0]);
|
||||
y = c.AxisValue(Definition.AxisControls[1]);
|
||||
x = c.AxisValue(Definition.Axes[0]);
|
||||
y = c.AxisValue(Definition.Axes[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in Port2.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public float wheel1;
|
||||
|
|
|
@ -148,8 +148,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
|
||||
if (c.IsPressed(Definition.BoolButtons[0])) retVal &= 0x3F;
|
||||
|
||||
float x = c.AxisValue(Definition.AxisControls[0]);
|
||||
float y = c.AxisValue(Definition.AxisControls[1]);
|
||||
float x = c.AxisValue(Definition.Axes[0]);
|
||||
float y = c.AxisValue(Definition.Axes[1]);
|
||||
|
||||
var angle = updateWheel ? wheelAngle : CalcDirection(x, y);
|
||||
|
||||
|
@ -219,8 +219,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
|
||||
public float UpdateWheel(IController c)
|
||||
{
|
||||
float x = c.AxisValue(Definition.AxisControls[0]);
|
||||
float y = c.AxisValue(Definition.AxisControls[1]);
|
||||
float x = c.AxisValue(Definition.Axes[0]);
|
||||
float y = c.AxisValue(Definition.Axes[1]);
|
||||
return CalcDirection(x, y);
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,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.AxisValue(Definition.AxisControls[0]);
|
||||
float y = c.AxisValue(Definition.AxisControls[1]);
|
||||
float x = c.AxisValue(Definition.Axes[0]);
|
||||
float y = c.AxisValue(Definition.Axes[1]);
|
||||
|
||||
var angle = updateWheel ? wheelAngle : CalcDirection(x, y);
|
||||
|
||||
|
@ -348,8 +348,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
|
||||
public float UpdateWheel(IController c)
|
||||
{
|
||||
float x = c.AxisValue(Definition.AxisControls[0]);
|
||||
float y = c.AxisValue(Definition.AxisControls[1]);
|
||||
float x = c.AxisValue(Definition.Axes[0]);
|
||||
float y = c.AxisValue(Definition.Axes[1]);
|
||||
return CalcDirection(x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in Port2.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
|
|
|
@ -38,11 +38,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
Definition.AxisControls.AddRange(Port2.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
Definition.AxisRanges.AddRange(Port2.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in Port2.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
|
|
|
@ -160,8 +160,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
}
|
||||
}
|
||||
|
||||
int x = (int)c.AxisValue(Definition.AxisControls[0]);
|
||||
int y = (int)c.AxisValue(Definition.AxisControls[1]);
|
||||
int x = (int)c.AxisValue(Definition.Axes[0]);
|
||||
int y = (int)c.AxisValue(Definition.Axes[1]);
|
||||
result |= CalcDirection(x, y);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -43,9 +43,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
|
|
|
@ -26,9 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
.ToList()
|
||||
};
|
||||
|
||||
Definition.AxisControls.AddRange(Port1.Definition.AxisControls);
|
||||
|
||||
Definition.AxisRanges.AddRange(Port1.Definition.AxisRanges);
|
||||
foreach (var kvp in Port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
|
|
|
@ -173,8 +173,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
theta_prev = theta;
|
||||
phi_prev = phi;
|
||||
|
||||
theta = (float)(c.AxisValue(Definition.AxisControls[1]) * Math.PI / 180.0);
|
||||
phi = (float)(c.AxisValue(Definition.AxisControls[0]) * Math.PI / 180.0);
|
||||
theta = (float)(c.AxisValue(Definition.Axes[1]) * Math.PI / 180.0);
|
||||
phi = (float)(c.AxisValue(Definition.Axes[0]) * Math.PI / 180.0);
|
||||
|
||||
float temp = (float)(Math.Cos(theta) * Math.Sin(phi));
|
||||
|
||||
|
|
|
@ -34,19 +34,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
static void AddN64StandardController(ControllerDefinition def, int player)
|
||||
{
|
||||
def.BoolButtons.AddRange(new[] { $"P{player} A Up", $"P{player} A Down", $"P{player} A Left", $"P{player} A Right", $"P{player} DPad U", $"P{player} DPad D", $"P{player} DPad L", $"P{player} DPad R", $"P{player} Start", $"P{player} Z", $"P{player} B", $"P{player} A", $"P{player} C Up", $"P{player} C Down", $"P{player} C Right", $"P{player} C Left", $"P{player} L", $"P{player} R" });
|
||||
def.AddXYPair($"P{player} {{0}} Axis", AxisPairOrientation.RightAndUp, -128, 0, 127);
|
||||
def.AxisConstraints.Add(new AxisConstraint
|
||||
{
|
||||
Class = "Natural Circle",
|
||||
Type = AxisConstraintType.Circular,
|
||||
Params = new object[] { $"P{player} X Axis", $"P{player} Y Axis", 127.0f }
|
||||
});
|
||||
def.AddXYPair(
|
||||
$"P{player} {{0}} Axis",
|
||||
AxisPairOrientation.RightAndUp,
|
||||
-128,
|
||||
0,
|
||||
127,
|
||||
new AxisConstraint
|
||||
{
|
||||
Class = "Natural Circle",
|
||||
Type = AxisConstraintType.Circular,
|
||||
Params = new object[] { $"P{player} X Axis", $"P{player} Y Axis", 127.0f }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ControllerDefinition.BoolButtons.Clear();
|
||||
ControllerDefinition.AxisControls.Clear();
|
||||
ControllerDefinition.AxisRanges.Clear();
|
||||
ControllerDefinition.AxisConstraints.Clear();
|
||||
ControllerDefinition.Axes.Clear();
|
||||
|
||||
ControllerDefinition.BoolButtons.AddRange(new[] { "Reset", "Power" });
|
||||
for (var i = 1; i <= 4; i++)
|
||||
|
|
|
@ -160,10 +160,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
}
|
||||
|
||||
// Add in the reset timing axis for subneshawk
|
||||
if (using_reset_timing && ControllerDefinition.AxisControls.Count == 0)
|
||||
if (using_reset_timing && ControllerDefinition.Axes.Count == 0)
|
||||
{
|
||||
ControllerDefinition.AxisControls.Add("Reset Cycle");
|
||||
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 0, 500000));
|
||||
ControllerDefinition.AddAxis("Reset Cycle", 0, 0, 500000);
|
||||
}
|
||||
|
||||
// don't replace the magicSoundProvider on reset, as it's not needed
|
||||
|
|
|
@ -183,8 +183,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
Right.SyncState(ser);
|
||||
ser.EndSection();
|
||||
}
|
||||
|
||||
internal static readonly AxisRange ArkanoidPaddleRange = new AxisRange(0, 80, 160);
|
||||
}
|
||||
|
||||
public class UnpluggedNES : INesPort
|
||||
|
@ -388,12 +386,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
bool resetting = false;
|
||||
byte latchedvalue = 0x54 ^ 0xff;
|
||||
|
||||
static ControllerDefinition Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = { "0Fire" },
|
||||
AxisControls = { "0Paddle" },
|
||||
AxisRanges = { NesDeck.ArkanoidPaddleRange }
|
||||
};
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Fire" } }
|
||||
.AddAxis("0Paddle", 0, 80, 160);
|
||||
|
||||
public void Strobe(StrobeInfo s, IController c)
|
||||
{
|
||||
|
@ -746,12 +741,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
bool resetting = false;
|
||||
byte latchedvalue = 0x54 ^ 0xff;
|
||||
|
||||
static ControllerDefinition Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = { "0Fire" },
|
||||
AxisControls = { "0Paddle" },
|
||||
AxisRanges = { NesDeck.ArkanoidPaddleRange }
|
||||
};
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Fire" } }
|
||||
.AddAxis("0Paddle", 0, 80, 160);
|
||||
|
||||
public void Strobe(StrobeInfo s, IController c)
|
||||
{
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
|
||||
public void ApplyState(IController controller, short[] input, int offset)
|
||||
{
|
||||
foreach (var s in Definition.AxisControls)
|
||||
foreach (var s in Definition.Axes.Keys)
|
||||
input[offset++] = (short)(controller.AxisValue(s));
|
||||
foreach (var s in Definition.BoolButtons)
|
||||
input[offset++] = (short)(controller.IsPressed(s) ? 1 : 0);
|
||||
|
|
|
@ -41,8 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
|
|||
_tracer = new TraceBuffer { Header = _GBCore.cpu.TraceHeader };
|
||||
ser.Register(_tracer);
|
||||
|
||||
_GBCore.ControllerDefinition.AxisControls.Add("Input Cycle");
|
||||
_GBCore.ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 70224, 70224));
|
||||
_GBCore.ControllerDefinition.AddAxis("Input Cycle", 0, 70224, 70224);
|
||||
}
|
||||
|
||||
public GBHawk.GBHawk _GBCore;
|
||||
|
|
|
@ -43,18 +43,11 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
.Concat(_port5.Definition.BoolButtons)
|
||||
.ToList()
|
||||
};
|
||||
|
||||
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.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);
|
||||
foreach (var kvp in _port1.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in _port2.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in _port3.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in _port4.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
foreach (var kvp in _port5.Definition.Axes) Definition.Axes.Add(kvp);
|
||||
}
|
||||
|
||||
private readonly IPort _port1;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
||||
{
|
||||
public partial class SMS : IEmulator
|
||||
|
@ -24,8 +26,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
return SMSPaddleController;
|
||||
case SmsSyncSettings.ControllerTypes.LightPhaser:
|
||||
// scale the vertical to the display mode
|
||||
SMSLightPhaserController.AxisRanges[1] = new ControllerDefinition.AxisRange(0, Vdp.FrameHeight / 2, Vdp.FrameHeight - 1);
|
||||
|
||||
var axisName = SMSLightPhaserController.Axes[1];
|
||||
SMSLightPhaserController.Axes[axisName] = SMSLightPhaserController.Axes[axisName]
|
||||
.With(range: new AxisRange(0, Vdp.FrameHeight / 2, Vdp.FrameHeight - 1));
|
||||
return SMSLightPhaserController;
|
||||
case SmsSyncSettings.ControllerTypes.SportsPad:
|
||||
return SMSSportsPadController;
|
||||
|
|
|
@ -38,18 +38,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
"Reset", "Pause",
|
||||
"P1 Left", "P1 Right", "P1 B1",
|
||||
"P2 Left", "P2 Right", "P2 B1",
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"P1 Paddle",
|
||||
"P2 Paddle"
|
||||
},
|
||||
AxisRanges =
|
||||
{
|
||||
new AxisRange(0, 128, 255),
|
||||
new AxisRange(0, 128, 255)
|
||||
}
|
||||
};
|
||||
}.AddAxis("P1 Paddle", 0, 128, 255)
|
||||
.AddAxis("P2 Paddle", 0, 128, 255);
|
||||
|
||||
public static readonly ControllerDefinition SMSLightPhaserController = new ControllerDefinition
|
||||
{
|
||||
|
|
|
@ -272,19 +272,11 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
"P" + pnum + " A",
|
||||
});
|
||||
|
||||
definition.AxisControls.AddRange(new[]
|
||||
{
|
||||
"P" + pnum + " Twist",
|
||||
"P" + pnum + " 1",
|
||||
"P" + pnum + " 2",
|
||||
"P" + pnum + " L"
|
||||
});
|
||||
|
||||
var axisRange = new AxisRange(0, 128, 255);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
definition.AddAxis($"P{pnum} Twist", axisRange);
|
||||
definition.AddAxis($"P{pnum} 1", axisRange);
|
||||
definition.AddAxis($"P{pnum} 2", axisRange);
|
||||
definition.AddAxis($"P{pnum} L", axisRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -325,13 +317,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
"Reset"
|
||||
});
|
||||
|
||||
definition.AxisControls.Add("Disc Select");
|
||||
|
||||
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 AxisRange(0, 1, 1)
|
||||
);
|
||||
definition.AddAxis("Disc Select", new AxisRange(0, 1, 1));
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using BizHawk.Emulation.Common;
|
||||
using NymaTypes;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
using static BizHawk.Emulation.Cores.Waterbox.LibNymaCore;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Waterbox
|
||||
|
@ -176,11 +178,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
var data = input.Extra.AsAxis();
|
||||
var fullName = $"{name} {overrideName(data.NameNeg)} / {overrideName(data.NamePos)}";
|
||||
|
||||
ret.AxisControls.Add(fullName);
|
||||
ret.AddAxis(fullName, new AxisRange(0, 0x8000, 0xFFFF, (input.Flags & AxisFlags.InvertCo) != 0));
|
||||
ret.CategoryLabels[fullName] = category;
|
||||
ret.AxisRanges.Add(new ControllerDefinition.AxisRange(
|
||||
0, 0x8000, 0xffff, (input.Flags & AxisFlags.InvertCo) != 0
|
||||
));
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(fullName);
|
||||
|
@ -194,15 +193,12 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
var data = input.Extra.AsAxis();
|
||||
var fullName = $"{name} {input.Extra.AsAxis().NameNeg} / {input.Extra.AsAxis().NamePos}";
|
||||
|
||||
ret.AxisControls.Add(fullName);
|
||||
// TODO: Mednafen docs say this range should be [-32768, 32767], and inspecting the code
|
||||
// reveals that a 16 bit value is read, but using anywhere near this full range makes
|
||||
// PCFX mouse completely unusable. Maybe this is some TAS situation where average users
|
||||
// will want a 1/400 multiplier on sensitivity but TASers might want one frame screenwide movement?
|
||||
ret.AddAxis(fullName, new AxisRange(-127, 0, 127, (input.Flags & AxisFlags.InvertCo) != 0));
|
||||
ret.CategoryLabels[fullName] = category;
|
||||
ret.AxisRanges.Add(new ControllerDefinition.AxisRange(
|
||||
// TODO: Mednafen docs say this range should be [-32768, 32767], and inspecting the code
|
||||
// reveals that a 16 bit value is read, but using anywhere near this full range makes
|
||||
// PCFX mouse completely unusable. Maybe this is some TAS situation where average users
|
||||
// will want a 1/400 multiplier on sensitivity but TASers might want one frame screenwide movement?
|
||||
-127, 0, 127, (input.Flags & AxisFlags.InvertCo) != 0
|
||||
));
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(fullName);
|
||||
|
@ -214,9 +210,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
case InputType.PointerX:
|
||||
{
|
||||
// I think the core expects to be sent some sort of 16 bit integer, but haven't investigated much
|
||||
ret.AxisControls.Add(name);
|
||||
ret.AxisRanges.Add(new ControllerDefinition.AxisRange(
|
||||
systemInfo.PointerOffsetX, systemInfo.PointerOffsetX, systemInfo.PointerScaleX));
|
||||
ret.AddAxis(name, new AxisRange(systemInfo.PointerOffsetX, systemInfo.PointerOffsetX, systemInfo.PointerScaleX));
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(name);
|
||||
|
@ -228,9 +222,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
case InputType.PointerY:
|
||||
{
|
||||
// I think the core expects to be sent some sort of 16 bit integer, but haven't investigated much
|
||||
ret.AxisControls.Add(name);
|
||||
ret.AxisRanges.Add(new ControllerDefinition.AxisRange(
|
||||
systemInfo.PointerOffsetY, systemInfo.PointerOffsetY, systemInfo.PointerScaleY));
|
||||
ret.AddAxis(name, new AxisRange(systemInfo.PointerOffsetY, systemInfo.PointerOffsetY, systemInfo.PointerScaleY));
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(name);
|
||||
|
@ -241,11 +233,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
}
|
||||
case InputType.ButtonAnalog:
|
||||
{
|
||||
ret.AxisControls.Add(name);
|
||||
ret.AddAxis(name, new AxisRange(0, 0, 0xFFFF));
|
||||
ret.CategoryLabels[name] = category;
|
||||
ret.AxisRanges.Add(new ControllerDefinition.AxisRange(
|
||||
0, 0, 0xffff, false
|
||||
));
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(name);
|
||||
|
|
Loading…
Reference in New Issue