Controller Config - add a Restore Defaults context menu item that sets up a default mapping for a given controller type.

This commit is contained in:
adelikat 2012-12-03 01:20:06 +00:00
parent d4280b2607
commit e61da61d5d
3 changed files with 531 additions and 550 deletions

View File

@ -780,7 +780,7 @@ namespace BizHawk.MultiClient
public bool Atari2600_ShowPlayfield = true;
}
public class NESConsoleButtonTemplate
public class NESConsoleButtonTemplate : iControllerConfigObject
{
public string Reset = "";
public string Power = "";
@ -788,32 +788,55 @@ namespace BizHawk.MultiClient
//public string FDS_Insert = ""; //Need to support inserting of disk 1,2,3,4,etc so not supporting this for now
//public string VS_Coin_1 = ""; //Not supported yet
//public string VS_Coin_2 = ""; //Not supported yet
public void SetDefaults()
{
Reset = "";
Power = "";
}
}
public class SMSConsoleButtonTemplate
public class SMSConsoleButtonTemplate : iControllerConfigObject
{
public string Reset = "C";
public string Pause = "V, X1 Start";
public void SetDefaults()
{
Reset = "C";
Pause = "V, X1 Start";
}
}
public class GenConsoleButtonTemplate
public class GenConsoleButtonTemplate : iControllerConfigObject
{
public string Reset = "";
public void SetDefaults()
{
Reset = "";
}
}
public class SMSControllerTemplate
public class SMSControllerTemplate : iControllerConfigObject
{
public string Up;
public string Down;
public string Left;
public string Right;
public string B1;
public string B2;
public bool Enabled;
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string B1 = "";
public string B2 = "";
public bool Enabled = false;
public SMSControllerTemplate() { }
public SMSControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -823,34 +846,29 @@ namespace BizHawk.MultiClient
B1 = "Z, X1 A";
B2 = "X, X1 B";
}
else
{
Enabled = false;
Up = "";
Down = "";
Right = "";
Left = "";
B1 = "";
B2 = "";
}
}
}
public class PCEControllerTemplate
public class PCEControllerTemplate : iControllerConfigObject
{
public string Up;
public string Down;
public string Left;
public string Right;
public string I;
public string II;
public string Select;
public string Run;
public bool Enabled;
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string I = "";
public string II = "";
public string Select = "";
public string Run = "";
public bool Enabled = false;
public PCEControllerTemplate() { }
public PCEControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -862,37 +880,33 @@ namespace BizHawk.MultiClient
Run = "C, X1 Start";
Select = "V, X1 Back";
}
else
{
Enabled = false;
Up = "";
Down = "";
Right = "";
Left = "";
I = "";
II = "";
Run = "";
Select = "";
}
}
}
public class SNESControllerTemplate
public class SNESControllerTemplate : iControllerConfigObject
{
public string Up;
public string Down;
public string Left;
public string Right;
public string A;
public string B;
public string Start;
public string Select;
public string Y, X, L, R;
public bool Enabled;
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string A = "";
public string B = "";
public string Start = "";
public string Select = "";
public string Y = "";
public string X = "";
public string L = "";
public string R = "";
public bool Enabled = false;
public SNESControllerTemplate() { }
public SNESControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -908,39 +922,32 @@ namespace BizHawk.MultiClient
Start = "Return, X1 Start";
Select = "Space, X1 Back";
}
else
{
Enabled = false;
Up = "";
Down = "";
Right = "";
Left = "";
A = "";
B = "";
Start = "";
Select = "";
X = Y = L = R = "";
}
}
}
public class GBAControllerTemplate
public class GBAControllerTemplate : iControllerConfigObject
{
public string Up;
public string Down;
public string Left;
public string Right;
public string A;
public string B;
public string Start;
public string Select;
public string L, R;
public string Power;
public bool Enabled;
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string A = "";
public string B = "";
public string Start = "";
public string Select = "";
public string L = "";
public string R = "";
public string Power = "";
public bool Enabled = false;
public GBAControllerTemplate() { }
public GBAControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -955,38 +962,29 @@ namespace BizHawk.MultiClient
Select = "Space, X1 Back";
Power = "";
}
else
{
Enabled = false;
Up = "";
Down = "";
Right = "";
Left = "";
A = "";
B = "";
Start = "";
Select = "";
L = R = "";
Power = "";
}
}
}
public class NESControllerTemplate
public class NESControllerTemplate : iControllerConfigObject
{
public string Up;
public string Down;
public string Left;
public string Right;
public string A;
public string B;
public string Select;
public string Start;
public bool Enabled;
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string A = "";
public string B = "";
public string Select = "";
public string Start = "";
public bool Enabled = false;
public NESControllerTemplate() { }
public NESControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -998,37 +996,30 @@ namespace BizHawk.MultiClient
Start = "Return, X1 Start";
Select = "Space, X1 Back";
}
else
{
Enabled = false;
Up = "";
Down = "";
Right = "";
Left = "";
A = "";
B = "";
Start = "";
Select = "";
}
}
}
public class GBControllerTemplate
public class GBControllerTemplate : iControllerConfigObject
{
public string Up;
public string Down;
public string Left;
public string Right;
public string A;
public string B;
public string Select;
public string Start;
public string Up = "";
public string Down = "";
public string Left = "";
public string Right = "";
public string A = "";
public string B = "";
public string Select = "";
public string Start = "";
public string Power = "";
public bool Enabled;
public bool Enabled = false;
public GBControllerTemplate() { }
public GBControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -1041,23 +1032,9 @@ namespace BizHawk.MultiClient
Select = "Space, X1 Back";
Power = "";
}
else
{
Enabled = false;
Up = "";
Down = "";
Right = "";
Left = "";
A = "";
B = "";
Start = "";
Select = "";
Power = "";
}
}
}
public class GenControllerTemplate
public class GenControllerTemplate : iControllerConfigObject
{
public string Up = "";
public string Down = "";
@ -1073,6 +1050,12 @@ namespace BizHawk.MultiClient
public GenControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -1085,9 +1068,8 @@ namespace BizHawk.MultiClient
Start = "Return, X1 Start";
}
}
}
public class SingleButtonJoyStickTemplate
public class SingleButtonJoyStickTemplate : iControllerConfigObject
{
public string Up = "";
public string Down = "";
@ -1095,13 +1077,21 @@ namespace BizHawk.MultiClient
public string Right = "";
public string Button = "";
public bool Enabled;
public bool UseNumpad;
public SingleButtonJoyStickTemplate() { }
public SingleButtonJoyStickTemplate(bool defaults, bool useNumpad = false)
{
UseNumpad = useNumpad;
if (defaults)
{
if (useNumpad)
SetDefaults();
}
}
public void SetDefaults()
{
if (UseNumpad)
{
Enabled = true;
Up = "NumberPad8, X1 DpadUp, X1 LStickUp";
@ -1121,27 +1111,31 @@ namespace BizHawk.MultiClient
}
}
}
}
public class Atari2600ConsoleButtonsTemplate
public class Atari2600ConsoleButtonsTemplate : iControllerConfigObject
{
public string Reset = "";
public string Select = "";
public bool Enabled;
public bool Enabled = false;
public Atari2600ConsoleButtonsTemplate() { }
public Atari2600ConsoleButtonsTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Reset = "";
Select = "";
}
}
}
public class ColecoVisionControllerTemplate
public class ColecoVisionControllerTemplate : iControllerConfigObject
{
public string Up = "";
public string Down = "";
@ -1167,6 +1161,12 @@ namespace BizHawk.MultiClient
public ColecoVisionControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
Up = "UpArrow, X1 DpadUp, X1 LStickUp";
@ -1189,88 +1189,93 @@ namespace BizHawk.MultiClient
Star = "NumberPadEnter";
}
}
}
public class C64KeyboardTemplate
public class C64KeyboardTemplate : iControllerConfigObject
{
public string F1;
public string F3;
public string F5;
public string F7;
public string F1 = "";
public string F3 = "";
public string F5 = "";
public string F7 = "";
public string Left_Arrow;
public string _1;
public string _2;
public string _3;
public string _4;
public string _5;
public string _6;
public string _7;
public string _8;
public string _9;
public string _0;
public string Plus;
public string Minus;
public string Pound;
public string Clear_Home;
public string Insert_Delete;
public string Left_Arrow = "";
public string _1 = "";
public string _2 = "";
public string _3 = "";
public string _4 = "";
public string _5 = "";
public string _6 = "";
public string _7 = "";
public string _8 = "";
public string _9 = "";
public string _0 = "";
public string Plus = "";
public string Minus = "";
public string Pound = "";
public string Clear_Home = "";
public string Insert_Delete = "";
public string Control;
public string Q;
public string W;
public string E;
public string R;
public string T;
public string Y;
public string U;
public string I;
public string O;
public string P;
public string At;
public string Asterisk;
public string Up_Arrow;
public string Restore;
public string Control = "";
public string Q = "";
public string W = "";
public string E = "";
public string R = "";
public string T = "";
public string Y = "";
public string U = "";
public string I = "";
public string O = "";
public string P = "";
public string At = "";
public string Asterisk = "";
public string Up_Arrow = "";
public string Restore = "";
public string Run_Stop;
public string Lck;
public string A;
public string S;
public string D;
public string F;
public string G;
public string H;
public string J;
public string K;
public string L;
public string Colon;
public string Semicolon;
public string Equal;
public string Return;
public string Run_Stop = "";
public string Lck = "";
public string A = "";
public string S = "";
public string D = "";
public string F = "";
public string G = "";
public string H = "";
public string J = "";
public string K = "";
public string L = "";
public string Colon = "";
public string Semicolon = "";
public string Equal = "";
public string Return = "";
public string Commodore;
public string Left_Shift;
public string Z;
public string X;
public string C;
public string V;
public string B;
public string N;
public string M;
public string Comma;
public string Period;
public string Slash;
public string Right_Shift;
public string Cursor_Up_Down;
public string Cursor_Left_Right;
public string Commodore = "";
public string Left_Shift = "";
public string Z = "";
public string X = "";
public string C = "";
public string V = "";
public string B = "";
public string N = "";
public string M = "";
public string Comma = "";
public string Period = "";
public string Slash = "";
public string Right_Shift = "";
public string Cursor_Up_Down = "";
public string Cursor_Left_Right = "";
public string Space;
public string Space = "";
public bool enabled;
public bool enabled = false;
public C64KeyboardTemplate() { }
public C64KeyboardTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
F1 = "F1";
F3 = "F3";
@ -1343,65 +1348,72 @@ namespace BizHawk.MultiClient
Space = "Space";
}
}
}
public class TI83ControllerTemplate
public class TI83ControllerTemplate : iControllerConfigObject
{
public string _0;
public string _1;
public string _2;
public string _3;
public string _4;
public string _5;
public string _6;
public string _7;
public string _8;
public string _9;
public string DOT;
public string ON;
public string ENTER;
public string DOWN;
public string UP;
public string LEFT;
public string RIGHT;
public string PLUS;
public string MINUS;
public string MULTIPLY;
public string DIVIDE;
public string CLEAR;
public string EXP;
public string DASH;
public string PARACLOSE;
public string TAN;
public string VARS;
public string PARAOPEN;
public string COS;
public string PRGM;
public string STAT;
public string SIN;
public string MATRIX;
public string X;
public string STO;
public string LN;
public string LOG;
public string SQUARED;
public string NEG1;
public string MATH;
public string ALPHA;
public string GRAPH;
public string TRACE;
public string ZOOM;
public string WINDOW;
public string Y;
public string SECOND;
public string MODE;
public string DEL;
public string _0 = "";
public string _1 = "";
public string _2 = "";
public string _3 = "";
public string _4 = "";
public string _5 = "";
public string _6 = "";
public string _7 = "";
public string _8 = "";
public string _9 = "";
public string DOT = "";
public string ON = "";
public string ENTER = "";
public string DOWN = "";
public string UP = "";
public string LEFT = "";
public string RIGHT = "";
public string PLUS = "";
public string MINUS = "";
public string MULTIPLY = "";
public string DIVIDE = "";
public string CLEAR = "";
public string EXP = "";
public string DASH = "";
public string PARACLOSE = "";
public string TAN = "";
public string VARS = "";
public string PARAOPEN = "";
public string COS = "";
public string PRGM = "";
public string STAT = "";
public string SIN = "";
public string MATRIX = "";
public string X = "";
public string STO = "";
public string LN = "";
public string LOG = "";
public string SQUARED = "";
public string NEG1 = "";
public string MATH = "";
public string ALPHA = "";
public string GRAPH = "";
public string TRACE = "";
public string ZOOM = "";
public string WINDOW = "";
public string Y = "";
public string SECOND = "";
public string MODE = "";
public string DEL = "";
public string COMMA = "";
public bool Enabled = false;
public TI83ControllerTemplate() { }
public bool Enabled;
public string COMMA;
public TI83ControllerTemplate(bool defaults)
{
if (defaults)
{
SetDefaults();
}
}
public void SetDefaults()
{
Enabled = true;
_0 = "NumberPad0"; //0
@ -1455,60 +1467,10 @@ namespace BizHawk.MultiClient
COMMA = "Comma"; //48
SIN = "Period"; //49
}
else
}
public interface iControllerConfigObject
{
Enabled = false;
_0 = "";
_1 = "";
_2 = "";
_3 = "";
_4 = "";
_5 = "";
_6 = "";
_7 = "";
_8 = "";
_9 = "";
DOT = "";
ON = "";
ENTER = "";
UP = "";
DOWN = "";
LEFT = "";
RIGHT = "";
PLUS = "";
MINUS = "";
MULTIPLY = "";
DIVIDE = "";
CLEAR = "";
EXP = "";
DASH = "";
PARACLOSE = "";
TAN = "";
VARS = "";
PARAOPEN = "";
COS = "";
PRGM = "";
STAT = "";
SIN = "";
MATRIX = "";
X = "";
STO = "";
LN = "";
LOG = "";
SQUARED = "";
NEG1 = "";
MATH = "";
ALPHA = "";
GRAPH = "";
TRACE = "";
ZOOM = "";
WINDOW = "";
Y = "";
SECOND = "";
MODE = "";
DEL = "";
COMMA = "";
}
}
void SetDefaults();
}
}

