virtual pad: schema sanity checking

This commit is contained in:
goyuken 2014-06-30 17:14:02 +00:00
parent 2bd52403a7
commit 65ddaf8a30
1 changed files with 35 additions and 3 deletions

View File

@ -92,9 +92,9 @@ namespace BizHawk.Client.EmuHawk
if (schemaType != null)
{
var pads = (Activator.CreateInstance(schemaType) as IVirtualPadSchema)
.GetPadSchemas()
.Select(s => new VirtualPad(s));
var padschemas = (Activator.CreateInstance(schemaType) as IVirtualPadSchema).GetPadSchemas();
CheckPads(padschemas, Global.Emulator.ControllerDefinition);
var pads = padschemas.Select(s => new VirtualPad(s));
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()
{
Global.Config.VirtualPadSettings.Wndx = Location.X;