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

370 lines
9.2 KiB
C#
Raw Normal View History

2014-06-23 14:13:07 +00:00
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.SNES;
2014-06-22 15:43:45 +00:00
namespace BizHawk.Client.EmuHawk
{
[SchemaAttributes("SNES")]
2014-06-23 14:13:07 +00:00
public class SnesSchema : IVirtualPadSchema
2014-06-22 15:43:45 +00:00
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
2014-06-23 14:13:07 +00:00
{
var syncsettings = ((LibsnesCore)core).GetSyncSettings();
var ports = new[]
{
syncsettings.LeftPort,
syncsettings.RightPort
};
int offset = 0;
for (int i = 0; i < 2; i++)
{
int playerNum = i + offset + 1;
switch (ports[i])
{
default:
case LibsnesControllerDeck.ControllerType.Unplugged:
offset -= 1;
break;
case LibsnesControllerDeck.ControllerType.Gamepad:
yield return StandardController(playerNum);
break;
case LibsnesControllerDeck.ControllerType.Multitap:
for (int j = 0; j < 4; j++)
{
yield return StandardController(playerNum + j);
}
offset += 3;
break;
case LibsnesControllerDeck.ControllerType.Mouse:
yield return Mouse(playerNum);
break;
case LibsnesControllerDeck.ControllerType.SuperScope:
yield return SuperScope(playerNum);
break;
case LibsnesControllerDeck.ControllerType.Justifier:
for (int j = 0; j < 2; j++)
{
yield return Justifier(playerNum);
offset += j;
}
break;
case LibsnesControllerDeck.ControllerType.Payload:
yield return Payload(playerNum);
break;
}
}
2014-06-28 16:52:31 +00:00
yield return ConsoleButtons();
2014-06-23 14:13:07 +00:00
}
2014-06-28 16:52:31 +00:00
private static PadSchema StandardController(int controller, int rowOffset = 0)
2014-06-22 15:43:45 +00:00
{
return new PadSchema
{
2014-06-23 01:43:33 +00:00
IsConsole = false,
2014-06-28 16:52:31 +00:00
DefaultSize = new Size(200, 90),
2014-06-23 01:43:33 +00:00
Buttons = new[]
{
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " Up",
DisplayName = "",
Icon = Properties.Resources.BlueUp,
2014-06-28 16:52:31 +00:00
Location = new Point(34, 17),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " Down",
DisplayName = "",
Icon = Properties.Resources.BlueDown,
2014-06-28 16:52:31 +00:00
Location = new Point(34, 61),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " Left",
DisplayName = "",
Icon = Properties.Resources.Back,
2014-06-28 16:52:31 +00:00
Location = new Point(22, 39),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " Right",
DisplayName = "",
Icon = Properties.Resources.Forward,
2014-06-28 16:52:31 +00:00
Location = new Point(44, 39),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
2014-06-28 16:52:31 +00:00
Name = "P" + controller + " L",
DisplayName = "L",
Location = new Point(2, 10),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
2014-06-28 16:52:31 +00:00
Name = "P" + controller + " R",
DisplayName = "R",
Location = new Point(174, 10),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2014-06-28 16:52:31 +00:00
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " Select",
DisplayName = "s",
2014-06-28 16:52:31 +00:00
Location = new Point(70, 39),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " Start",
DisplayName = "S",
2014-06-28 16:52:31 +00:00
Location = new Point(92, 39),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-28 16:52:31 +00:00
{
Name = "P" + controller + " Y",
DisplayName = "Y",
Location = new Point(121, 39),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-28 16:52:31 +00:00
{
Name = "P" + controller + " B",
DisplayName = "B",
Location = new Point(145, 52),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
Name = "P" + controller + " X",
DisplayName = "X",
2014-06-28 16:52:31 +00:00
Location = new Point(122, 15),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
2014-06-28 16:52:31 +00:00
Name = "P" + controller + " A",
DisplayName = "A",
Location = new Point(146, 25),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
2014-06-29 03:14:40 +00:00
}
2014-06-28 16:52:31 +00:00
}
};
}
private static PadSchema Mouse(int controller)
{
return new PadSchema
{
IsConsole = false,
DefaultSize = new Size(345, 225),
Buttons = new[]
{
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Mouse X",
MinValue = -128,
MidValue = 0,
MaxValue = 127,
MinValueSec = 127,
MidValueSec = 0,
MaxValueSec = -128,
DisplayName = "",
Location = new Point(6, 14),
Type = PadSchema.PadInputType.AnalogStick
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Mouse Left",
DisplayName = "Left",
Location = new Point(275, 15),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Mouse Right",
DisplayName = "Right",
Location = new Point(275, 45),
Type = PadSchema.PadInputType.Boolean
}
}
};
}
private static PadSchema SuperScope(int controller)
{
return new PadSchema
{
DisplayName = "Superscope",
IsConsole = false,
DefaultSize = new Size(356, 290),
MaxSize = new Size(356, 290),
Buttons = new[]
{
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Scope X",
Location = new Point(14, 17),
Type = PadSchema.PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new []
{
"P" + controller + " Scope Y",
}
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Trigger",
DisplayName = "Trigger",
Location = new Point(284, 17),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Cursor",
DisplayName = "Cursor",
Location = new Point(284, 47),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Turbo",
DisplayName = "Turbo",
Location = new Point(284, 77),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Pause",
DisplayName = "Pause",
Location = new Point(284, 107),
Type = PadSchema.PadInputType.Boolean
}
}
};
}
private static PadSchema Justifier(int controller)
{
return new PadSchema
{
DisplayName = "Justifier",
IsConsole = false,
DefaultSize = new Size(356, 290),
MaxSize = new Size(356, 290),
Buttons = new[]
{
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Justifier X",
Location = new Point(14, 17),
Type = PadSchema.PadInputType.TargetedPair,
TargetSize = new Size(256, 240),
SecondaryNames = new []
{
"P" + controller + " Justifier Y",
}
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Trigger",
DisplayName = "Trigger",
Location = new Point(284, 17),
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
{
Name = "P" + controller + " Start",
DisplayName = "Start",
Location = new Point(284, 47),
Type = PadSchema.PadInputType.Boolean
}
}
};
}
private static PadSchema Payload(int controller)
{
return new PadSchema
{
DisplayName = "Payload",
IsConsole = false,
DefaultSize = new Size(460, 85),
Buttons = PayLoadButtons(controller)
};
}
2017-04-29 20:41:27 +00:00
private static IEnumerable<PadSchema.ButtonSchema> PayLoadButtons(int controller)
{
int startX = 5;
int startY = 15;
int buttonSpacingX = 28;
int buttonSpacingY = 30;
for (int i = 0; i < 16; i++)
{
2017-04-29 20:41:27 +00:00
yield return new PadSchema.ButtonSchema
{
Name = "P" + controller + " B" + i,
DisplayName = i.ToString(),
Location = new Point(startX + (i * buttonSpacingX), startY),
Type = PadSchema.PadInputType.Boolean
};
}
for (int i = 0; i < 16; i++)
{
2017-04-29 20:41:27 +00:00
yield return new PadSchema.ButtonSchema
{
Name = "P" + controller + " B" + (i + 16),
DisplayName = (i + 16).ToString(),
Location = new Point(startX + (i * buttonSpacingX), startY + buttonSpacingY),
Type = PadSchema.PadInputType.Boolean
};
}
}
2014-06-28 16:52:31 +00:00
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-23 01:43:33 +00:00
{
2014-06-28 16:52:31 +00:00
Name = "Reset",
DisplayName = "Reset",
Location = new Point(10, 15),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
},
2017-04-29 20:41:27 +00:00
new PadSchema.ButtonSchema
2014-06-23 01:43:33 +00:00
{
2014-06-28 16:52:31 +00:00
Name = "Power",
DisplayName = "Power",
Location = new Point(58, 15),
2014-06-23 01:43:33 +00:00
Type = PadSchema.PadInputType.Boolean
2014-06-23 23:25:08 +00:00
}
2014-06-23 01:43:33 +00:00
}
2014-06-22 15:43:45 +00:00
};
}
}
}