View File

@ -31,15 +31,17 @@
this.components = new System.ComponentModel.Container();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restoreDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.clearToolStripMenuItem});
this.clearToolStripMenuItem,
this.restoreDefaultsToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(102, 26);
this.contextMenuStrip1.Size = new System.Drawing.Size(160, 70);
//
// clearToolStripMenuItem
//
@ -48,6 +50,13 @@
this.clearToolStripMenuItem.Text = "&Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
//
// restoreDefaultsToolStripMenuItem
//
this.restoreDefaultsToolStripMenuItem.Name = "restoreDefaultsToolStripMenuItem";
this.restoreDefaultsToolStripMenuItem.Size = new System.Drawing.Size(159, 22);
this.restoreDefaultsToolStripMenuItem.Text = "&Restore Defaults";
this.restoreDefaultsToolStripMenuItem.Click += new System.EventHandler(this.restoreDefaultsToolStripMenuItem_Click);
//
// ControllerConfigPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -64,5 +73,6 @@
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restoreDefaultsToolStripMenuItem;
}
}

View File

@ -12,7 +12,7 @@ namespace BizHawk.MultiClient
{
public partial class ControllerConfigPanel : UserControl
{
object ControllerConfigObject; //Object that values will be saved to (In Config.cs)
iControllerConfigObject ControllerConfigObject; //Object that values will be saved to (In Config.cs)
public List<string> buttons = new List<string>();
@ -55,7 +55,7 @@ namespace BizHawk.MultiClient
}
}
public void LoadSettings(object configobj)
public void LoadSettings(iControllerConfigObject configobj)
{
ControllerConfigObject = configobj;
@ -139,5 +139,14 @@ namespace BizHawk.MultiClient
{
ClearAll();
}
private void restoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (ControllerConfigObject is iControllerConfigObject)
{
(ControllerConfigObject as iControllerConfigObject).SetDefaults();
}
SetWidgetStrings();
}
}
}