ButtonSchema - make Type not directly settable and force the use of inheritance to set it

This commit is contained in:
adelikat 2020-03-22 12:18:47 -05:00
parent 1f63228061
commit ec36ed6206
16 changed files with 123 additions and 159 deletions

View File

@ -85,20 +85,18 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} Button 2",
DisplayName = "B2"
},
new ButtonSchema(55, 17)
new SingleFloatSchema(55, 17)
{
Name = $"P{controller} Paddle X 1",
DisplayName = "Paddle X 1",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 69),
MaxValue = 127,
MinValue = -127
},
new ButtonSchema(193, 17)
new SingleFloatSchema(193, 17)
{
Name = $"P{controller} Paddle X 2",
DisplayName = "Paddle X 2",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 69),
MaxValue = 127,
MinValue = -127
@ -155,20 +153,18 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} Button",
DisplayName = "B1"
},
new ButtonSchema(55, 17)
new SingleFloatSchema(55, 17)
{
Name = $"P{controller} Wheel X 1",
DisplayName = "Wheel X 1",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 69),
MaxValue = 127,
MinValue = -127
},
new ButtonSchema(193, 17)
new SingleFloatSchema(193, 17)
{
Name = $"P{controller} Wheel X 2",
DisplayName = "Wheel X 2",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 69),
MaxValue = 127,
MinValue = -127

View File

@ -111,11 +111,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(250, 74),
Buttons = new[]
{
new ButtonSchema(23, 15)
new SingleFloatSchema(23, 15)
{
Name = $"P{controller} Paddle",
DisplayName = "Paddle",
Type = PadInputType.FloatSingle
DisplayName = "Paddle"
},
new ButtonSchema(12, 90)
{
@ -136,10 +135,9 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(356, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17)
{
Name = $"P{controller} VPos",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new[]
{

View File

@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
public string Name { get; set; }
public string DisplayName { get; set; }
public PadInputType Type { get; set; } = PadInputType.Boolean;
public PadInputType Type { get; protected set; } = PadInputType.Boolean;
public Point Location { get; set; }
public Bitmap Icon { get; set; }
public Size TargetSize { get; set; } // Specifically for TargetedPair, specifies the screen size
@ -63,4 +63,61 @@ namespace BizHawk.Client.EmuHawk
Icon = Properties.Resources.Forward
};
}
public class SingleFloatSchema : ButtonSchema
{
public SingleFloatSchema(int x, int y)
: base(x, y)
{
Type = PadInputType.FloatSingle;
}
}
public class TargetedPairSchema : ButtonSchema
{
public TargetedPairSchema(int x, int y)
: base(x, y)
{
Type = PadInputType.TargetedPair;
}
public TargetedPairSchema(int x, int y, string nameX)
: this(x, y)
{
Name = nameX;
SecondaryNames = new[]
{
nameX.Replace("X", "Y")
};
}
}
public class AnalogSchema : ButtonSchema
{
public AnalogSchema(int x, int y)
: base(x, y)
{
Type = PadInputType.AnalogStick;
}
public AnalogSchema(int x, int y, string nameX)
: this(x, y)
{
Name = nameX;
SecondaryNames = new[]
{
nameX.Replace("X", "Y")
};
}
}
public class DiscManagerSchema : ButtonSchema
{
public DiscManagerSchema(int x, int y)
: base(x, y)
{
Type = PadInputType.DiscManager;
Name = "Disc Select"; // not really, but shuts up a warning
}
}
}

View File

@ -134,12 +134,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(275, 260),
Buttons = new[]
{
new ButtonSchema(6, 14)
new AnalogSchema(6, 14, $"P{controller} Disc X")
{
Name = $"P{controller} Disc X",
AxisRange = controllerDefRanges[0],
SecondaryAxisRange = controllerDefRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = controllerDefRanges[1]
},
new ButtonSchema(6, 224)
{
@ -226,14 +224,13 @@ namespace BizHawk.Client.EmuHawk
DisplayName = "#"
},
new ButtonSchema(6, 200)
new SingleFloatSchema(6, 200)
{
Name = $"P{controller} Disc X",
DisplayName = "Disc",
TargetSize = new Size(180, 55),
MinValue = -360,
MaxValue = 360,
Type = PadInputType.FloatSingle
MaxValue = 360
},
new ButtonSchema(126, 15)

View File

@ -31,34 +31,30 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(256, 326),
Buttons = new[]
{
new ButtonSchema(10, 15)
new SingleFloatSchema(10, 15)
{
Name = "Tilt X",
Type = PadInputType.FloatSingle,
TargetSize = new Size(226, 69),
MinValue = short.MinValue,
MaxValue = short.MaxValue
},
new ButtonSchema(10, 94)
new SingleFloatSchema(10, 94)
{
Name = "Tilt Y",
Type = PadInputType.FloatSingle,
TargetSize = new Size(226, 69),
MinValue = short.MinValue,
MaxValue = short.MaxValue
},
new ButtonSchema(10, 173)
new SingleFloatSchema(10, 173)
{
Name = "Tilt Z",
Type = PadInputType.FloatSingle,
TargetSize = new Size(226, 69),
MinValue = short.MinValue,
MaxValue = short.MaxValue
},
new ButtonSchema(10, 252)
new SingleFloatSchema(10, 252)
{
Name = "Light Sensor",
Type = PadInputType.FloatSingle,
TargetSize = new Size(226, 69),
MaxValue = byte.MaxValue
}

View File

@ -125,15 +125,9 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(356, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, "P1 Tilt X")
{
Name = "P1 Tilt X",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new[]
{
"P1 Tilt Y"
}
TargetSize = new Size(256, 240)
}
}
};

View File

@ -162,16 +162,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(356, 300),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, $"P{controller} Lightgun X")
{
Name = $"P{controller} Lightgun X",
Type = PadInputType.TargetedPair,
MaxValue = 10000,
TargetSize = new Size(320, 240),
SecondaryNames = new[]
{
$"P{controller} Lightgun Y"
}
TargetSize = new Size(320, 240)
},
new ButtonSchema(284, 17)
{
@ -196,16 +190,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(418, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new AnalogSchema(14, 17, $"P{controller} Mouse X")
{
Name = $"P{controller} Mouse X",
Type = PadInputType.AnalogStick,
MaxValue = 255,
TargetSize = new Size(520, 570),
SecondaryNames = new[]
{
$"P{controller} Mouse Y"
}
TargetSize = new Size(520, 570)
},
new ButtonSchema(365, 17)
{

View File

@ -309,12 +309,10 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} R",
DisplayName = "R"
},
new ButtonSchema(1, 121)
new AnalogSchema(1, 121, $"P{controller} Disc X")
{
Name = $"P{controller} Disc X",
AxisRange = controllerDefRanges[0],
SecondaryAxisRange = controllerDefRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = controllerDefRanges[1]
}
}
};

