snes - some progress on controller configuration support - use controller deck for ControllerDefinition and hack in appropriate button orders

This commit is contained in:
adelikat 2017-04-15 18:34:12 -05:00
parent 31ba7bc3dd
commit 2daa1b3d68
2 changed files with 34 additions and 21 deletions

View File

@ -103,9 +103,34 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
"0R"
};
private static int ButtonOrder(string btn)
{
var order = new Dictionary<string, int>
{
["0Up"] = 0,
["0Down"] = 1,
["0Left"] = 2,
["0Right"] = 3,
["0Select"] = 4,
["0Start"] = 5,
["0Y"] = 6,
["0B"] = 7,
["0X"] = 8,
["0A"] = 9,
["0L"] = 10,
["0R"] = 11
};
return order[btn];
}
private static readonly ControllerDefinition _definition = new ControllerDefinition
{
BoolButtons = Buttons.ToList()
BoolButtons = Buttons.OrderBy(ButtonOrder).ToList()
};
public ControllerDefinition Definition { get; } = _definition;

View File

@ -5,7 +5,7 @@
//TODO
//libsnes needs to be modified to support multiple instances - THIS IS NECESSARY - or else loading one game and then another breaks things
// edit - this is a lot of work
//wrap dll code around some kind of library-accessing interface so that it doesnt malfunction if the dll is unavailable
//wrap dll code around some kind of library-accessing interface so that it doesnt malfunction if the dll is unavailablecd
using System;
using System.Linq;
@ -67,10 +67,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
ScanlineHookManager = new MyScanlineHookManager(this);
//TODO: set correct port inputs from sync settings
_controllerDeck = new LibsnesControllerDeck(LibsnesControllerDeck.ControllerType.Gamepad,
LibsnesControllerDeck.ControllerType.Gamepad);
_controllerDeck = new LibsnesControllerDeck(this.SyncSettings.LeftPort,
this.SyncSettings.RightPort);
_controllerDeck.NativeInit(api);
api.CMD_init();
api.QUERY_set_video_refresh(snes_video_refresh);
@ -704,7 +704,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
int[] vidBuffer = new int[256 * 224];
int vidWidth = 256, vidHeight = 224;
public ControllerDefinition ControllerDefinition { get { return SNESController; } }
public ControllerDefinition ControllerDefinition { get { return _controllerDeck.Definition; } }
IController controller;
public IController Controller
{
@ -712,21 +712,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
set { controller = value; }
}
public static readonly ControllerDefinition SNESController =
new ControllerDefinition
{
Name = "SNES Controller",
BoolButtons = {
"Reset", "Power",
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Select", "P1 Start", "P1 Y", "P1 B", "P1 X", "P1 A", "P1 L", "P1 R",
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Select", "P2 Start", "P2 Y", "P2 B", "P2 X", "P2 A", "P2 L", "P2 R",
// adelikat: disabling these since they aren't hooked up
// "P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 Select", "P3 Start", "P3 Y", "P3 B", "P3 X", "P3 A", "P3 L", "P3 R",
// "P4 Up", "P4 Down", "P4 Left", "P4 Right", "P4 Select", "P4 Start", "P4 Y", "P4 B", "P4 X", "P4 A", "P4 L", "P4 R",
}
};
int timeFrameCounter;
public int Frame { get { return timeFrameCounter; } set { timeFrameCounter = value; } }
public int LagCount { get; set; }
@ -1323,6 +1308,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
public string Profile = "Performance"; // "Accuracy", and "Compatibility" are the other choicec, todo: make this an enum
public LibsnesControllerDeck.ControllerType LeftPort { get; set; } = LibsnesControllerDeck.ControllerType.Gamepad;
public LibsnesControllerDeck.ControllerType RightPort { get; set; } = LibsnesControllerDeck.ControllerType.Gamepad;
public SnesSyncSettings Clone()
{
return (SnesSyncSettings)MemberwiseClone();