Saturn - fix virtualpad logic broken by settings changes, fix mnemonic in 3d controller

This commit is contained in:
adelikat 2020-06-21 13:14:26 -05:00
parent b0007c83f4
commit c76515d7f7
2 changed files with 31 additions and 34 deletions

View File

@ -532,7 +532,7 @@ namespace BizHawk.Client.Common
["D-Pad Up"] = 'U', ["D-Pad Up"] = 'U',
["D-Pad Down"] = 'D', ["D-Pad Down"] = 'D',
["D-Pad Left"] = 'L', ["D-Pad Left"] = 'L',
["D-Pad Right"] = 'L', ["D-Pad Right"] = 'R',
["Mode: Set Digital(+)"] = '+', ["Mode: Set Digital(+)"] = '+',
["Mode: Set Analog(○)"] = 'o', ["Mode: Set Analog(○)"] = 'o',
["L Gear Shift"] = 'L', ["L Gear Shift"] = 'L',

View File

@ -1,10 +1,9 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Consoles.Sega.Saturn; using BizHawk.Emulation.Cores.Waterbox;
using static BizHawk.Emulation.Common.ControllerDefinition; using static BizHawk.Emulation.Common.ControllerDefinition;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -13,29 +12,22 @@ namespace BizHawk.Client.EmuHawk
// ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedMember.Global
public class SaturnSchema : IVirtualPadSchema public class SaturnSchema : IVirtualPadSchema
{ {
private static TValue GetOrDefault<TKey, TValue>(IDictionary<TKey, TValue> dict, TKey key)
{
dict.TryGetValue(key, out var ret);
return ret;
}
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core) public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{ {
var ss = ((Saturnus)core).GetSyncSettings(); var nyma = (NymaCore)core;
var multi1 = GetOrDefault(ss.MednafenValues, "ss.input.sport1.multitap") != "1"; foreach (var result in nyma.ActualPortData
var multi2 = GetOrDefault(ss.MednafenValues, "ss.input.sport2.multitap") != "1"; .Where(r => r.Port.ShortName != "builtin"))
{
var num = int.Parse(result.Port.ShortName.Last().ToString());
var device = result.Device.ShortName;
var schema = GenerateSchemaForPort(device, num);
if (schema != null)
{
yield return schema;
}
}
int totalPorts = 1 + (multi1 ? 6 : 1) + (multi2 ? 6 : 1); yield return ConsoleButtons();
var padSchemas = Enumerable.Range(0, 12)
.Take(totalPorts)
.Concat(new[] { 12 })
.Select(p => new { index = p, device = GetOrDefault(ss.PortDevices, p) })
.Where(a => a.device != null && a.device != "none")
.Select(a => GenerateSchemaForPort(a.device, a.index + 1))
.Concat(new[] { ConsoleButtons() })
.ToList();
return padSchemas;
} }
private static PadSchema GenerateSchemaForPort(string device, int controllerNum) private static PadSchema GenerateSchemaForPort(string device, int controllerNum)
@ -45,7 +37,8 @@ namespace BizHawk.Client.EmuHawk
default: default:
MessageBox.Show($"This peripheral `{device}` is not supported yet"); MessageBox.Show($"This peripheral `{device}` is not supported yet");
return null; return null;
case "none":
return null;
case "gamepad": case "gamepad":
return StandardController(controllerNum); return StandardController(controllerNum);
case "3dpad": case "3dpad":
@ -93,10 +86,10 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(458, 285), Size = new Size(458, 285),
Buttons = new PadSchemaControl[] Buttons = new PadSchemaControl[]
{ {
ButtonSchema.Up(290, 77, controller), ButtonSchema.Up(290, 77, $"P{controller} D-Pad Up"),
ButtonSchema.Down(290, 121, controller), ButtonSchema.Down(290, 121, $"P{controller} D-Pad Down"),
ButtonSchema.Left(278, 99, controller), ButtonSchema.Left(278, 99, $"P{controller} D-Pad Left"),
ButtonSchema.Right(300, 99, controller), ButtonSchema.Right(300, 99, $"P{controller} D-Pad Right"),
new ButtonSchema(334, 112, controller, "Start") { DisplayName = "S" }, new ButtonSchema(334, 112, controller, "Start") { DisplayName = "S" },
new ButtonSchema(366, 123, controller, "A"), new ButtonSchema(366, 123, controller, "A"),
new ButtonSchema(390, 113, controller, "B"), new ButtonSchema(390, 113, controller, "B"),
@ -104,20 +97,20 @@ namespace BizHawk.Client.EmuHawk
new ButtonSchema(366, 100, controller, "X"), new ButtonSchema(366, 100, controller, "X"),
new ButtonSchema(390, 90, controller, "Y"), new ButtonSchema(390, 90, controller, "Y"),
new ButtonSchema(414, 80, controller, "Z"), new ButtonSchema(414, 80, controller, "Z"),
new AnalogSchema(6, 74, $"P{controller} Stick Horizontal") new AnalogSchema(6, 74, $"P{controller} Analog Left / Right")
{ {
SecondaryName = $"P{controller} Stick Vertical", SecondaryName = $"P{controller} Analog Up / Down",
AxisRange = axisRange, AxisRange = axisRange,
SecondaryAxisRange = axisRange SecondaryAxisRange = axisRange
}, },
new SingleAxisSchema(8, 12, controller, "Left Shoulder") new SingleAxisSchema(8, 12, controller, "L")
{ {
DisplayName = "L", DisplayName = "L",
TargetSize = new Size(128, 55), TargetSize = new Size(128, 55),
MinValue = 0, MinValue = 0,
MaxValue = 255 MaxValue = 255
}, },
new SingleAxisSchema(328, 12, controller, "Right Shoulder") new SingleAxisSchema(328, 12, controller, "R")
{ {
DisplayName = "R", DisplayName = "R",
TargetSize = new Size(128, 55), TargetSize = new Size(128, 55),
@ -261,7 +254,7 @@ namespace BizHawk.Client.EmuHawk
{ {
return new ConsoleSchema return new ConsoleSchema
{ {
Size = new Size(250, 50), Size = new Size(327, 50),
Buttons = new[] Buttons = new[]
{ {
new ButtonSchema(10, 15, "Reset"), new ButtonSchema(10, 15, "Reset"),
@ -273,6 +266,10 @@ namespace BizHawk.Client.EmuHawk
new ButtonSchema(175, 15, "Next Disk") new ButtonSchema(175, 15, "Next Disk")
{ {
DisplayName = "Next Disc" DisplayName = "Next Disc"
},
new ButtonSchema(242, 15, "P13 Smpc Reset")
{
DisplayName = "Smpc Reset"
} }
} }
}; };