View File

@ -31,7 +31,7 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(275, 316),
Buttons = new[]
{
ButtonSchema.Up(24, 230, $"P{controller} DPad U"),
ButtonSchema.Up(24, 230, $"P{controller} DPad U"),
ButtonSchema.Down(24, 251, $"P{controller} DPad D"),
ButtonSchema.Left(3, 242, $"P{controller} DPad L"),
ButtonSchema.Right(45, 242, $"P{controller} DPad R"),
@ -85,12 +85,10 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} C Right",
Icon = Properties.Resources.YellowRight
},
new ButtonSchema(6, 14)
new AnalogSchema(6, 14, $"P{controller} X Axis")
{
Name = $"P{controller} X Axis",
AxisRange = controllerDefRanges[0],
SecondaryAxisRange = controllerDefRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = controllerDefRanges[1]
}
}
};

View File

@ -49,12 +49,9 @@ namespace BizHawk.Client.EmuHawk.tools.VirtualPads.schema
new ButtonSchema(366, 86) { Name = "A" },
// Screen
new ButtonSchema(72, 35)
new TargetedPairSchema(72, 35, "TouchX")
{
Name = "TouchX",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 192),
SecondaryNames = new[] { "TouchY" }
TargetSize = new Size(256, 192)
},
new ButtonSchema(72, 10) { Name = "Touch" }
}

View File

