BizHawk/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SatSchema.cs

197 lines
5.1 KiB
C#
Raw Normal View History

2014-06-23 23:25:08 +00:00
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
2014-06-23 23:25:08 +00:00
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Consoles.Sega.Saturn;
2014-06-23 23:25:08 +00:00
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("SAT")]
2014-06-23 23:25:08 +00:00
public class SaturnSchema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
2014-06-23 23:25:08 +00:00
{
var ss = ((Saturnus)core).GetSyncSettings();
int totalPorts = (ss.Port1Multitap ? 6 : 1) + (ss.Port2Multitap ? 6 : 1);
var padSchemas = new SaturnusControllerDeck.Device[]
{
ss.Port1,
ss.Port2,
ss.Port3,
ss.Port4,
ss.Port5,
ss.Port6,
ss.Port7,
ss.Port8,
ss.Port9,
ss.Port10,
ss.Port11,
ss.Port12
}.Take(totalPorts)
.Where(p => p != SaturnusControllerDeck.Device.None)
.Select((p, i) => GenerateSchemaForPort(p, i + 1))
.Where(s => s != null)
.Concat(new[] { ConsoleButtons() });
return padSchemas;
}
private static PadSchema GenerateSchemaForPort(SaturnusControllerDeck.Device device, int controllerNum)
{
switch (device)
{
default:
case SaturnusControllerDeck.Device.None:
return null;
case SaturnusControllerDeck.Device.Gamepad:
return StandardController(controllerNum);
case SaturnusControllerDeck.Device.ThreeDeePad:
case SaturnusControllerDeck.Device.Mission:
case SaturnusControllerDeck.Device.DualMission:
case SaturnusControllerDeck.Device.Wheel:
case SaturnusControllerDeck.Device.Keyboard:
case SaturnusControllerDeck.Device.Mouse:
System.Windows.Forms.MessageBox.Show("This peripheral is not supported yet");
return null;
}
2014-06-23 23:25:08 +00:00
}
2014-06-28 16:31:25 +00:00
2017-05-24 14:07:03 +00:00
private static PadSchema StandardController(int controller)
2014-06-23 23:25:08 +00:00
{
return new PadSchema
{
IsConsole = false,
2014-06-28 16:31:25 +00:00
DefaultSize = new Size(212, 90),
2014-06-23 23:25:08 +00:00
Buttons = new[]
{
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " Up",
DisplayName = "",
Icon = Properties.Resources.BlueUp,
2014-06-28 16:31:25 +00:00
Location = new Point(34, 17),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " Down",
DisplayName = "",
Icon = Properties.Resources.BlueDown,
2014-06-28 16:31:25 +00:00
Location = new Point(34, 61),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " Left",
DisplayName = "",
Icon = Properties.Resources.Back,
2014-06-28 16:31:25 +00:00
Location = new Point(22, 39),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " Right",
DisplayName = "",
Icon = Properties.Resources.Forward,
2014-06-28 16:31:25 +00:00
Location = new Point(44, 39),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
2014-06-28 16:31:25 +00:00
Name = "P" + controller + " Start",
DisplayName = "S",
Location = new Point(78, 52),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " A",
DisplayName = "A",
2014-06-28 16:31:25 +00:00
Location = new Point(110, 63),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
2014-06-28 16:31:25 +00:00
Name = "P" + controller + " B",
DisplayName = "B",
Location = new Point(134, 53),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-28 16:31:25 +00:00
{
Name = "P" + controller + " C",
DisplayName = "C",
Location = new Point(158, 43),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " X",
DisplayName = "X",
2014-06-28 16:31:25 +00:00
Location = new Point(110, 40),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " Y",
DisplayName = "Y",
2014-06-28 16:31:25 +00:00
Location = new Point(134, 30),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-28 16:31:25 +00:00
{
Name = "P" + controller + " Z",
DisplayName = "Z",
Location = new Point(158, 20),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " L",
DisplayName = "L",
2014-06-28 16:31:25 +00:00
Location = new Point(2, 10),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 23:25:08 +00:00
{
Name = "P" + controller + " R",
DisplayName = "R",
2014-06-28 16:31:25 +00:00
Location = new Point(184, 10),
Type = PadSchema.PadInputType.Boolean
}
}
};
}
private static PadSchema ConsoleButtons()
{
return new PadSchema
{
DisplayName = "Console",
IsConsole = true,
DefaultSize = new Size(150, 50),
Buttons = new[]
{
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-28 16:31:25 +00:00
{
Name = "Reset",
DisplayName = "Reset",
Location = new Point(10, 15),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-28 16:31:25 +00:00
{
Name = "Power",
DisplayName = "Power",
Location = new Point(58, 15),
2014-06-23 23:25:08 +00:00
Type = PadSchema.PadInputType.Boolean
}
}
};
}
}
}