Rename IController.Type to IController.Definition to more clearly describe the property

This commit is contained in:
adelikat 2016-12-12 12:30:32 -06:00
parent bd7bd831c7
commit 5ff33e7569
31 changed files with 130 additions and 127 deletions

View File

@ -340,7 +340,7 @@ namespace BizHawk.Client.ApiHawk
{
AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
IEnumerable<string> pressedButtons = from button in joypadAdaptor.Type.BoolButtons
IEnumerable<string> pressedButtons = from button in joypadAdaptor.Definition.BoolButtons
where joypadAdaptor[button]
select button;

View File

@ -27,7 +27,7 @@ namespace BizHawk.Client.Common
}
}
public ControllerDefinition Type { get { return _type; } }
public ControllerDefinition Definition { get { return _type; } }
/// <summary>don't do this</summary>
public void ForceType(ControllerDefinition newtype) { _type = newtype; }
@ -165,9 +165,9 @@ namespace BizHawk.Client.Common
{
// change: or from each button that the other input controller has
// foreach (string button in type.BoolButtons)
if (controller.Type != null)
if (controller.Definition != null)
{
foreach (var button in controller.Type.BoolButtons)
foreach (var button in controller.Definition.BoolButtons)
{
if (controller.IsPressed(button))
{
@ -259,7 +259,7 @@ namespace BizHawk.Client.Common
public int On { get; set; }
public int Off { get; set; }
public ControllerDefinition Type { get { return _type; } }
public ControllerDefinition Definition { get { return _type; } }
public bool this[string button] { get { return IsPressed(button); } }
public bool IsPressed(string button)
{

View File

@ -17,7 +17,7 @@ namespace BizHawk.Client.Common
public IController Source { get; set; }
public IController SourceAnd { get; set; }
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public ControllerDefinition Definition { get { return Source.Definition; } set { throw new InvalidOperationException(); } }
public bool this[string button]
{
@ -52,9 +52,9 @@ namespace BizHawk.Client.Common
public IController Source { get; set; }
public IController SourceOr { get; set; }
public ControllerDefinition Type
public ControllerDefinition Definition
{
get { return Source.Type; }
get { return Source.Definition; }
set { throw new InvalidOperationException(); }
}

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.Common
/// </summary>
public class ClickyVirtualPadController : IController
{
public ControllerDefinition Type { get; set; }
public ControllerDefinition Definition { get; set; }
public bool this[string button]
{
@ -86,9 +86,9 @@ namespace BizHawk.Client.Common
/// </summary>
public class UD_LR_ControllerAdapter : IController
{
public ControllerDefinition Type
public ControllerDefinition Definition
{
get { return Source.Type; }
get { return Source.Definition; }
}
public bool this[string button]
@ -185,7 +185,7 @@ namespace BizHawk.Client.Common
public class SimpleController : IController
{
public ControllerDefinition Type { get; set; }
public ControllerDefinition Definition { get; set; }
protected WorkingDictionary<string, bool> Buttons = new WorkingDictionary<string, bool>();
protected WorkingDictionary<string, float> Floats = new WorkingDictionary<string, float>();
@ -219,7 +219,7 @@ namespace BizHawk.Client.Common
public virtual void LatchFrom(IController source)
{
foreach (var button in source.Type.BoolButtons)
foreach (var button in source.Definition.BoolButtons)
{
Buttons[button] = source[button];
}
@ -246,13 +246,13 @@ namespace BizHawk.Client.Common
// this works in the code because SourceOr is the autofire controller
public float GetFloat(string name)
{
int i = Source.Type.FloatControls.IndexOf(name);
return Source.Type.FloatRanges[i].Mid; // Floats don't make sense in sticky land
int i = Source.Definition.FloatControls.IndexOf(name);
return Source.Definition.FloatRanges[i].Mid; // Floats don't make sense in sticky land
}
public ISticky Source { get; set; }
public ISticky SourceStickyOr { get; set; }
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public ControllerDefinition Definition { get { return Source.Definition; } set { throw new InvalidOperationException(); } }
public bool this[string button]
{
@ -280,9 +280,9 @@ namespace BizHawk.Client.Common
public IController Source { get; set; }
public ControllerDefinition Type
public ControllerDefinition Definition
{
get { return Source.Type; }
get { return Source.Definition; }
set { throw new InvalidOperationException(); }
}
@ -440,9 +440,9 @@ namespace BizHawk.Client.Common
public IController Source { get; set; }
public ControllerDefinition Type
public ControllerDefinition Definition
{
get { return Source.Type; }
get { return Source.Definition; }
}
public bool Locked { get; set; } // Pretty much a hack,
@ -598,9 +598,9 @@ namespace BizHawk.Client.Common
}
}
public ControllerDefinition Type
public ControllerDefinition Definition
{
get { return Curr.Type; }
get { return Curr.Definition; }
}
public bool this[string button]
@ -654,7 +654,7 @@ namespace BizHawk.Client.Common
}
}
public ControllerDefinition Type { get; set; }
public ControllerDefinition Definition { get; set; }
public IEnumerable<string> Overrides
{

View File

@ -9,7 +9,7 @@ namespace BizHawk.Client.Common
public static void RewireInputChain()
{
Global.ControllerInputCoalescer.Clear();
Global.ControllerInputCoalescer.Type = Global.ActiveController.Type;
Global.ControllerInputCoalescer.Definition = Global.ActiveController.Definition;
Global.UD_LR_ControllerAdapter.Source = Global.ActiveController.Or(Global.AutoFireController);
@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
Global.ControllerOutput.Source = Global.MovieOutputHardpoint;
Global.Emulator.Controller = Global.ControllerOutput;
Global.MovieSession.MovieControllerAdapter.Type = Global.MovieInputSourceAdapter.Type;
Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition;
// connect the movie session before MovieOutputHardpoint if it is doing anything
// otherwise connect the MovieInputSourceAdapter to it, effectively bypassing the movie session
@ -45,7 +45,7 @@ namespace BizHawk.Client.Common
// allow propogating controls that are in the current controller definition but not in the prebaked one
// these two lines shouldn't be required anymore under the new system?
Global.ActiveController.ForceType(new ControllerDefinition(def));
Global.ClickyVirtualPadController.Type = new ControllerDefinition(def);
Global.ClickyVirtualPadController.Definition = new ControllerDefinition(def);
RewireInputChain();
}

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
{
var buttons = Lua.NewTable();
var adaptor = Global.AutofireStickyXORAdapter;
foreach (var button in adaptor.Source.Type.BoolButtons)
foreach (var button in adaptor.Source.Definition.BoolButtons)
{
if (!controller.HasValue)
{
@ -33,7 +33,7 @@ namespace BizHawk.Client.Common
}
}
foreach (var button in adaptor.Source.Type.FloatControls)
foreach (var button in adaptor.Source.Definition.FloatControls)
{
if (controller == null)
{
@ -59,7 +59,7 @@ namespace BizHawk.Client.Common
public LuaTable GetImmediate()
{
var buttons = Lua.NewTable();
foreach (var button in Global.ActiveController.Type.BoolButtons)
foreach (var button in Global.ActiveController.Definition.BoolButtons)
{
buttons[button] = Global.ActiveController[button];
}
@ -78,12 +78,12 @@ namespace BizHawk.Client.Common
var lg = Global.MovieSession.MovieControllerInstance();
lg.SetControllersAsMnemonic(inputLogEntry);
foreach (var button in lg.Type.BoolButtons)
foreach (var button in lg.Definition.BoolButtons)
{
Global.LuaAndAdaptor.SetButton(button, lg.IsPressed(button));
}
foreach (var floatButton in lg.Type.FloatControls)
foreach (var floatButton in lg.Definition.FloatControls)
{
Global.LuaAndAdaptor.SetFloat(floatButton, lg.GetFloat(floatButton));
}

View File

@ -63,12 +63,12 @@ namespace BizHawk.Client.Common
return null;
}
foreach (var button in adapter.Type.BoolButtons)
foreach (var button in adapter.Definition.BoolButtons)
{
input[button] = adapter[button];
}
foreach (var button in adapter.Type.FloatControls)
foreach (var button in adapter.Definition.FloatControls)
{
input[button] = adapter[button];
}

View File

@ -65,7 +65,7 @@ namespace BizHawk.Client.Common
public IMovieController MovieControllerInstance()
{
var adapter = Movie.LogGeneratorInstance().MovieControllerAdapter;
adapter.Type = MovieControllerAdapter.Type;
adapter.Definition = MovieControllerAdapter.Definition;
return adapter;
}

View File

@ -94,7 +94,7 @@ namespace BizHawk.Client.Common
public int PlayerSource { get; set; }
public int PlayerTargetMask { get; set; }
public ControllerDefinition Type { get { return Source.Type; } }
public ControllerDefinition Definition { get { return Source.Definition; } }
public bool this[string button]
{

View File

@ -71,7 +71,7 @@ namespace BizHawk.Client.Common
private Bk2ControllerDefinition _type = new Bk2ControllerDefinition();
public ControllerDefinition Type
public ControllerDefinition Definition
{
get
{
@ -90,7 +90,7 @@ namespace BizHawk.Client.Common
/// </summary>
public void LatchPlayerFromSource(IController playerSource, int playerNum)
{
foreach (var button in playerSource.Type.BoolButtons)
foreach (var button in playerSource.Definition.BoolButtons)
{
var bnp = ButtonNameParser.Parse(button);
if (bnp == null)
@ -107,7 +107,7 @@ namespace BizHawk.Client.Common
MyBoolButtons[button] = val;
}
foreach (var button in Type.FloatControls)
foreach (var button in Definition.FloatControls)
{
var bnp = ButtonNameParser.Parse(button);
if (bnp == null)
@ -131,12 +131,12 @@ namespace BizHawk.Client.Common
/// </summary>
public void LatchFromSource(IController source)
{
foreach (var button in Type.BoolButtons)
foreach (var button in Definition.BoolButtons)
{
MyBoolButtons[button] = source.IsPressed(button);
}
foreach (var name in Type.FloatControls)
foreach (var name in Definition.FloatControls)
{
MyFloatControls[name] = source.GetFloat(name);
}
@ -151,7 +151,7 @@ namespace BizHawk.Client.Common
{
var def = Global.Emulator.ControllerDefinition;
var trimmed = mnemonic.Replace("|", "");
var buttons = Type.ControlsOrdered.SelectMany(x => x).ToList();
var buttons = Definition.ControlsOrdered.SelectMany(x => x).ToList();
var iterator = 0;
foreach (var key in buttons)

View File

@ -67,7 +67,7 @@ namespace BizHawk.Client.Common
var sb = new StringBuilder();
sb.Append("LogKey:");
foreach (var group in _source.Type.ControlsOrdered.Where(c => c.Any()))
foreach (var group in _source.Definition.ControlsOrdered.Where(c => c.Any()))
{
sb.Append("#");
foreach (var button in group)
@ -84,15 +84,15 @@ namespace BizHawk.Client.Common
public Dictionary<string, string> Map()
{
var dict = new Dictionary<string, string>();
foreach (var group in _source.Type.ControlsOrdered.Where(c => c.Any()))
foreach (var group in _source.Definition.ControlsOrdered.Where(c => c.Any()))
{
foreach (var button in group)
{
if (_source.Type.BoolButtons.Contains(button))
if (_source.Definition.BoolButtons.Contains(button))
{
dict.Add(button, Mnemonics[button].ToString());
}
else if (_source.Type.FloatControls.Contains(button))
else if (_source.Definition.FloatControls.Contains(button))
{
dict.Add(button, FloatLookup[button]);
}
@ -109,17 +109,17 @@ namespace BizHawk.Client.Common
if (!forInputDisplay)
sb.Append('|');
foreach (var group in _source.Type.ControlsOrdered)
foreach (var group in _source.Definition.ControlsOrdered)
{
if (group.Any())
{
foreach (var button in group)
{
if (_source.Type.FloatControls.Contains(button))
if (_source.Definition.FloatControls.Contains(button))
{
int val;
int i = _source.Type.FloatControls.IndexOf(button);
int mid = (int)_source.Type.FloatRanges[i].Mid;
int i = _source.Definition.FloatControls.IndexOf(button);
int mid = (int)_source.Definition.FloatRanges[i].Mid;
if (createEmpty)
{
@ -135,7 +135,7 @@ namespace BizHawk.Client.Common
else
sb.Append(val.ToString().PadLeft(5, ' ')).Append(',');
}
else if (_source.Type.BoolButtons.Contains(button))
else if (_source.Definition.BoolButtons.Contains(button))
{
if (createEmpty)
{

View File

@ -321,7 +321,7 @@ namespace BizHawk.Client.Common
private string ConvertLogEntryFromFile(string line, string logKey)
{
var adapter = new Bk2LogEntryGenerator(logKey).MovieControllerAdapter;
adapter.Type = Global.MovieSession.MovieControllerAdapter.Type;
adapter.Definition = Global.MovieSession.MovieControllerAdapter.Definition;
adapter.SetControllersAsMnemonic(line);
var lg = LogGeneratorInstance();

View File

@ -143,7 +143,7 @@ namespace BizHawk.Client.Common
var adapter = new Bk2ControllerAdapter
{
Type = Global.MovieSession.MovieControllerAdapter.Type
Definition = Global.MovieSession.MovieControllerAdapter.Definition
};
adapter.SetControllersAsMnemonic(_log[getframe]);

View File

@ -28,14 +28,14 @@ namespace BizHawk.Client.Common
#region IMovieController Implementation
public ControllerDefinition Type { get; set; }
public ControllerDefinition Definition { get; set; }
/// <summary>
/// latches one player from the source
/// </summary>
public void LatchPlayerFromSource(IController playerSource, int playerNum)
{
foreach (var button in playerSource.Type.BoolButtons)
foreach (var button in playerSource.Definition.BoolButtons)
{
var bnp = ButtonNameParser.Parse(button);
if (bnp == null)
@ -58,12 +58,12 @@ namespace BizHawk.Client.Common
/// </summary>
public void LatchFromSource(IController source)
{
foreach (var button in Type.BoolButtons)
foreach (var button in Definition.BoolButtons)
{
MyBoolButtons[button] = source[button];
}
foreach (var name in Type.FloatControls)
foreach (var name in Definition.FloatControls)
{
MyFloatControls[name] = source.GetFloat(name);
}
@ -258,7 +258,7 @@ namespace BizHawk.Client.Common
private bool IsGenesis6Button()
{
return this.Type.BoolButtons.Contains("P1 X");
return this.Definition.BoolButtons.Contains("P1 X");
}
private void Force(string button, bool state)
@ -271,7 +271,7 @@ namespace BizHawk.Client.Common
MyFloatControls[name] = state;
}
private string ControlType { get { return Type.Name; } }
private string ControlType { get { return Definition.Name; } }
private void SetGBAControllersAsMnemonic(string mnemonic)
{

View File

@ -12,7 +12,7 @@ namespace BizHawk.Client.Common
public void SetSource(IController source)
{
_source = source;
_controlType = source.Type.Name;
_controlType = source.Definition.Name;
}
public string GenerateLogEntry()

View File

@ -100,7 +100,7 @@ namespace BizHawk.Client.Common
var adapter = new BkmControllerAdapter
{
Type = Global.MovieSession.MovieControllerAdapter.Type
Definition = Global.MovieSession.MovieControllerAdapter.Definition
};
adapter.SetControllersAsMnemonic(_log[getframe]);
return adapter;

View File

@ -241,7 +241,7 @@ namespace BizHawk.Client.Common
private static IController EmptyLmsvFrame(string line)
{
var emptyController = new SimpleController { Type = new ControllerDefinition { Name = "SNES Controller" } };
var emptyController = new SimpleController { Definition = new ControllerDefinition { Name = "SNES Controller" } };
emptyController["Reset"] = false;
emptyController["Power"] = false;
@ -294,7 +294,7 @@ namespace BizHawk.Client.Common
controller = "Saturn Controller";
break;
}
var controllers = new SimpleController { Type = new ControllerDefinition { Name = controller } };
var controllers = new SimpleController { Definition = new ControllerDefinition { Name = controller } };
// Split up the sections of the frame.
string[] sections = line.Split('|');
if (ext == ".FM2" && sections.Length >= 2 && sections[1].Length != 0)
@ -373,14 +373,14 @@ namespace BizHawk.Client.Common
int player = section + player_offset;
string prefix = "P" + (player) + " ";
// Gameboy doesn't currently have a prefix saying which player the input is for.
if (controllers.Type.Name == "Gameboy Controller")
if (controllers.Definition.Name == "Gameboy Controller")
{
prefix = "";
}
// Only count lines with that have the right number of buttons and are for valid players.
if (
sections[section].Length == buttons.Length &&
player <= BkmMnemonicConstants.PLAYERS[controllers.Type.Name]
player <= BkmMnemonicConstants.PLAYERS[controllers.Definition.Name]
)
{
for (int button = 0; button < buttons.Length; button++)
@ -724,7 +724,7 @@ namespace BizHawk.Client.Common
m.Header[HeaderKeys.AUTHOR] = author;
// Advance to first byte of input data.
r.BaseStream.Position = firstFrameOffset;
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = "NES Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } };
string[] buttons = { "A", "B", "Select", "Start", "Up", "Down", "Left", "Right" };
bool fds = false;
bool fourscore = false;
@ -955,7 +955,7 @@ namespace BizHawk.Client.Common
*/
m.Header[HeaderKeys.PAL] = "False";
// 090 frame data begins here
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = "NES Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } };
/*
* 01 Right
* 02 Left
@ -1042,14 +1042,14 @@ namespace BizHawk.Client.Common
string player1Config = r.ReadStringFixedAscii(1);
// 015 ASCII-encoded controller config for player 2. '3' or '6'.
string player2Config = r.ReadStringFixedAscii(1);
SimpleController controllers = new SimpleController { Type = new ControllerDefinition() };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition() };
if (player1Config == "6" || player2Config == "6")
{
controllers.Type.Name = "GPGX Genesis Controller";
controllers.Definition.Name = "GPGX Genesis Controller";
}
else
{
controllers.Type.Name = "GPGX 3-Button Controller";
controllers.Definition.Name = "GPGX 3-Button Controller";
}
// 016 special flags (Version A and up only)
byte flags = r.ReadByte();
@ -1474,7 +1474,7 @@ namespace BizHawk.Client.Common
r.ReadBytes(103);
// TODO: Verify if NTSC/"PAL" mode used for the movie can be detected or not.
// 100 variable Input data
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = name + " Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = name + " Controller" } };
int bytes = 256;
// The input stream consists of 1 byte for power-on and reset, and then X bytes per each input port per frame.
if (platform == "nes")
@ -1595,7 +1595,7 @@ namespace BizHawk.Client.Common
// 00e4-00f3: binary: rom MD5 digest
byte[] md5 = r.ReadBytes(16);
m.Header[MD5] = string.Format("{0:x8}", md5.BytesToHexString().ToLower());
var controllers = new SimpleController { Type = new ControllerDefinition { Name = "SMS Controller" } };
var controllers = new SimpleController { Definition = new ControllerDefinition { Name = "SMS Controller" } };
/*
76543210
* bit 0 (0x01): up
@ -1820,7 +1820,7 @@ namespace BizHawk.Client.Common
// ... 4-byte little-endian unsigned int: length of controller data in bytes
uint length = r.ReadUInt32();
// ... (variable) controller data
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = "NES Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } };
/*
Standard controllers store data in the following format:
* 01: A
@ -1923,7 +1923,7 @@ namespace BizHawk.Client.Common
* bit 4: controller 5 in use
* other: reserved, set to 0
*/
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = "SNES Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "SNES Controller" } };
bool[] controllersUsed = new bool[5];
for (int controller = 1; controller <= controllersUsed.Length; controller++)
{
@ -2109,7 +2109,7 @@ namespace BizHawk.Client.Common
}
}
ushort controllerState = (ushort)(((controllerState1 << 4) & 0x0F00) | controllerState2);
if (player <= BkmMnemonicConstants.PLAYERS[controllers.Type.Name])
if (player <= BkmMnemonicConstants.PLAYERS[controllers.Definition.Name])
{
for (int button = 0; button < buttons.Length; button++)
{
@ -2334,14 +2334,14 @@ namespace BizHawk.Client.Common
string movieDescription = NullTerminated(r.ReadStringFixedAscii(128));
m.Comments.Add(COMMENT + " " + movieDescription);
r.BaseStream.Position = firstFrameOffset;
SimpleController controllers = new SimpleController { Type = new ControllerDefinition() };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition() };
if (platform != "GBA")
{
controllers.Type.Name = "Gameboy Controller";
controllers.Definition.Name = "Gameboy Controller";
}
else
{
controllers.Type.Name = "GBA Controller";
controllers.Definition.Name = "GBA Controller";
}
/*
* 01 00 A
@ -2512,7 +2512,7 @@ namespace BizHawk.Client.Common
return m;
}
r.BaseStream.Position = firstFrameOffset;
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = "NES Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "NES Controller" } };
/*
* 01 A
* 02 B
@ -2749,7 +2749,7 @@ namespace BizHawk.Client.Common
uint savestateSize = (uint)((r.ReadByte() | (r.ReadByte() << 8) | (r.ReadByte() << 16)) & 0x7FFFFF);
// Next follows a ZST format savestate.
r.ReadBytes((int)savestateSize);
SimpleController controllers = new SimpleController { Type = new ControllerDefinition { Name = "SNES Controller" } };
SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = "SNES Controller" } };
/*
* bit 11: A
* bit 10: X
@ -2903,7 +2903,7 @@ namespace BizHawk.Client.Common
}
}
leftOver = !leftOver;
if (player <= BkmMnemonicConstants.PLAYERS[controllers.Type.Name])
if (player <= BkmMnemonicConstants.PLAYERS[controllers.Definition.Name])
{
if (player != 2 || !superScope)
{

View File

@ -183,7 +183,7 @@ namespace BizHawk.Client.Common
info.player2Type,
OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None
};
controllers.Type = Octoshock.CreateControllerDefinition(settings);
controllers.Definition = Octoshock.CreateControllerDefinition(settings);
string[] buttons = { "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left",
"L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square"};
@ -290,7 +290,7 @@ namespace BizHawk.Client.Common
info.player2Type,
OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None,OctoshockDll.ePeripheralType.None
};
controllers.Type = Octoshock.CreateControllerDefinition(settings);
controllers.Definition = Octoshock.CreateControllerDefinition(settings);
string[] buttons = { "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left",
"L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square"};

View File

@ -4,7 +4,7 @@ namespace BizHawk.Client.Common
{
public interface IMovieController: IController
{
new ControllerDefinition Type { get; set; }
new ControllerDefinition Definition { get; set; }
void LatchPlayerFromSource(IController playerSource, int playerNum);

View File

@ -268,14 +268,14 @@ namespace BizHawk.Client.Common
public string CreateDisplayValueForButton(IController adapter, string buttonName)
{
if (adapter.Type.BoolButtons.Contains(buttonName))
if (adapter.Definition.BoolButtons.Contains(buttonName))
{
return adapter.IsPressed(buttonName) ?
Mnemonics[buttonName].ToString() :
string.Empty;
}
if (adapter.Type.FloatControls.Contains(buttonName))
if (adapter.Definition.FloatControls.Contains(buttonName))
{
return adapter.GetFloat(buttonName).ToString();
}

View File

@ -903,7 +903,7 @@ namespace BizHawk.Client.EmuHawk
var lg = Global.MovieSession.MovieControllerInstance();
lg.SetControllersAsMnemonic(logEntry);
foreach (var button in lg.Type.BoolButtons)
foreach (var button in lg.Definition.BoolButtons)
{
// TODO: make an input adapter specifically for the bot?
Global.LuaAndAdaptor.SetButton(button, lg.IsPressed(button));

View File

@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk
var lg = Global.MovieSession.LogGeneratorInstance() as Bk2LogEntryGenerator;
lg.SetSource(Global.MovieSession.MovieControllerAdapter);
targetController = new Bk2ControllerAdapter();
targetController.Type = Global.Emulator.ControllerDefinition;
targetController.Definition = Global.Emulator.ControllerDefinition;
targetController.LatchFromSource(targetController); // Reference and create all buttons
if (key == "")
@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
}
}
controller = new Bk2ControllerAdapter { Type = d };
controller = new Bk2ControllerAdapter { Definition = d };
var logGenerator = new Bk2LogEntryGenerator("");
logGenerator.SetSource(controller);
logGenerator.GenerateLogEntry(); // Reference and create all buttons.
@ -104,7 +104,7 @@ namespace BizHawk.Client.EmuHawk
}
}
var newController = new Bk2ControllerAdapter { Type = d };
var newController = new Bk2ControllerAdapter { Definition = d };
var logGenerator = new Bk2LogEntryGenerator("");
logGenerator.SetSource(newController);
@ -252,7 +252,7 @@ namespace BizHawk.Client.EmuHawk
// Adapters
targetController = new Bk2ControllerAdapter();
targetController.Type = Global.Emulator.ControllerDefinition;
targetController.Definition = Global.Emulator.ControllerDefinition;
targetController.LatchFromSource(targetController); // Reference and create all buttons
string[] keys = _inputKey.Split('|');
ControllerDefinition d = new ControllerDefinition();
@ -268,19 +268,19 @@ namespace BizHawk.Client.EmuHawk
}
}
controller = new Bk2ControllerAdapter { Type = d };
controller = new Bk2ControllerAdapter { Definition = d };
}
#region Custom Latch
private void LatchFromSourceButtons(Bk2ControllerAdapter latching, IController source)
{
foreach (string button in source.Type.BoolButtons)
foreach (string button in source.Definition.BoolButtons)
{
latching[button] = source.IsPressed(button);
}
foreach (string name in source.Type.FloatControls)
foreach (string name in source.Definition.FloatControls)
{
latching.SetFloat(name, source.GetFloat(name));
}
@ -288,16 +288,16 @@ namespace BizHawk.Client.EmuHawk
private void ORLatchFromSource(Bk2ControllerAdapter latching, IController source)
{
foreach (string button in latching.Type.BoolButtons)
foreach (string button in latching.Definition.BoolButtons)
{
latching[button] |= source.IsPressed(button);
}
foreach (string name in latching.Type.FloatControls)
foreach (string name in latching.Definition.FloatControls)
{
float sFloat = source.GetFloat(name);
int indexRange = source.Type.FloatControls.IndexOf(name);
if (sFloat == source.Type.FloatRanges[indexRange].Mid)
int indexRange = source.Definition.FloatControls.IndexOf(name);
if (sFloat == source.Definition.FloatRanges[indexRange].Mid)
{
latching.SetFloat(name, sFloat);
}

View File

@ -20,9 +20,9 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent();
tastudio = owner;
foreach (var button in Global.MovieSession.MovieControllerAdapter.Type.BoolButtons)
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons)
ButtonBox.Items.Add(button);
foreach (var button in Global.MovieSession.MovieControllerAdapter.Type.FloatControls)
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.FloatControls)
ButtonBox.Items.Add(button);
ButtonBox.Items.Add("Default bool Auto-Fire");
ButtonBox.Items.Add("Default float Auto-Fire");
@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
List<string> values = new List<string>();
int loopAt;
string selectedButton { get { return ButtonBox.Text; } }
bool isBool { get { return selectedButton == "Default bool Auto-Fire" || Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(selectedButton); } }
bool isBool { get { return selectedButton == "Default bool Auto-Fire" || Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(selectedButton); } }
private void ButtonBox_SelectedIndexChanged(object sender, EventArgs e)
{
@ -150,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < values.Count)
{
index = Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.IndexOf(selectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
if (selectedButton == "Default bool Auto-Fire")
index = tastudio.BoolPatterns.Length + 1;
if (index != -1)
@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk
if (selectedButton == "Default float Auto-Fire")
index = tastudio.FloatPatterns.Length + 1;
else
index = Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(selectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
LagBox.Checked = tastudio.FloatPatterns[index].SkipsLag;
ValueNum.Value = Convert.ToDecimal(values[PatternList.SelectedIndex]);
@ -180,7 +180,7 @@ namespace BizHawk.Client.EmuHawk
private void UpdatePattern()
{
int index = Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.IndexOf(selectedButton);
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
if (selectedButton == "Default bool Auto-Fire")
index = tastudio.BoolPatterns.Length + 1;
if (index != -1)
@ -198,7 +198,7 @@ namespace BizHawk.Client.EmuHawk
if (selectedButton == "Default float Auto-Fire")
index = tastudio.FloatPatterns.Length + 1;
else
index = Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(selectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
List<float> p = new List<float>();
for (int i = 0; i < counts.Count; i++)
{
@ -213,7 +213,7 @@ namespace BizHawk.Client.EmuHawk
private void GetPattern()
{
int index = Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.IndexOf(selectedButton);
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
if (selectedButton == "Default bool Auto-Fire")
index = tastudio.BoolPatterns.Length + 1;
if (index != -1)
@ -242,7 +242,7 @@ namespace BizHawk.Client.EmuHawk
if (selectedButton == "Default float Auto-Fire")
index = tastudio.FloatPatterns.Length + 1;
else
index = Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(selectedButton);
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
float[] p = tastudio.FloatPatterns[index].Pattern;
float lastValue = p[0];
counts.Clear();

View File

@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk
private bool _wasRecording = false;
private Emulation.Common.ControllerDefinition controllerType
{ get { return Global.MovieSession.MovieControllerAdapter.Type; } }
{ get { return Global.MovieSession.MovieControllerAdapter.Definition; } }
public AutoPatternBool[] BoolPatterns;
public AutoPatternFloat[] FloatPatterns;
@ -297,8 +297,8 @@ namespace BizHawk.Client.EmuHawk
if (column.Type == InputRoll.RollColumn.InputType.Float)
{
// feos: this could be cashed, but I don't notice any slowdown this way either
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Type.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(columnName)];
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)];
if (text == range.Mid.ToString())
text = "";
}
@ -493,7 +493,7 @@ namespace BizHawk.Client.EmuHawk
{
bool wasPaused = Mainform.EmulatorPaused;
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName))
{
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);
@ -952,8 +952,8 @@ namespace BizHawk.Client.EmuHawk
return;
float value = _floatPaintState + increment;
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Type.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(_floatEditColumn)];
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)];
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed in ControllerDefinition.cs.
// SuuperW: I really don't think changing it would break anything, but adelikat isn't so sure.
float rMax = range.Max;
@ -1027,8 +1027,8 @@ namespace BizHawk.Client.EmuHawk
float prev = value;
string prevTyped = _floatTypedValue;
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Type.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(_floatEditColumn)];
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)];
float rMax = range.Max;
float rMin = range.Min;

View File

@ -424,10 +424,10 @@ namespace BizHawk.Client.EmuHawk
int digits = 1;
foreach (var kvp in columnNames)
{
if (Global.MovieSession.MovieControllerAdapter.Type.FloatControls.Contains(kvp.Key))
if (Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.Contains(kvp.Key))
{
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Type.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(kvp.Key)];
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(kvp.Key)];
type = InputRoll.RollColumn.InputType.Float;
digits = Math.Max(kvp.Value.Length, range.MaxDigits());
}

View File

@ -27,12 +27,12 @@ namespace BizHawk.Client.EmuHawk
var lg = Global.MovieSession.MovieControllerInstance();
lg.SetControllersAsMnemonic(inputLogEntry);
foreach (var button in lg.Type.BoolButtons)
foreach (var button in lg.Definition.BoolButtons)
{
Global.LuaAndAdaptor.SetButton(button, lg.IsPressed(button));
}
foreach (var floatButton in lg.Type.FloatControls)
foreach (var floatButton in lg.Definition.FloatControls)
{
Global.LuaAndAdaptor.SetFloat(floatButton, lg.GetFloat(floatButton));
}

View File

@ -20,7 +20,7 @@ namespace BizHawk.Client.MultiHawk
public void RewireInputChain()
{
Global.ControllerInputCoalescer.Clear();
Global.ControllerInputCoalescer.Type = Global.ActiveController.Type;
Global.ControllerInputCoalescer.Definition = Global.ActiveController.Definition;
// TODO?
//Global.UD_LR_ControllerAdapter.Source = Global.ActiveController.Or(Global.AutoFireController);
@ -42,7 +42,7 @@ namespace BizHawk.Client.MultiHawk
window.Emulator.Controller = Global.ControllerOutput;
}
Global.MovieSession.MovieControllerAdapter.Type = Global.MovieInputSourceAdapter.Type;
Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition;
// connect the movie session before MovieOutputHardpoint if it is doing anything
// otherwise connect the MovieInputSourceAdapter to it, effectively bypassing the movie session
@ -67,7 +67,7 @@ namespace BizHawk.Client.MultiHawk
// allow propogating controls that are in the current controller definition but not in the prebaked one
// these two lines shouldn't be required anymore under the new system?
Global.ActiveController.ForceType(new ControllerDefinition(def));
Global.ClickyVirtualPadController.Type = new ControllerDefinition(def);
Global.ClickyVirtualPadController.Definition = new ControllerDefinition(def);
RewireInputChain();
}

View File

@ -2,7 +2,7 @@
{
public class NullController : IController
{
public ControllerDefinition Type { get { return null; } }
public ControllerDefinition Definition { get { return null; } }
public bool this[string button] { get { return false; } }
public bool IsPressed(string button) { return false; }
public float GetFloat(string name) { return 0f; }

View File

@ -2,7 +2,10 @@
{
public interface IController
{
ControllerDefinition Type { get; }
/// <summary>
/// Defines the controller schema, including all currently available buttons and their types
/// </summary>
ControllerDefinition Definition { get; }
// TODO - it is obnoxious for this to be here. must be removed.
bool this[string button] { get; }

View File

@ -1156,7 +1156,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
this.remaps = remaps;
}
public ControllerDefinition Type { get { throw new NotImplementedException(); } }
public ControllerDefinition Definition { get { throw new NotImplementedException(); } }
public bool this[string button] { get { return IsPressed(button); } }

View File

@ -862,7 +862,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// <summary>
/// invalid until CopyFrom has been called
/// </summary>
public ControllerDefinition Type
public ControllerDefinition Definition
{
get { return def; }
}
@ -899,7 +899,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// <param name="source"></param>
public void CopyFrom(IController source)
{
this.def = source.Type;
this.def = source.Definition;
buttons.Clear();
foreach (var k in def.BoolButtons)
buttons.Add(k, source.IsPressed(k) ? 1.0f : 0);