@ -294,15 +294,9 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(356, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, $"P{controller} Zapper X")
{
Name = $"P{controller} Zapper X",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new[]
{
$"P{controller} Zapper Y"
}
TargetSize = new Size(256, 240)
},
new ButtonSchema(284, 17)
{
@ -323,11 +317,10 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(380, 110),
Buttons = new[]
{
new ButtonSchema(14, 17)
new SingleFloatSchema(14, 17)
{
Name = $"P{controller} Paddle",
DisplayName = "Arkanoid Paddle",
Type = PadInputType.FloatSingle,
TargetSize = new Size(380, 69),
MaxValue = 160
},
@ -424,15 +417,9 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(356, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, $"P{controller} Pen X")
{
Name = $"P{controller} Pen X",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new[]
{
$"P{controller} Pen Y"
}
TargetSize = new Size(256, 240)
},
new ButtonSchema(284, 17)
{

View File

@ -118,19 +118,17 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} Select",
DisplayName = "s"
},
new ButtonSchema(3, 120)
new AnalogSchema(3, 120, $"P{controller} LStick X")
{
Name = $"P{controller} LStick X",
AxisRange = stickRanges[0],
SecondaryAxisRange = stickRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = stickRanges[1]
},
new ButtonSchema(260, 120)
{
Name = $"P{controller} RStick X",
AxisRange = stickRanges[0],
SecondaryAxisRange = stickRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = stickRanges[1]
}
}
};
@ -237,39 +235,35 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} R",
DisplayName = "R"
},
new ButtonSchema(5, 15)
new SingleFloatSchema(5, 15)
{
Name = $"P{controller} L",
DisplayName = "L",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
},
new ButtonSchema(125, 15)
new SingleFloatSchema(125, 15)
{
Name = $"P{controller} Twist",
DisplayName = "Twist",
Type = PadInputType.FloatSingle,
TargetSize = new Size(64, 178),
MinValue = 0,
MaxValue = 255,
Orientation = Orientation.Vertical
},
new ButtonSchema(180, 60)
new SingleFloatSchema(180, 60)
{
Name = $"P{controller} 2",
DisplayName = "II",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
},
new ButtonSchema(220, 120)
new SingleFloatSchema(220, 120)
{
Name = $"P{controller} 1",
DisplayName = "I",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
@ -288,10 +282,8 @@ namespace BizHawk.Client.EmuHawk
Buttons = new[]
{
new ButtonSchema(10, 15) { Name = "Reset" },
new ButtonSchema(10, 54)
new DiscManagerSchema(10, 54)
{
Name = "Disc Select", // not really, but shuts up a warning
Type = PadInputType.DiscManager,
TargetSize = new Size(300, 300),
OwnerEmulator = psx,
SecondaryNames = new[] { "Open", "Close", "Disc Select" }

View File

@ -116,11 +116,8 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(375, 320),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, $"P{controller} X")
{
Name = $"P{controller} X",
SecondaryNames = new[] { $"P{controller} Y" },
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 256)
},
new ButtonSchema(300, 17)

View File

@ -175,28 +175,25 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} Z",
DisplayName = "Z"
},
new ButtonSchema(6, 74)
new AnalogSchema(6, 74)
{
Name = $"P{controller} Stick Horizontal",
SecondaryNames = new[] { $"P{controller} Stick Vertical" },
AxisRange = axisRanges[0],
SecondaryAxisRange = axisRanges[1],
Type = PadInputType.AnalogStick
},
new ButtonSchema(8, 12)
new SingleFloatSchema(8, 12)
{
Name = $"P{controller} Left Shoulder",
DisplayName = "L",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
},
new ButtonSchema(328, 12)
new SingleFloatSchema(328, 12)
{
Name = $"P{controller} Right Shoulder",
DisplayName = "L",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
@ -214,11 +211,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(375, 320),
Buttons = new[]
{
new ButtonSchema(14, 17)
new SingleFloatSchema(14, 17)
{
Name = $"P{controller} X",
SecondaryNames = new[] { $"P{controller} Y" },
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 256)
},
new ButtonSchema(300, 17)
@ -254,11 +250,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(325, 100),
Buttons = new[]
{
new ButtonSchema(8, 12)
new SingleFloatSchema(8, 12)
{
Name = $"P{controller} Wheel",
DisplayName = "Wheel",
Type = PadInputType.FloatSingle,
TargetSize = new Size(128, 55),
MinValue = 0,
MaxValue = 255
@ -359,19 +354,17 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} C",
DisplayName = "C"
},
new ButtonSchema(185, 13)
new AnalogSchema(185, 13)
{
Name = $"P{controller} Stick Horizontal",
SecondaryNames = new[] { $"P{controller} Stick Vertical" },
AxisRange = axisRanges[0],
SecondaryAxisRange = axisRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = axisRanges[1]
},
new ButtonSchema(135, 13)
new SingleFloatSchema(135, 13)
{
Name = $"P{controller} Throttle",
DisplayName = "Throttle",
Type = PadInputType.FloatSingle,
TargetSize = new Size(64, 178),
MinValue = 0,
MaxValue = 255,
@ -389,39 +382,35 @@ namespace BizHawk.Client.EmuHawk
DisplayName = "Dual Mission",
IsConsole = false,
DefaultSize = new Size(680, 230),
Buttons = new[]
Buttons = new ButtonSchema[]
{
new ButtonSchema(58, 13)
new AnalogSchema(58, 13)
{
Name = $"P{controller} Left Stick Horizontal",
SecondaryNames = new[] { $"P{controller} Left Stick Vertical" },
AxisRange = axisRanges[3],
SecondaryAxisRange = axisRanges[4],
Type = PadInputType.AnalogStick
SecondaryAxisRange = axisRanges[4]
},
new ButtonSchema(8, 13)
new SingleFloatSchema(8, 13)
{
Name = $"P{controller} Left Throttle",
DisplayName = "Throttle",
Type = PadInputType.FloatSingle,
TargetSize = new Size(64, 178),
MinValue = 0,
MaxValue = 255,
Orientation = Orientation.Vertical
},
new ButtonSchema(400, 13)
new AnalogSchema(400, 13)
{
Name = $"P{controller} Right Stick Horizontal",
SecondaryNames = new[] { $"P{controller} Right Stick Vertical" },
AxisRange = axisRanges[0],
SecondaryAxisRange = axisRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = axisRanges[1]
},
new ButtonSchema(350, 13)
new SingleFloatSchema(350, 13)
{
Name = $"P{controller} Right Throttle",
DisplayName = "Throttle",
Type = PadInputType.FloatSingle,
TargetSize = new Size(64, 178),
MinValue = 0,
MaxValue = 255,

View File

@ -173,12 +173,10 @@ namespace BizHawk.Client.EmuHawk
DefaultSize = new Size(345, 225),
Buttons = new[]
{
new ButtonSchema(6, 14)
new AnalogSchema(6, 14, $"P{controller} Mouse X")
{
Name = $"P{controller} Mouse X",
AxisRange = controllerDefRanges[0],
SecondaryAxisRange = controllerDefRanges[1],
Type = PadInputType.AnalogStick
SecondaryAxisRange = controllerDefRanges[1]
},
new ButtonSchema(275, 15)
{
@ -204,15 +202,9 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(356, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, $"P{controller} Scope X")
{
Name = $"P{controller} Scope X",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new[]
{
$"P{controller} Scope Y"
}
TargetSize = new Size(256, 240)
},
new ButtonSchema(284, 17)
{
@ -248,15 +240,9 @@ namespace BizHawk.Client.EmuHawk
MaxSize = new Size(356, 290),
Buttons = new[]
{
new ButtonSchema(14, 17)
new TargetedPairSchema(14, 17, $"P{controller} Justifier X")
{
Name = $"P{controller} Justifier X",
Type = PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new[]
{
$"P{controller} Justifier Y"
}
TargetSize = new Size(256, 240)
},
new ButtonSchema(284, 17)
{

View File

@ -102,16 +102,10 @@ namespace BizHawk.Client.EmuHawk
Name = $"P{controller} Button 4",
DisplayName = "4"
},
new ButtonSchema(2, 80)
new AnalogSchema(2, 80, $"P{controller} Stick X")
{
Name = $"P{controller} Stick X",
AxisRange = controllerDefRanges[0],
SecondaryAxisRange = controllerDefRanges[1],
Type = PadInputType.AnalogStick,
SecondaryNames = new[]
{
$"P{controller} Stick Y"
}
SecondaryAxisRange = controllerDefRanges[1]
}
}
};