Merge AxisRange into AxisSpec
was going to move only Mid but this made more sense
This commit is contained in:
parent
6cb60aa9fd
commit
15906af6e4
|
@ -14,8 +14,8 @@ namespace BizHawk.Client.Common
|
|||
Definition = definition;
|
||||
foreach (var kvp in Definition.Axes)
|
||||
{
|
||||
_axes[kvp.Key] = kvp.Value.Range.Mid;
|
||||
_axisRanges[kvp.Key] = kvp.Value.Range;
|
||||
_axes[kvp.Key] = kvp.Value.Mid;
|
||||
_axisRanges[kvp.Key] = kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace BizHawk.Client.Common
|
|||
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, int> _axes = new WorkingDictionary<string, int>();
|
||||
private readonly Dictionary<string, ControllerDefinition.AxisRange> _axisRanges = new WorkingDictionary<string, ControllerDefinition.AxisRange>();
|
||||
private readonly Dictionary<string, ControllerDefinition.AxisSpec> _axisRanges = new WorkingDictionary<string, ControllerDefinition.AxisSpec>();
|
||||
private readonly Dictionary<string, AnalogBind> _axisBindings = new Dictionary<string, AnalogBind>();
|
||||
|
||||
/// <summary>don't do this</summary>
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var val = (int)_source.AxisValue(button);
|
||||
|
||||
if (val == range.Range.Mid)
|
||||
if (val == range.Mid)
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace BizHawk.Client.Common
|
|||
// axes don't have sticky logic, so latch default value
|
||||
foreach (var kvp in Definition.Axes)
|
||||
{
|
||||
_myAxisControls[kvp.Key] = kvp.Value.Range.Mid;
|
||||
_myAxisControls[kvp.Key] = kvp.Value.Mid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (createEmpty)
|
||||
{
|
||||
val = range.Range.Mid;
|
||||
val = range.Mid;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.NDS;
|
||||
|
||||
|
@ -88,7 +90,7 @@ 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
|
||||
}.AddXYPair("Touch{0}", ControllerDefinition.AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(191), 96) //TODO verify direction against hardware
|
||||
};
|
||||
|
||||
controller["LidOpen"] = false;
|
||||
|
|
|
@ -296,7 +296,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
foreach (string name in latching.Definition.Axes.Keys)
|
||||
{
|
||||
var axisValue = source.AxisValue(name);
|
||||
if (axisValue == source.Definition.Axes[name].Range.Mid)
|
||||
if (axisValue == source.Definition.Axes[name].Mid)
|
||||
{
|
||||
latching.SetAxis(name, axisValue);
|
||||
}
|
||||
|
|
|
@ -358,7 +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
|
||||
if (text == ((float) ControllerType.Axes[columnName].Range.Mid).ToString())
|
||||
if (text == ((float) ControllerType.Axes[columnName].Mid).ToString())
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
|
@ -1201,7 +1201,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.Axes[_axisEditColumn].Range.Range);
|
||||
var value = (_axisPaintState + increment).ConstrainWithin(ControllerType.Axes[_axisEditColumn].Range);
|
||||
CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, value);
|
||||
_axisTypedValue = value.ToString();
|
||||
|
||||
|
@ -1275,12 +1275,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
string prevTyped = _axisTypedValue;
|
||||
|
||||
var range = ControllerType.Axes[_axisEditColumn];
|
||||
var (rMin, rMax) = range.Range.FloatRange;
|
||||
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.Range.MaxDigits;
|
||||
int maxDigits = range.MaxDigits;
|
||||
int curDigits = _axisTypedValue.Length;
|
||||
string curMinus;
|
||||
if (_axisTypedValue.StartsWith("-"))
|
||||
|
|
|
@ -424,7 +424,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (ControllerType.Axes.TryGetValue(kvp.Key, out var range))
|
||||
{
|
||||
type = ColumnType.Axis;
|
||||
digits = Math.Max(kvp.Value.Length, range.Range.MaxDigits);
|
||||
digits = Math.Max(kvp.Value.Length, range.MaxDigits);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -96,8 +96,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
SecondaryName = analog.SecondaryName,
|
||||
Location = UIHelper.Scale(analog.Location),
|
||||
Size = UIHelper.Scale(new Size(180 + 79, 200 + 9)),
|
||||
RangeX = analog.AxisRange,
|
||||
RangeY = analog.SecondaryAxisRange
|
||||
RangeX = analog.Spec,
|
||||
RangeY = analog.SecondarySpec
|
||||
},
|
||||
TargetedPairSchema targetedPair => new VirtualPadTargetScreen
|
||||
{
|
||||
|
|
|
@ -7,6 +7,8 @@ using BizHawk.Emulation.Common;
|
|||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class VirtualPadAnalogStick : UserControl, IVirtualPadControl
|
||||
|
@ -30,9 +32,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
manualTheta.ValueChanged += PolarNumeric_Changed;
|
||||
}
|
||||
|
||||
public ControllerDefinition.AxisRange RangeX { get; set; }
|
||||
public AxisSpec RangeX { get; set; }
|
||||
|
||||
public ControllerDefinition.AxisRange RangeY { get; set; }
|
||||
public AxisSpec RangeY { get; set; }
|
||||
|
||||
public string? SecondaryName { get; set; }
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ using BizHawk.Common;
|
|||
using BizHawk.Common.NumberExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public sealed class AnalogStickPanel : Panel
|
||||
|
@ -53,7 +55,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Refresh();
|
||||
}
|
||||
|
||||
public void Init(string nameX, ControllerDefinition.AxisRange rangeX, string nameY, ControllerDefinition.AxisRange rangeY)
|
||||
public void Init(string nameX, AxisSpec rangeX, string nameY, AxisSpec rangeY)
|
||||
{
|
||||
Name = XName = nameX;
|
||||
_fullRangeX = rangeX;
|
||||
|
@ -64,8 +66,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private Range<int> _rangeX = 0.RangeTo(0);
|
||||
private Range<int> _rangeY = 0.RangeTo(0);
|
||||
private ControllerDefinition.AxisRange _fullRangeX;
|
||||
private ControllerDefinition.AxisRange _fullRangeY;
|
||||
private AxisSpec _fullRangeX;
|
||||
private AxisSpec _fullRangeY;
|
||||
|
||||
private bool _reverseX;
|
||||
private bool _reverseY;
|
||||
|
|
|
@ -56,8 +56,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
new AnalogSchema(6, 14, $"P{controller} Disc X")
|
||||
{
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
Spec = defAxes.SpecAtIndex(0),
|
||||
SecondarySpec = defAxes.SpecAtIndex(1)
|
||||
},
|
||||
new ButtonSchema(6, 224, controller, "Pedal")
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
new AnalogSchema(1, 121, $"P{controller} Disc X")
|
||||
{
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
Spec = defAxes.SpecAtIndex(0),
|
||||
SecondarySpec = defAxes.SpecAtIndex(1)
|
||||
}
|
||||
})
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64;
|
||||
|
||||
|
@ -59,8 +60,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
},
|
||||
new AnalogSchema(6, 14, $"P{controller} X Axis")
|
||||
{
|
||||
AxisRange = new AxisRange(-128, 0, 127),
|
||||
SecondaryAxisRange = new AxisRange(-128, 0, 127)
|
||||
Spec = new AxisSpec((-128).RangeTo(127), 0),
|
||||
SecondarySpec = new AxisSpec((-128).RangeTo(127), 0)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Sony.PSX;
|
||||
|
||||
|
@ -47,7 +48,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema DualShockController(int controller)
|
||||
{
|
||||
var stickRanges = CreateAxisRangePair(0, 128, 255, AxisPairOrientation.RightAndDown);
|
||||
var stickRanges = new[] { new AxisSpec(0.RangeTo(255), 128), new AxisSpec(0.RangeTo(255), 128, isReversed: true) };
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(500, 290),
|
||||
|
@ -90,13 +91,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
},
|
||||
new AnalogSchema(3, 120, $"P{controller} LStick X")
|
||||
{
|
||||
AxisRange = stickRanges[0],
|
||||
SecondaryAxisRange = stickRanges[1]
|
||||
Spec = stickRanges[0],
|
||||
SecondarySpec = stickRanges[1]
|
||||
},
|
||||
new AnalogSchema(260, 120, $"P{controller} RStick X")
|
||||
{
|
||||
AxisRange = stickRanges[0],
|
||||
SecondaryAxisRange = stickRanges[1]
|
||||
Spec = stickRanges[0],
|
||||
SecondarySpec = stickRanges[1]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,6 +7,8 @@ using System.Windows.Forms;
|
|||
using BizHawk.Client.EmuHawk.Properties;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public abstract class PadSchemaControl
|
||||
|
@ -88,9 +90,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <summary>An analog stick (X, Y) pair</summary>
|
||||
public sealed class AnalogSchema : PadSchemaControl
|
||||
{
|
||||
public ControllerDefinition.AxisRange AxisRange { get; set; }
|
||||
public AxisSpec Spec { get; set; }
|
||||
|
||||
public ControllerDefinition.AxisRange SecondaryAxisRange { get; set; }
|
||||
public AxisSpec SecondarySpec { get; set; }
|
||||
|
||||
public string SecondaryName { get; set; }
|
||||
|
||||
|
|
|
@ -3,10 +3,13 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.PCEngine;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[Schema("PCECD")]
|
||||
|
@ -140,7 +143,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema Mouse(int controller)
|
||||
{
|
||||
var range = new ControllerDefinition.AxisRange(-127, 0, 127);
|
||||
var range = new AxisSpec((-127).RangeTo(127), 0);
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(345, 225),
|
||||
|
@ -149,8 +152,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
new AnalogSchema(6, 14, $"P{controller} Motion Left / Right")
|
||||
{
|
||||
SecondaryName = $"P{controller} Motion Up / Down",
|
||||
AxisRange = range,
|
||||
SecondaryAxisRange = range
|
||||
Spec = range,
|
||||
SecondarySpec = range
|
||||
},
|
||||
new ButtonSchema(275, 15, controller, "Left Button")
|
||||
{
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[Schema("PCFX")]
|
||||
|
@ -69,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private static PadSchema Mouse(int controller)
|
||||
{
|
||||
var range = new ControllerDefinition.AxisRange(-127, 0, 127);
|
||||
var range = new AxisSpec((-127).RangeTo(127), 0);
|
||||
return new PadSchema
|
||||
{
|
||||
Size = new Size(345, 225),
|
||||
|
@ -78,8 +82,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
new AnalogSchema(6, 14, $"P{controller} Motion Left / Right")
|
||||
{
|
||||
SecondaryName = $"P{controller} Motion Up / Down",
|
||||
AxisRange = range,
|
||||
SecondaryAxisRange = range
|
||||
Spec = range,
|
||||
SecondarySpec = range
|
||||
},
|
||||
new ButtonSchema(275, 15, controller, "Left Button")
|
||||
{
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
@ -12,7 +14,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// ReSharper disable once UnusedMember.Global
|
||||
public class SaturnSchema : IVirtualPadSchema
|
||||
{
|
||||
private static readonly AxisRange AxisRange = new AxisRange(0, 0x8000, 0xffff);
|
||||
private static readonly AxisSpec AxisRange = new AxisSpec(0.RangeTo(0xffff), 0x8000);
|
||||
|
||||
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
|
||||
{
|
||||
|
@ -103,8 +105,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
new AnalogSchema(6, 74, $"P{controller} Analog Left / Right")
|
||||
{
|
||||
SecondaryName = $"P{controller} Analog Up / Down",
|
||||
AxisRange = AxisRange,
|
||||
SecondaryAxisRange = AxisRange
|
||||
Spec = AxisRange,
|
||||
SecondarySpec = AxisRange
|
||||
},
|
||||
new SingleAxisSchema(8, 12, controller, "L")
|
||||
{
|
||||
|
@ -202,8 +204,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
new AnalogSchema(195, 13, $"P{controller} Stick Left / Right")
|
||||
{
|
||||
SecondaryName = $"P{controller} Stick Fore / Back",
|
||||
AxisRange = AxisRange,
|
||||
SecondaryAxisRange = AxisRange
|
||||
Spec = AxisRange,
|
||||
SecondarySpec = AxisRange
|
||||
},
|
||||
new SingleAxisSchema(135, 13, controller, "Throttle Down / Up", isVertical: true)
|
||||
{
|
||||
|
@ -227,8 +229,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
new AnalogSchema(68, 13, $"P{controller} L Stick Left / Right")
|
||||
{
|
||||
SecondaryName = $"P{controller} L Stick Fore / Back",
|
||||
AxisRange = AxisRange,
|
||||
SecondaryAxisRange = AxisRange
|
||||
Spec = AxisRange,
|
||||
SecondarySpec = AxisRange
|
||||
},
|
||||
new SingleAxisSchema(8, 13, controller, "L Throttle Down / Up", isVertical: true)
|
||||
{
|
||||
|
@ -251,8 +253,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
new AnalogSchema(570, 13, $"P{controller} R Stick Left / Right")
|
||||
{
|
||||
SecondaryName = $"P{controller} R Stick Fore / Back",
|
||||
AxisRange = AxisRange,
|
||||
SecondaryAxisRange = AxisRange
|
||||
Spec = AxisRange,
|
||||
SecondarySpec = AxisRange
|
||||
},
|
||||
new SingleAxisSchema(510, 13, controller, "R Throttle Down / Up", isVertical: true)
|
||||
{
|
||||
|
|
|
@ -167,8 +167,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
new AnalogSchema(6, 14, $"P{controller} Mouse X")
|
||||
{
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
Spec = defAxes.SpecAtIndex(0),
|
||||
SecondarySpec = defAxes.SpecAtIndex(1)
|
||||
},
|
||||
new ButtonSchema(275, 15, controller, "Mouse Left")
|
||||
{
|
||||
|
|
|
@ -72,8 +72,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
Button(146, 34, controller, 4),
|
||||
new AnalogSchema(2, 80, $"P{controller} Stick X")
|
||||
{
|
||||
AxisRange = defAxes.SpecAtIndex(0).Range,
|
||||
SecondaryAxisRange = defAxes.SpecAtIndex(1).Range
|
||||
Spec = defAxes.SpecAtIndex(0),
|
||||
SecondarySpec = defAxes.SpecAtIndex(1)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -99,11 +99,27 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public readonly AxisConstraint? Constraint;
|
||||
|
||||
public readonly AxisRange Range;
|
||||
public Range<float> FloatRange => ((float) Min).RangeTo(Max);
|
||||
|
||||
public AxisSpec(AxisRange range, AxisConstraint? constraint = null)
|
||||
public readonly bool IsReversed;
|
||||
|
||||
public int Max => Range.EndInclusive;
|
||||
|
||||
/// <value>maximum decimal digits analog input can occupy with no-args ToString</value>
|
||||
/// <remarks>does not include the extra char needed for a minus sign</remarks>
|
||||
public int MaxDigits => Math.Max(Math.Abs(Min).ToString().Length, Math.Abs(Max).ToString().Length);
|
||||
|
||||
public readonly int Mid;
|
||||
|
||||
public int Min => Range.Start;
|
||||
|
||||
public readonly Range<int> Range;
|
||||
|
||||
public AxisSpec(Range<int> range, int mid, bool isReversed = false, AxisConstraint? constraint = null)
|
||||
{
|
||||
Constraint = constraint;
|
||||
IsReversed = isReversed;
|
||||
Mid = mid;
|
||||
Range = range;
|
||||
}
|
||||
}
|
||||
|
@ -151,42 +167,6 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
}
|
||||
|
||||
public readonly struct AxisRange
|
||||
{
|
||||
public readonly bool IsReversed;
|
||||
|
||||
public readonly int Max;
|
||||
|
||||
/// <remarks>used as default/neutral/unset</remarks>
|
||||
public readonly int Mid;
|
||||
|
||||
public readonly int Min;
|
||||
|
||||
public Range<float> FloatRange => ((float) Min).RangeTo(Max);
|
||||
|
||||
/// <value>maximum decimal digits analog input can occupy with no-args ToString</value>
|
||||
/// <remarks>does not include the extra char needed for a minus sign</remarks>
|
||||
public int MaxDigits => Math.Max(Math.Abs(Min).ToString().Length, Math.Abs(Max).ToString().Length);
|
||||
|
||||
public Range<int> Range => Min.RangeTo(Max);
|
||||
|
||||
public AxisRange(int min, int mid, int max, bool isReversed = false)
|
||||
{
|
||||
const string ReversedBoundsExceptionMessage = nameof(AxisRange) + " must not have " + nameof(max) + " < " + nameof(min) + ". pass " + nameof(isReversed) + ": true to ctor instead, or use " + nameof(CreateAxisRangePair);
|
||||
if (max < min) throw new ArgumentOutOfRangeException(nameof(max), max, ReversedBoundsExceptionMessage);
|
||||
IsReversed = isReversed;
|
||||
Max = max;
|
||||
Mid = mid;
|
||||
Min = min;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<AxisRange> CreateAxisRangePair(int min, int mid, int max, AxisPairOrientation pDir) => new List<AxisRange>
|
||||
{
|
||||
new AxisRange(min, mid, max, ((byte) pDir & 2) != 0),
|
||||
new AxisRange(min, mid, max, ((byte) pDir & 1) != 0)
|
||||
};
|
||||
|
||||
/// <summary>represents the direction of <c>(+, +)</c></summary>
|
||||
/// <remarks>docs of individual controllers are being collected in comments of https://github.com/TASVideos/BizHawk/issues/1200</remarks>
|
||||
public enum AxisPairOrientation : byte
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
||||
|
@ -406,20 +407,21 @@ namespace BizHawk.Emulation.Common
|
|||
/// </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, AxisRange range, AxisConstraint? constraint = null)
|
||||
public static ControllerDefinition AddAxis(this ControllerDefinition def, string name, Range<int> range, int mid, bool isReversed = false, AxisConstraint? constraint = null)
|
||||
{
|
||||
def.Axes.Add(name, new AxisSpec(range, constraint));
|
||||
def.Axes.Add(name, new AxisSpec(range, mid, isReversed, 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.
|
||||
/// 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="constraint">pass only for one axis in a pair, by convention the X axis</param>
|
||||
/// <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 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);
|
||||
public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, Range<int> rangeX, int midX, Range<int> rangeY, int midY, AxisConstraint? constraint = null)
|
||||
=> def.AddAxis(string.Format(nameFormat, "X"), rangeX, midX, ((byte) pDir & 2) != 0, constraint)
|
||||
.AddAxis(string.Format(nameFormat, "Y"), rangeY, midY, ((byte) pDir & 1) != 0);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an X/Y pair of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
|
@ -427,18 +429,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, 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.
|
||||
/// 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, AxisConstraint? constraint = null)
|
||||
=> def.AddXYPair(nameFormat, pDir, (minBoth, midBoth, maxBoth), (minBoth, midBoth, maxBoth), constraint);
|
||||
public static ControllerDefinition AddXYPair(this ControllerDefinition def, string nameFormat, AxisPairOrientation pDir, Range<int> rangeBoth, int midBoth, AxisConstraint? constraint = null)
|
||||
=> def.AddXYPair(nameFormat, pDir, rangeBoth, midBoth, rangeBoth, midBoth, constraint);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an X/Y/Z triple of axes to the receiver <see cref="ControllerDefinition"/>, and returns it.
|
||||
|
@ -446,14 +438,11 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
/// <param name="nameFormat">format string e.g. <c>"P1 Tilt {0}"</c> (will be used to interpolate <c>"X"</c>, <c>"Y"</c>, and <c>"Z"</c>)</param>
|
||||
/// <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)
|
||||
{
|
||||
var range = new AxisRange(minAll, midAll, maxAll);
|
||||
return def.AddAxis(string.Format(nameFormat, "X"), range)
|
||||
.AddAxis(string.Format(nameFormat, "Y"), range)
|
||||
.AddAxis(string.Format(nameFormat, "Z"), range);
|
||||
}
|
||||
public static ControllerDefinition AddXYZTriple(this ControllerDefinition def, string nameFormat, Range<int> rangeAll, int midAll)
|
||||
=> def.AddAxis(string.Format(nameFormat, "X"), rangeAll, midAll)
|
||||
.AddAxis(string.Format(nameFormat, "Y"), rangeAll, midAll)
|
||||
.AddAxis(string.Format(nameFormat, "Z"), rangeAll, midAll);
|
||||
|
||||
public static AxisSpec With(this in AxisSpec spec, AxisRange range) => new AxisSpec(range, spec.Constraint);
|
||||
public static AxisSpec With(this in AxisSpec spec, Range<int> range, int mid) => new AxisSpec(range, mid, spec.IsReversed, spec.Constraint);
|
||||
}
|
||||
}
|
|
@ -120,8 +120,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
BoolButtons = BaseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Paddle X 1", -127, 0, 127)
|
||||
.AddAxis($"P{PortNum} Paddle X 2", -127, 0, 127);
|
||||
}.AddAxis($"P{PortNum} Paddle X 1", (-127).RangeTo(127), 0)
|
||||
.AddAxis($"P{PortNum} Paddle X 2", (-127).RangeTo(127), 0);
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
@ -236,8 +236,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
BoolButtons = BaseDefinition
|
||||
.Select(b => $"P{PortNum} " + b)
|
||||
.ToList()
|
||||
}.AddAxis($"P{PortNum} Wheel X 1", -127, 0, 127)
|
||||
.AddAxis($"P{PortNum} Wheel X 2", -127, 0, 127);
|
||||
}.AddAxis($"P{PortNum} Wheel X 1", (-127).RangeTo(127), 0)
|
||||
.AddAxis($"P{PortNum} Wheel X 2", (-127).RangeTo(127), 0);
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
{
|
||||
Name = "Light Gun Controller",
|
||||
BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList()
|
||||
}.AddXYPair($"P{PortNum} {{0}}", AxisPairOrientation.RightAndUp, (1, 160, 320), (1, 121, 242)); //TODO verify direction against hardware
|
||||
}.AddXYPair($"P{PortNum} {{0}}", AxisPairOrientation.RightAndUp, 1.RangeTo(320), 160, 1.RangeTo(242), 121); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Belogic
|
||||
|
@ -62,7 +64,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic
|
|||
{
|
||||
Name = "SNES Controller",
|
||||
BoolButtons = { "P1 Mouse Left", "P1 Mouse Right", "Power" }
|
||||
}.AddXYPair("P1 Mouse {0}", AxisPairOrientation.RightAndUp, -127, 0, 127); //TODO verify direction against hardware
|
||||
}.AddXYPair("P1 Mouse {0}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware
|
||||
|
||||
private static readonly string[] PadBits =
|
||||
{
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
{
|
||||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() }
|
||||
.AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, -127, 0, 127); //TODO verify direction against hardware
|
||||
.AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
@ -232,7 +232,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
{
|
||||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() }
|
||||
.AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, -127, 0, 127); //TODO verify direction against hardware
|
||||
.AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
{
|
||||
Name = "Vectrex Analog Controller",
|
||||
BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList()
|
||||
}.AddXYPair($"P{PortNum} Stick {{0}}", AxisPairOrientation.RightAndUp, -128, 0, 127);
|
||||
}.AddXYPair($"P{PortNum} Stick {{0}}", AxisPairOrientation.RightAndUp, (-128).RangeTo(127), 0);
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
{
|
||||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition { BoolButtons = BaseBoolDefinition.Select(b => $"P{PortNum} {b}").ToList() }
|
||||
.AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, -127, 0, 127); //TODO verify direction against hardware
|
||||
.AddXYPair($"P{PortNum} Disc {{0}}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
||||
|
@ -258,7 +260,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
{
|
||||
Name = "GBA Controller",
|
||||
BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power" }
|
||||
}.AddXYZTriple("Tilt {0}", -32767, 0, 32767)
|
||||
.AddAxis("Light Sensor", 0, 100, 200);
|
||||
}.AddXYZTriple("Tilt {0}", (-32767).RangeTo(32767), 0)
|
||||
.AddAxis("Light Sensor", 0.RangeTo(200), 100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
{
|
||||
Name = "Gameboy Controller + Tilt",
|
||||
BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList()
|
||||
}.AddXYPair($"P{PortNum} Tilt {{0}}", AxisPairOrientation.RightAndUp, -45, 0, 45); //TODO verify direction against hardware
|
||||
}.AddXYPair($"P{PortNum} Tilt {{0}}", AxisPairOrientation.RightAndUp, (-45).RangeTo(45), 0); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
|
@ -37,9 +38,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
|
|||
def.AddXYPair(
|
||||
$"P{player} {{0}} Axis",
|
||||
AxisPairOrientation.RightAndUp,
|
||||
-128,
|
||||
(-128).RangeTo(127),
|
||||
0,
|
||||
127,
|
||||
new AxisConstraint
|
||||
{
|
||||
Class = "Natural Circle",
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
@ -100,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
ControllerDefinition.BoolButtons.Add("Power");
|
||||
|
||||
ControllerDefinition.BoolButtons.Add("Touch");
|
||||
ControllerDefinition.AddXYPair("Touch{0}", AxisPairOrientation.RightAndUp, (0, 128, 255), (0, 96, 191)); //TODO verify direction against hardware
|
||||
ControllerDefinition.AddXYPair("Touch{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(191), 96); //TODO verify direction against hardware
|
||||
|
||||
CoreComm = comm;
|
||||
_resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DEFAULT, 32768, 44100, 32768, 44100);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Components.M6502;
|
||||
|
||||
|
@ -162,7 +163,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
// Add in the reset timing axis for subneshawk
|
||||
if (using_reset_timing && ControllerDefinition.Axes.Count == 0)
|
||||
{
|
||||
ControllerDefinition.AddAxis("Reset Cycle", 0, 0, 500000);
|
||||
ControllerDefinition.AddAxis("Reset Cycle", 0.RangeTo(500000), 0);
|
||||
}
|
||||
|
||||
// don't replace the magicSoundProvider on reset, as it's not needed
|
||||
|
|
|
@ -388,7 +388,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Fire" } }
|
||||
.AddAxis("0Paddle", 0, 80, 160);
|
||||
.AddAxis("0Paddle", 0.RangeTo(160), 80);
|
||||
|
||||
public void Strobe(StrobeInfo s, IController c)
|
||||
{
|
||||
|
@ -538,7 +538,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
internal static class NESControllerDefExtensions
|
||||
{
|
||||
public static ControllerDefinition AddZapper(this ControllerDefinition def, string nameFormat)
|
||||
=> def.AddXYPair(nameFormat, AxisPairOrientation.RightAndUp, (0, 128, 255), (0, 120, 239)); //TODO verify direction against hardware
|
||||
=> def.AddXYPair(nameFormat, AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(239), 120); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
// Dummy interface to indicate zapper behavior, used as a means of type checking for zapper functionality
|
||||
|
@ -743,7 +743,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Fire" } }
|
||||
.AddAxis("0Paddle", 0, 80, 160);
|
||||
.AddAxis("0Paddle", 0.RangeTo(160), 80);
|
||||
|
||||
public void Strobe(StrobeInfo s, IController c)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common.NumberExtensions;
|
||||
|
||||
|
@ -92,7 +93,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
/// for reference Snes9x is always in 224 mode
|
||||
/// </remarks>
|
||||
public static ControllerDefinition AddLightGun(this ControllerDefinition def, string nameFormat)
|
||||
=> def.AddXYPair(nameFormat, AxisPairOrientation.RightAndUp, (0, 128, 256), (0, 0, 240)); //TODO verify direction against hardware
|
||||
=> def.AddXYPair(nameFormat, AxisPairOrientation.RightAndUp, 0.RangeTo(256), 128, 0.RangeTo(240), 0); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public interface ILibsnesController
|
||||
|
@ -287,7 +288,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
private static readonly ControllerDefinition _definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Mouse Left", "0Mouse Right" } }
|
||||
.AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndDown, -127, 0, 127); //TODO verify direction against hardware, R+D inferred from behaviour in Mario Paint
|
||||
.AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndDown, (-127).RangeTo(127), 0); //TODO verify direction against hardware, R+D inferred from behaviour in Mario Paint
|
||||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
{
|
||||
private static readonly ControllerDefinition _definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Mouse Left", "0Mouse Right" } }
|
||||
.AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndUp, -127, 0, 127); //TODO verify direction against hardware
|
||||
.AddXYPair("0Mouse {0}", AxisPairOrientation.RightAndUp, (-127).RangeTo(127), 0); //TODO verify direction against hardware
|
||||
|
||||
public override ControllerDefinition Definition => _definition;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
|
||||
{
|
||||
|
@ -41,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk
|
|||
_tracer = new TraceBuffer { Header = _GBCore.cpu.TraceHeader };
|
||||
ser.Register(_tracer);
|
||||
|
||||
_GBCore.ControllerDefinition.AddAxis("Input Cycle", 0, 70224, 70224);
|
||||
_GBCore.ControllerDefinition.AddAxis("Input Cycle", 0.RangeTo(70224), 70224);
|
||||
}
|
||||
|
||||
public GBHawk.GBHawk _GBCore;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
|
@ -28,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
// scale the vertical to the display mode
|
||||
var axisName = SMSLightPhaserController.Axes[1];
|
||||
SMSLightPhaserController.Axes[axisName] = SMSLightPhaserController.Axes[axisName]
|
||||
.With(range: new AxisRange(0, Vdp.FrameHeight / 2, Vdp.FrameHeight - 1));
|
||||
.With(0.RangeTo(Vdp.FrameHeight - 1), Vdp.FrameHeight / 2);
|
||||
return SMSLightPhaserController;
|
||||
case SmsSyncSettings.ControllerTypes.SportsPad:
|
||||
return SMSSportsPadController;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
@ -39,8 +40,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
"P1 Left", "P1 Right", "P1 B1",
|
||||
"P2 Left", "P2 Right", "P2 B1",
|
||||
}
|
||||
}.AddAxis("P1 Paddle", 0, 128, 255)
|
||||
.AddAxis("P2 Paddle", 0, 128, 255);
|
||||
}.AddAxis("P1 Paddle", 0.RangeTo(255), 128)
|
||||
.AddAxis("P2 Paddle", 0.RangeTo(255), 128);
|
||||
|
||||
public static readonly ControllerDefinition SMSLightPhaserController = new ControllerDefinition
|
||||
{
|
||||
|
@ -50,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
"Reset", "Pause",
|
||||
"P1 Trigger"
|
||||
}
|
||||
}.AddXYPair("P1 {0}", AxisPairOrientation.RightAndUp, (0, 64, 127), (0, 500, 1000)); //TODO verify direction against hardware
|
||||
}.AddXYPair("P1 {0}", AxisPairOrientation.RightAndUp, 0.RangeTo(127), 64, 0.RangeTo(1000), 500); //TODO verify direction against hardware
|
||||
|
||||
public static readonly ControllerDefinition SMSSportsPadController = new ControllerDefinition
|
||||
{
|
||||
|
@ -61,8 +62,8 @@ 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"
|
||||
}
|
||||
}.AddXYPair("P1 {0}", AxisPairOrientation.RightAndUp, -64, 0, 63) //TODO verify direction against hardware
|
||||
.AddXYPair("P2 {0}", AxisPairOrientation.RightAndUp, -64, 0, 63); //TODO ditto
|
||||
}.AddXYPair("P1 {0}", AxisPairOrientation.RightAndUp, (-64).RangeTo(63), 0) //TODO verify direction against hardware
|
||||
.AddXYPair("P2 {0}", AxisPairOrientation.RightAndUp, (-64).RangeTo(63), 0); //TODO ditto
|
||||
|
||||
public static readonly ControllerDefinition SMSKeyboardController = new ControllerDefinition
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
@ -121,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
private void DoMouseAnalog(int idx, int player)
|
||||
{
|
||||
ControllerDef.AddXYPair($"P{player} Mouse {{0}}", AxisPairOrientation.RightAndUp, -256, 0, 255); //TODO verify direction against hardware
|
||||
ControllerDef.AddXYPair($"P{player} Mouse {{0}}", AxisPairOrientation.RightAndUp, (-256).RangeTo(255), 0); //TODO verify direction against hardware
|
||||
var nx = $"P{player} Mouse X";
|
||||
var ny = $"P{player} Mouse Y";
|
||||
_converts.Add(() =>
|
||||
|
@ -134,7 +136,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
private void DoLightgunAnalog(int idx, int player)
|
||||
{
|
||||
// lightgun needs to be transformed to match the current screen resolution
|
||||
ControllerDef.AddXYPair($"P{player} Lightgun {{0}}", AxisPairOrientation.RightAndUp, 0, 5000, 10000); //TODO verify direction against hardware
|
||||
ControllerDef.AddXYPair($"P{player} Lightgun {{0}}", AxisPairOrientation.RightAndUp, 0.RangeTo(10000), 5000); //TODO verify direction against hardware
|
||||
var nx = $"P{player} Lightgun X";
|
||||
var ny = $"P{player} Lightgun Y";
|
||||
_converts.Add(() =>
|
||||
|
@ -146,7 +148,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
private void DoXea1PAnalog(int idx, int player)
|
||||
{
|
||||
ControllerDef.AddXYZTriple($"P{player} Stick {{0}}", -128, 0, 127);
|
||||
ControllerDef.AddXYZTriple($"P{player} Stick {{0}}", (-128).RangeTo(127), 0);
|
||||
var nx = $"P{player} Stick X";
|
||||
var ny = $"P{player} Stick Y";
|
||||
var nz = $"P{player} Stick Z";
|
||||
|
|
|
@ -272,11 +272,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
"P" + pnum + " A",
|
||||
});
|
||||
|
||||
var axisRange = new AxisRange(0, 128, 255);
|
||||
definition.AddAxis($"P{pnum} Twist", axisRange);
|
||||
definition.AddAxis($"P{pnum} 1", axisRange);
|
||||
definition.AddAxis($"P{pnum} 2", axisRange);
|
||||
definition.AddAxis($"P{pnum} L", axisRange);
|
||||
foreach (var axisName in new[] { $"P{pnum} Twist", $"P{pnum} 1", $"P{pnum} 2", $"P{pnum} L" })
|
||||
{
|
||||
definition.AddAxis(axisName, 0.RangeTo(255), 128);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -304,8 +303,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
definition.BoolButtons.Add("P" + pnum + " L3");
|
||||
definition.BoolButtons.Add("P" + pnum + " R3");
|
||||
definition.BoolButtons.Add("P" + pnum + " MODE");
|
||||
definition.AddXYPair($"P{pnum} LStick {{0}}", AxisPairOrientation.RightAndDown, 0, 128, 255);
|
||||
definition.AddXYPair($"P{pnum} RStick {{0}}", AxisPairOrientation.RightAndDown, 0, 128, 255);
|
||||
definition.AddXYPair($"P{pnum} LStick {{0}}", AxisPairOrientation.RightAndDown, 0.RangeTo(255), 128);
|
||||
definition.AddXYPair($"P{pnum} RStick {{0}}", AxisPairOrientation.RightAndDown, 0.RangeTo(255), 128);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +316,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
"Reset"
|
||||
});
|
||||
|
||||
definition.AddAxis("Disc Select", new AxisRange(0, 1, 1));
|
||||
definition.AddAxis("Disc Select", 0.RangeTo(1), 1);
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ using System;
|
|||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
@ -255,7 +257,7 @@ 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.AddXYPair("Pointer {0}", AxisPairOrientation.RightAndUp, -32767, 0, 32767);
|
||||
definition.AddXYPair("Pointer {0}", AxisPairOrientation.RightAndUp, (-32767).RangeTo(32767), 0);
|
||||
|
||||
foreach (var key in new[]{
|
||||
"Key Backspace", "Key Tab", "Key Clear", "Key Return", "Key Pause", "Key Escape",
|
||||
|
|
|
@ -2,6 +2,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using NymaTypes;
|
||||
|
||||
|
@ -178,7 +180,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
var data = input.Extra.AsAxis();
|
||||
var fullName = $"{name} {overrideName(data.NameNeg)} / {overrideName(data.NamePos)}";
|
||||
|
||||
ret.AddAxis(fullName, new AxisRange(0, 0x8000, 0xFFFF, (input.Flags & AxisFlags.InvertCo) != 0));
|
||||
ret.AddAxis(fullName, 0.RangeTo(0xFFFF), 0x8000, (input.Flags & AxisFlags.InvertCo) != 0);
|
||||
ret.CategoryLabels[fullName] = category;
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
|
@ -197,7 +199,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
// 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.AddAxis(fullName, (-127).RangeTo(127), 0, (input.Flags & AxisFlags.InvertCo) != 0);
|
||||
ret.CategoryLabels[fullName] = category;
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
|
@ -210,7 +212,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.AddAxis(name, new AxisRange(systemInfo.PointerOffsetX, systemInfo.PointerOffsetX, systemInfo.PointerScaleX));
|
||||
ret.AddAxis(name, systemInfo.PointerOffsetX.RangeTo(systemInfo.PointerScaleX), systemInfo.PointerOffsetX);
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(name);
|
||||
|
@ -222,7 +224,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.AddAxis(name, new AxisRange(systemInfo.PointerOffsetY, systemInfo.PointerOffsetY, systemInfo.PointerScaleY));
|
||||
ret.AddAxis(name, systemInfo.PointerOffsetY.RangeTo(systemInfo.PointerScaleY), systemInfo.PointerOffsetY);
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
var val = c.AxisValue(name);
|
||||
|
@ -233,7 +235,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
}
|
||||
case InputType.ButtonAnalog:
|
||||
{
|
||||
ret.AddAxis(name, new AxisRange(0, 0, 0xFFFF));
|
||||
ret.AddAxis(name, 0.RangeTo(0xFFFF), 0);
|
||||
ret.CategoryLabels[name] = category;
|
||||
_thunks.Add((c, b) =>
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
@ -24,7 +25,7 @@ namespace BizHawk.Tests.Client.Common.Display
|
|||
|
||||
_axisController = new SimpleController
|
||||
{
|
||||
Definition = new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0, MidValue, 200)
|
||||
Definition = new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(200), MidValue)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace BizHawk.Common.Tests.Client.Common.Movie
|
|||
|
||||
_axisController = new SimpleController
|
||||
{
|
||||
Definition = new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0, 100, 200)
|
||||
Definition = new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(200), 100)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue