diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs index 52613cae5e..565dbe0233 100644 --- a/BizHawk.MultiClient/Global.cs +++ b/BizHawk.MultiClient/Global.cs @@ -51,6 +51,9 @@ namespace BizHawk.MultiClient /// public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter(); + /// + /// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons + /// public static ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController(); public static Controller ClientControls; diff --git a/BizHawk.MultiClient/HawkFile.cs b/BizHawk.MultiClient/HawkFile.cs index 59412df483..fae1b6c15a 100644 --- a/BizHawk.MultiClient/HawkFile.cs +++ b/BizHawk.MultiClient/HawkFile.cs @@ -219,7 +219,7 @@ namespace BizHawk.MultiClient extractor.ExtractFile(archiveIndex, boundStream); boundStream.Position = 0; memberPath = FixArchiveFilename(extractor.ArchiveFileNames[archiveIndex]); //TODO - maybe go through our own list of names? maybe not, its indexes dont match.. - Console.WriteLine("bound " + CanonicalFullPath); + Console.WriteLine("HawkFile bound " + CanonicalFullPath); return this; } @@ -240,7 +240,7 @@ namespace BizHawk.MultiClient void BindRoot() { boundStream = rootStream; - Console.WriteLine("bound " + CanonicalFullPath); + Console.WriteLine("HawkFile bound " + CanonicalFullPath); } /// diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index 09757039f2..22f3fa75e2 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -7,12 +7,19 @@ namespace BizHawk.MultiClient public class Controller : IController { private ControllerDefinition type; - private Dictionary> bindings = new Dictionary>(); - private WorkingDictionary stickyButtons = new WorkingDictionary(); - private List unpressedButtons = new List(); - private List forcePressedButtons = new List(); - private List removeFromForcePressedButtons = new List(); - private List programmaticallyPressedButtons = new List(); + private WorkingDictionary> bindings = new WorkingDictionary>(); + private WorkingDictionary buttons = new WorkingDictionary(); + + public Controller(ControllerDefinition definition) + { + type = definition; + } + + public ControllerDefinition Type { get { return type; } } + public bool this[string button] { get { return IsPressed(button); } } + public bool IsPressed(string button) { return buttons[button]; } + public float GetFloat(string name) { throw new NotImplementedException(); } + public void UpdateControls(int frame) { } //look for bindings which are activated by the supplied physical button. public List SearchBindings(string button) @@ -36,11 +43,11 @@ namespace BizHawk.MultiClient { foreach (var kvp in bindings) { - stickyButtons[kvp.Key] = false; + buttons[kvp.Key] = false; foreach (var bound_button in kvp.Value) { if(controller[bound_button]) - stickyButtons[kvp.Key] = true; + buttons[kvp.Key] = true; } } } @@ -54,23 +61,10 @@ namespace BizHawk.MultiClient foreach (string button in type.BoolButtons) { if (controller.IsPressed(button)) - stickyButtons[button] = true; + buttons[button] = true; } } - public Controller(ControllerDefinition definition) - { - type = definition; - - foreach (var b in type.BoolButtons) - { - bindings[b] = new List(); - } - - foreach (var f in type.FloatControls) - bindings[f] = new List(); - } - public void BindButton(string button, string control) { bindings[button].Add(control); @@ -85,50 +79,5 @@ namespace BizHawk.MultiClient bindings[button].Add(control.Trim()); } - public ControllerDefinition Type - { - get { return type; } - } - - public bool this[string button] - { - get { return IsPressed(button); } - } - - public bool IsPressed(string button) - { - return stickyButtons[button]; - } - - public float GetFloat(string name) - { - throw new NotImplementedException(); - } - - public void UnpressButton(string name) - { - unpressedButtons.Add(name); - } - - public void UpdateControls(int frame) - { - } - - public void SetSticky(string button, bool sticky) - { - stickyButtons[button] = sticky; - } - - public bool IsSticky(string button) - { - return stickyButtons[button]; - } - - public void ForceButton(string button) - { - forcePressedButtons.Add(button); - } - - } } \ No newline at end of file diff --git a/BizHawk.MultiClient/Input/Input.cs b/BizHawk.MultiClient/Input/Input.cs index 6ffd63e0f0..2ee1846484 100644 --- a/BizHawk.MultiClient/Input/Input.cs +++ b/BizHawk.MultiClient/Input/Input.cs @@ -98,6 +98,10 @@ namespace BizHawk.MultiClient var other = (LogicalButton)obj; return other == this; } + public override int GetHashCode() + { + return Button.GetHashCode() ^ Modifiers.GetHashCode(); + } public static bool operator==(LogicalButton lhs, LogicalButton rhs) { return lhs.Button == rhs.Button && lhs.Modifiers == rhs.Modifiers; diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index ef4282f1e6..d60aa4fd3d 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -2121,8 +2121,9 @@ namespace BizHawk.MultiClient private void SoftReset() { + //is it enough to run this for one frame? maybe.. if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset")) - Global.ActiveController.ForceButton("Reset"); + Global.ClickyVirtualPadController.Click("Reset"); } public void UpdateStatusSlots()