Add an extension method to help w/ ControllerDefinition init of axes
This commit is contained in:
parent
2707d1cd92
commit
dbeb279bf0
|
@ -8,6 +8,8 @@ using System.Runtime.CompilerServices;
|
|||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public static class EmulatorExtensions
|
||||
|
@ -386,5 +388,64 @@ namespace BizHawk.Emulation.Common
|
|||
var pass2 = Path.GetFileName(pass1).RemoveInvalidFileSystemChars();
|
||||
return Path.Combine(filesystemDir, pass2.RemoveSuffix('.')); // trailing '.' would be duplicated when file extension is added
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <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)
|
||||
{
|
||||
def.AxisControls.Add(name);
|
||||
def.AxisRanges.Add(new AxisRange(min, mid, max, isReversed));
|
||||
return def;
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
/// <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 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an X/Y/Z triple 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 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -272,12 +274,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
Definition = new ControllerDefinition
|
||||
{
|
||||
Name = "Light Gun Controller",
|
||||
BoolButtons = BaseDefinition
|
||||
.Select(b => "P" + PortNum + " " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " X", "P" + PortNum + " Y" },
|
||||
AxisRanges = { new ControllerDefinition.AxisRange(1, 160, 320), new ControllerDefinition.AxisRange(1, 121, 242) }
|
||||
};
|
||||
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
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using System;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Belogic
|
||||
{
|
||||
[Core("uzem", "David Etherton", true, true, "", "", false)]
|
||||
|
@ -59,16 +61,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic
|
|||
private static readonly ControllerDefinition Mouse = new ControllerDefinition
|
||||
{
|
||||
Name = "SNES Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
"P1 Mouse Left", "P1 Mouse Right", "Power"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"P1 Mouse X", "P1 Mouse Y"
|
||||
},
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
|
||||
};
|
||||
BoolButtons = { "P1 Mouse Left", "P1 Mouse Right", "Power" }
|
||||
}.AddXYPair("P1 Mouse {0}", AxisPairOrientation.RightAndUp, -127, 0, 127); //TODO verify direction against hardware
|
||||
|
||||
private static readonly string[] PadBits =
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Linq;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.ColecoVision
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -130,14 +132,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
public ColecoTurboController(int portNum)
|
||||
{
|
||||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = BaseBoolDefinition
|
||||
.Select(b => "P" + PortNum + " " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
|
||||
};
|
||||
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
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
@ -235,14 +231,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
|||
public ColecoSuperActionController(int portNum)
|
||||
{
|
||||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = BaseBoolDefinition
|
||||
.Select(b => "P" + PortNum + " " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
|
||||
};
|
||||
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
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -78,12 +80,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
Definition = new ControllerDefinition
|
||||
{
|
||||
Name = "Vectrex Analog Controller",
|
||||
BoolButtons = BaseDefinition
|
||||
.Select(b => "P" + PortNum + " " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Stick X", "P" + PortNum + " Stick Y" },
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-128, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp)
|
||||
};
|
||||
BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList()
|
||||
}.AddXYPair($"P{PortNum} Stick {{0}}", AxisPairOrientation.RightAndUp, -128, 0, 127);
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Linq;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Intellivision
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -139,14 +141,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
|||
public FakeAnalogController(int portNum)
|
||||
{
|
||||
PortNum = portNum;
|
||||
Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = BaseBoolDefinition
|
||||
.Select(b => "P" + PortNum + " " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Disc X", "P" + PortNum + " Disc Y" },
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
|
||||
};
|
||||
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
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -250,25 +250,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
return baseTime + increment;
|
||||
}
|
||||
|
||||
private static readonly ControllerDefinition.AxisRange TiltRange = new ControllerDefinition.AxisRange(-32767, 0, 32767);
|
||||
|
||||
public static readonly ControllerDefinition GBAController = new ControllerDefinition
|
||||
{
|
||||
Name = "GBA Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
"Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"Tilt X", "Tilt Y", "Tilt Z",
|
||||
"Light Sensor"
|
||||
},
|
||||
AxisRanges =
|
||||
{
|
||||
TiltRange, TiltRange, TiltRange,
|
||||
new ControllerDefinition.AxisRange(0, 100, 200),
|
||||
}
|
||||
};
|
||||
BoolButtons = { "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "L", "R", "Power" }
|
||||
}.AddXYZTriple("Tilt {0}", -32767, 0, 32767)
|
||||
.AddAxis("Light Sensor", 0, 100, 200);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ using System.Linq;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -114,12 +116,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
Definition = new ControllerDefinition
|
||||
{
|
||||
Name = "Gameboy Controller + Tilt",
|
||||
BoolButtons = BaseDefinition
|
||||
.Select(b => "P" + PortNum + " " + b)
|
||||
.ToList(),
|
||||
AxisControls = { "P" + PortNum + " Tilt X", "P" + PortNum + " Tilt Y" },
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-45, 0, 45, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
|
||||
};
|
||||
BoolButtons = BaseDefinition.Select(b => $"P{PortNum} {b}").ToList()
|
||||
}.AddXYPair($"P{PortNum} Tilt {{0}}", AxisPairOrientation.RightAndUp, -45, 0, 45); //TODO verify direction against hardware
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Runtime.InteropServices;
|
|||
using System.IO;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
||||
{
|
||||
[Core("MelonDS", "Arisotura", false, false, null, null, true)]
|
||||
|
@ -92,10 +94,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
ControllerDefinition.BoolButtons.Add("Power");
|
||||
|
||||
ControllerDefinition.BoolButtons.Add("Touch");
|
||||
ControllerDefinition.AxisControls.Add("TouchX");
|
||||
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 128, 255));
|
||||
ControllerDefinition.AxisControls.Add("TouchY");
|
||||
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 96, 191));
|
||||
ControllerDefinition.AddXYPair("Touch{0}", AxisPairOrientation.RightAndUp, (0, 128, 255), (0, 96, 191)); //TODO verify direction against hardware
|
||||
|
||||
CoreComm = comm;
|
||||
_resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DEFAULT, 32768, 44100, 32768, 44100);
|
||||
|
|
|
@ -5,6 +5,8 @@ using BizHawk.Emulation.Common;
|
|||
using BizHawk.Common;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||
{
|
||||
/*
|
||||
|
@ -182,9 +184,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
ser.EndSection();
|
||||
}
|
||||
|
||||
internal static readonly ControllerDefinition.AxisRange ArkanoidPaddleRange = new ControllerDefinition.AxisRange(0, 80, 160);
|
||||
|
||||
internal static readonly List<ControllerDefinition.AxisRange> ZapperRanges = new List<ControllerDefinition.AxisRange> { new ControllerDefinition.AxisRange(0, 128, 255), new ControllerDefinition.AxisRange(0, 120, 239) };
|
||||
internal static readonly AxisRange ArkanoidPaddleRange = new AxisRange(0, 80, 160);
|
||||
}
|
||||
|
||||
public class UnpluggedNES : INesPort
|
||||
|
@ -540,6 +540,12 @@ 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
|
||||
}
|
||||
|
||||
// Dummy interface to indicate zapper behavior, used as a means of type checking for zapper functionality
|
||||
public interface IZapper
|
||||
{
|
||||
|
@ -553,12 +559,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
/// </summary>
|
||||
public LightgunDelegate PPUCallback { get; set; }
|
||||
|
||||
static ControllerDefinition Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = { "0Fire" },
|
||||
AxisControls = { "0Zapper X", "0Zapper Y" },
|
||||
AxisRanges = NesDeck.ZapperRanges
|
||||
};
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Fire" } }.AddZapper("0Zapper {0}");
|
||||
|
||||
public void Strobe(StrobeInfo s, IController c)
|
||||
{
|
||||
|
@ -606,12 +608,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
bool resetting = false;
|
||||
uint latchedvalue = 0;
|
||||
|
||||
static ControllerDefinition Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = { "0Fire" },
|
||||
AxisControls = { "0Zapper X", "0Zapper Y" },
|
||||
AxisRanges = NesDeck.ZapperRanges
|
||||
};
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Fire" } }.AddZapper("0Zapper {0}");
|
||||
|
||||
void Latch(IController c)
|
||||
{
|
||||
|
@ -1006,12 +1004,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
public class OekaKids : IFamicomExpansion
|
||||
{
|
||||
static ControllerDefinition Definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = { "0Click", "0Touch" },
|
||||
AxisControls = { "0Pen X", "0Pen Y" },
|
||||
AxisRanges = NesDeck.ZapperRanges // why would a tablet have the same resolution as a CRT monitor? --yoshi
|
||||
};
|
||||
private static readonly ControllerDefinition Definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Click", "0Touch" } }
|
||||
.AddZapper("0Pen {0}"); // why would a tablet have the same resolution as a CRT monitor? --yoshi
|
||||
|
||||
bool resetting;
|
||||
int shiftidx;
|
||||
|
|
|
@ -5,6 +5,8 @@ using System.Linq;
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common.NumberExtensions;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||
{
|
||||
public class LibsnesControllerDeck
|
||||
|
@ -20,13 +22,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
Payload
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// problem: when you're in 240 line mode, the limit on Y needs to be 240. when you're in 224 mode, it needs to be 224.
|
||||
/// perhaps the deck needs to account for this...
|
||||
/// for reference Snes9x is always in 224 mode
|
||||
/// </remarks>
|
||||
public static readonly List<ControllerDefinition.AxisRange> LightGunRanges = new List<ControllerDefinition.AxisRange> { new ControllerDefinition.AxisRange(0, 128, 256), new ControllerDefinition.AxisRange(0, 0, 240) };
|
||||
|
||||
private static ILibsnesController Factory(ControllerType t, LibsnesCore.SnesSyncSettings ss)
|
||||
{
|
||||
switch (t)
|
||||
|
@ -89,6 +84,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
}
|
||||
}
|
||||
|
||||
internal static class SNESControllerDefExtensions
|
||||
{
|
||||
/// <remarks>
|
||||
/// problem: when you're in 240 line mode, the limit on Y needs to be 240. when you're in 224 mode, it needs to be 224.
|
||||
/// perhaps the deck needs to account for this...
|
||||
/// 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
|
||||
}
|
||||
|
||||
public interface ILibsnesController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -279,20 +285,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
{
|
||||
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.Mouse;
|
||||
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Mouse Left",
|
||||
"0Mouse Right"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"0Mouse X",
|
||||
"0Mouse Y"
|
||||
},
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndDown) //TODO verify direction against hardware, R+D inferred from behaviour in Mario Paint
|
||||
};
|
||||
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
|
||||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
|
@ -332,22 +327,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
{
|
||||
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.SuperScope;
|
||||
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Trigger",
|
||||
"0Cursor",
|
||||
"0Turbo",
|
||||
"0Pause"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"0Scope X",
|
||||
"0Scope Y"
|
||||
},
|
||||
AxisRanges = LibsnesControllerDeck.LightGunRanges
|
||||
};
|
||||
private static readonly ControllerDefinition _definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } }
|
||||
.AddLightGun("0Scope {0}");
|
||||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
|
@ -379,24 +361,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
{
|
||||
public LibsnesApi.SNES_INPUT_PORT PortType => LibsnesApi.SNES_INPUT_PORT.Justifier;
|
||||
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Trigger",
|
||||
"0Start",
|
||||
"1Trigger",
|
||||
"1Start"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"0Justifier X",
|
||||
"0Justifier Y",
|
||||
"1Justifier X",
|
||||
"1Justifier Y",
|
||||
},
|
||||
AxisRanges = LibsnesControllerDeck.LightGunRanges.Concat(LibsnesControllerDeck.LightGunRanges).ToList()
|
||||
};
|
||||
private static readonly ControllerDefinition _definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Trigger", "0Start", "1Trigger", "1Start" } }
|
||||
.AddLightGun("0Justifier {0}")
|
||||
.AddLightGun("1Justifier {0}");
|
||||
|
||||
public ControllerDefinition Definition => _definition;
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@ using BizHawk.Common;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
||||
{
|
||||
[Core(CoreNames.Snes9X, "", true, true,
|
||||
|
@ -202,62 +206,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
|
||||
private class Mouse : Analog
|
||||
{
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Mouse Left",
|
||||
"0Mouse Right"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"0Mouse X",
|
||||
"0Mouse Y"
|
||||
},
|
||||
AxisRanges = ControllerDefinition.CreateAxisRangePair(-127, 0, 127, ControllerDefinition.AxisPairOrientation.RightAndUp) //TODO verify direction against hardware
|
||||
};
|
||||
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
|
||||
|
||||
public override ControllerDefinition Definition => _definition;
|
||||
}
|
||||
|
||||
private class SuperScope : Analog
|
||||
{
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Trigger",
|
||||
"0Cursor",
|
||||
"0Turbo",
|
||||
"0Pause"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"0Scope X",
|
||||
"0Scope Y"
|
||||
},
|
||||
AxisRanges = SNES.LibsnesControllerDeck.LightGunRanges
|
||||
};
|
||||
private static readonly ControllerDefinition _definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Trigger", "0Cursor", "0Turbo", "0Pause" } }
|
||||
.AddLightGun("0Scope {0}");
|
||||
|
||||
public override ControllerDefinition Definition => _definition;
|
||||
}
|
||||
|
||||
private class Justifier : Analog
|
||||
{
|
||||
private static readonly ControllerDefinition _definition = new ControllerDefinition
|
||||
{
|
||||
BoolButtons = new List<string>
|
||||
{
|
||||
"0Trigger",
|
||||
"0Start",
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"0Justifier X",
|
||||
"0Justifier Y",
|
||||
},
|
||||
AxisRanges = SNES.LibsnesControllerDeck.LightGunRanges
|
||||
};
|
||||
private static readonly ControllerDefinition _definition
|
||||
= new ControllerDefinition { BoolButtons = { "0Trigger", "0Start" } }
|
||||
.AddLightGun("0Justifier {0}");
|
||||
|
||||
public override ControllerDefinition Definition => _definition;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Linq;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
||||
{
|
||||
public partial class SMS
|
||||
|
@ -44,8 +46,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
},
|
||||
AxisRanges =
|
||||
{
|
||||
new ControllerDefinition.AxisRange(0, 128, 255),
|
||||
new ControllerDefinition.AxisRange(0, 128, 255)
|
||||
new AxisRange(0, 128, 255),
|
||||
new AxisRange(0, 128, 255)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,21 +57,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
BoolButtons =
|
||||
{
|
||||
"Reset", "Pause",
|
||||
"P1 Trigger",
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"P1 X", "P1 Y",
|
||||
},
|
||||
AxisRanges =
|
||||
{
|
||||
new ControllerDefinition.AxisRange(0, 64, 127),
|
||||
new ControllerDefinition.AxisRange(0, 500, 1000)
|
||||
"P1 Trigger"
|
||||
}
|
||||
};
|
||||
|
||||
/// <remarks>TODO verify direction against hardware</remarks>
|
||||
private static readonly List<ControllerDefinition.AxisRange> SportsPadTrackballRanges = ControllerDefinition.CreateAxisRangePair(-64, 0, 63, ControllerDefinition.AxisPairOrientation.RightAndUp);
|
||||
}.AddXYPair("P1 {0}", AxisPairOrientation.RightAndUp, (0, 64, 127), (0, 500, 1000)); //TODO verify direction against hardware
|
||||
|
||||
public static readonly ControllerDefinition SMSSportsPadController = new ControllerDefinition
|
||||
{
|
||||
|
@ -79,14 +69,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
|||
"Reset", "Pause",
|
||||
"P1 Left", "P1 Right", "P1 Up", "P1 Down", "P1 B1", "P1 B2",
|
||||
"P2 Left", "P2 Right", "P2 Up", "P2 Down", "P2 B1", "P2 B2"
|
||||
},
|
||||
AxisControls =
|
||||
{
|
||||
"P1 X", "P1 Y",
|
||||
"P2 X", "P2 Y"
|
||||
},
|
||||
AxisRanges = SportsPadTrackballRanges.Concat(SportsPadTrackballRanges).ToList()
|
||||
};
|
||||
}
|
||||
}.AddXYPair("P1 {0}", AxisPairOrientation.RightAndUp, -64, 0, 63) //TODO verify direction against hardware
|
||||
.AddXYPair("P2 {0}", AxisPairOrientation.RightAndUp, -64, 0, 63); //TODO ditto
|
||||
|
||||
public static readonly ControllerDefinition SMSKeyboardController = new ControllerDefinition
|
||||
{
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections.Generic;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||
{
|
||||
public class GPGXControlConverter
|
||||
|
@ -93,13 +95,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
new CName("XE E2", LibGPGX.INPUT_KEYS.INPUT_XE_E2),
|
||||
};
|
||||
|
||||
private static readonly ControllerDefinition.AxisRange MouseRange = new ControllerDefinition.AxisRange(-256, 0, 255);
|
||||
|
||||
// lightgun needs to be transformed to match the current screen resolution
|
||||
private static readonly ControllerDefinition.AxisRange LightgunRange = new ControllerDefinition.AxisRange(0, 5000, 10000);
|
||||
|
||||
private static readonly ControllerDefinition.AxisRange Xea1PRange = new ControllerDefinition.AxisRange(-128, 0, 127);
|
||||
|
||||
private LibGPGX.InputData _target;
|
||||
private IController _source;
|
||||
|
||||
|
@ -126,12 +121,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
private void DoMouseAnalog(int idx, int player)
|
||||
{
|
||||
string nx = $"P{player} Mouse X";
|
||||
string ny = $"P{player} Mouse Y";
|
||||
ControllerDef.AxisControls.Add(nx);
|
||||
ControllerDef.AxisControls.Add(ny);
|
||||
ControllerDef.AxisRanges.Add(MouseRange);
|
||||
ControllerDef.AxisRanges.Add(MouseRange);
|
||||
ControllerDef.AddXYPair($"P{player} Mouse {{0}}", AxisPairOrientation.RightAndUp, -256, 0, 255); //TODO verify direction against hardware
|
||||
var nx = $"P{player} Mouse X";
|
||||
var ny = $"P{player} Mouse Y";
|
||||
_converts.Add(delegate
|
||||
{
|
||||
_target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
|
||||
|
@ -141,12 +133,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
private void DoLightgunAnalog(int idx, int player)
|
||||
{
|
||||
string nx = $"P{player} Lightgun X";
|
||||
string ny = $"P{player} Lightgun Y";
|
||||
ControllerDef.AxisControls.Add(nx);
|
||||
ControllerDef.AxisControls.Add(ny);
|
||||
ControllerDef.AxisRanges.Add(LightgunRange);
|
||||
ControllerDef.AxisRanges.Add(LightgunRange);
|
||||
// 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
|
||||
var nx = $"P{player} Lightgun X";
|
||||
var ny = $"P{player} Lightgun Y";
|
||||
_converts.Add(delegate
|
||||
{
|
||||
_target.analog[(2 * idx) + 0] = (short)(_source.AxisValue(nx) / 10000.0f * (ScreenWidth - 1));
|
||||
|
@ -156,15 +146,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
private void DoXea1PAnalog(int idx, int player)
|
||||
{
|
||||
string nx = $"P{player} Stick X";
|
||||
string ny = $"P{player} Stick Y";
|
||||
string nz = $"P{player} Stick Z";
|
||||
ControllerDef.AxisControls.Add(nx);
|
||||
ControllerDef.AxisControls.Add(ny);
|
||||
ControllerDef.AxisControls.Add(nz);
|
||||
ControllerDef.AxisRanges.Add(Xea1PRange);
|
||||
ControllerDef.AxisRanges.Add(Xea1PRange);
|
||||
ControllerDef.AxisRanges.Add(Xea1PRange);
|
||||
ControllerDef.AddXYZTriple($"P{player} Stick {{0}}", -128, 0, 127);
|
||||
var nx = $"P{player} Stick X";
|
||||
var ny = $"P{player} Stick Y";
|
||||
var nz = $"P{player} Stick Z";
|
||||
_converts.Add(delegate
|
||||
{
|
||||
_target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
|
||||
|
|
|
@ -24,6 +24,8 @@ using BizHawk.Emulation.Common;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||
|
@ -220,8 +222,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
|
||||
public string SystemId => "PSX";
|
||||
|
||||
public static readonly IReadOnlyList<ControllerDefinition.AxisRange> DualShockStickRanges = ControllerDefinition.CreateAxisRangePair(0, 128, 255, ControllerDefinition.AxisPairOrientation.RightAndDown);
|
||||
|
||||
public static ControllerDefinition CreateControllerDefinition(SyncSettings syncSettings)
|
||||
{
|
||||
var definition = new ControllerDefinition { Name = "PSX Front Panel" };
|
||||
|
@ -255,7 +255,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
"P" + pnum + " L"
|
||||
});
|
||||
|
||||
var axisRange = new ControllerDefinition.AxisRange(0, 128, 255);
|
||||
var axisRange = new AxisRange(0, 128, 255);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
definition.AxisRanges.Add(axisRange);
|
||||
|
@ -287,16 +287,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.AxisControls.AddRange(new[]
|
||||
{
|
||||
"P" + pnum + " LStick X",
|
||||
"P" + pnum + " LStick Y",
|
||||
"P" + pnum + " RStick X",
|
||||
"P" + pnum + " RStick Y"
|
||||
});
|
||||
|
||||
definition.AxisRanges.AddRange(DualShockStickRanges.Concat(DualShockStickRanges).ToList());
|
||||
definition.AddXYPair($"P{pnum} LStick {{0}}", AxisPairOrientation.RightAndDown, 0, 128, 255);
|
||||
definition.AddXYPair($"P{pnum} RStick {{0}}", AxisPairOrientation.RightAndDown, 0, 128, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +305,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
definition.AxisRanges.Add(
|
||||
//new ControllerDefinition.AxisRange(-1, -1, -1) //this is carefully chosen so that we end up with a -1 disc by default (indicating that it's never been set)
|
||||
//hmm.. I don't see why this wouldn't work
|
||||
new ControllerDefinition.AxisRange(0, 1, 1)
|
||||
new AxisRange(0, 1, 1)
|
||||
);
|
||||
|
||||
return definition;
|
||||
|
|
|
@ -9,6 +9,8 @@ using System.Collections.Generic;
|
|||
using System.Runtime.InteropServices;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Libretro
|
||||
{
|
||||
[Core("Libretro", "zeromus", isPorted: false, isReleased: false)]
|
||||
|
@ -253,9 +255,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.AxisControls.Add("Pointer X");
|
||||
definition.AxisControls.Add("Pointer Y");
|
||||
definition.AxisRanges.AddRange(ControllerDefinition.CreateAxisRangePair(-32767, 0, 32767, ControllerDefinition.AxisPairOrientation.RightAndUp));
|
||||
definition.AddXYPair("Pointer {0}", AxisPairOrientation.RightAndUp, -32767, 0, 32767);
|
||||
|
||||
foreach (var key in new[]{
|
||||
"Key Backspace", "Key Tab", "Key Clear", "Key Return", "Key Pause", "Key Escape",
|
||||
|
|
|
@ -3,6 +3,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Tests.Client.Common.Display
|
||||
{
|
||||
[TestClass]
|
||||
|
@ -22,15 +24,7 @@ namespace BizHawk.Tests.Client.Common.Display
|
|||
|
||||
_axisController = new SimpleController
|
||||
{
|
||||
Definition = new ControllerDefinition
|
||||
{
|
||||
AxisControls = { "StickX", "StickY" },
|
||||
AxisRanges =
|
||||
{
|
||||
new ControllerDefinition.AxisRange(0, MidValue, 200),
|
||||
new ControllerDefinition.AxisRange(0, MidValue, 200)
|
||||
}
|
||||
}
|
||||
Definition = new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0, MidValue, 200)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using static BizHawk.Emulation.Common.ControllerDefinition;
|
||||
|
||||
namespace BizHawk.Common.Tests.Client.Common.Movie
|
||||
{
|
||||
[TestClass]
|
||||
|
@ -21,15 +23,7 @@ namespace BizHawk.Common.Tests.Client.Common.Movie
|
|||
|
||||
_floatController = new SimpleController
|
||||
{
|
||||
Definition = new ControllerDefinition
|
||||
{
|
||||
AxisControls = { "StickX", "StickY" },
|
||||
AxisRanges =
|
||||
{
|
||||
new ControllerDefinition.AxisRange(0, 100, 200),
|
||||
new ControllerDefinition.AxisRange(0, 100, 200)
|
||||
}
|
||||
}
|
||||
Definition = new ControllerDefinition().AddXYPair("Stick{0}", AxisPairOrientation.RightAndUp, 0, 100, 200)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue