virtual pad: schema sanity checking
This commit is contained in:
parent
2bd52403a7
commit
65ddaf8a30
|
@ -92,9 +92,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (schemaType != null)
|
if (schemaType != null)
|
||||||
{
|
{
|
||||||
var pads = (Activator.CreateInstance(schemaType) as IVirtualPadSchema)
|
var padschemas = (Activator.CreateInstance(schemaType) as IVirtualPadSchema).GetPadSchemas();
|
||||||
.GetPadSchemas()
|
CheckPads(padschemas, Global.Emulator.ControllerDefinition);
|
||||||
.Select(s => new VirtualPad(s));
|
var pads = padschemas.Select(s => new VirtualPad(s));
|
||||||
|
|
||||||
if (pads.Any())
|
if (pads.Any())
|
||||||
{
|
{
|
||||||
|
@ -103,6 +103,38 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckPads(IEnumerable<PadSchema> schemas, BizHawk.Emulation.Common.ControllerDefinition def)
|
||||||
|
{
|
||||||
|
HashSet<string> analogs = new HashSet<string>(def.FloatControls);
|
||||||
|
HashSet<string> bools = new HashSet<string>(def.BoolButtons);
|
||||||
|
|
||||||
|
foreach (var schema in schemas)
|
||||||
|
{
|
||||||
|
foreach (var button in schema.Buttons)
|
||||||
|
{
|
||||||
|
HashSet<string> searchset = null;
|
||||||
|
switch (button.Type)
|
||||||
|
{
|
||||||
|
case PadSchema.PadInputType.AnalogStick:
|
||||||
|
case PadSchema.PadInputType.FloatSingle:
|
||||||
|
case PadSchema.PadInputType.TargetedPair:
|
||||||
|
// analog
|
||||||
|
searchset = analogs;
|
||||||
|
break;
|
||||||
|
case PadSchema.PadInputType.Boolean:
|
||||||
|
searchset = bools;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!searchset.Contains(button.Name))
|
||||||
|
{
|
||||||
|
MessageBox.Show(this,
|
||||||
|
string.Format("Schema warning: Schema entry '{0}':'{1}' will not correspond to any control in definition '{2}'", schema.DisplayName, button.Name, def.Name),
|
||||||
|
"Dev Warning");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveConfigSettings()
|
private void SaveConfigSettings()
|
||||||
{
|
{
|
||||||
Global.Config.VirtualPadSettings.Wndx = Location.X;
|
Global.Config.VirtualPadSettings.Wndx = Location.X;
|
||||||
|
|
Loading…
Reference in New Issue