From 6f3bc27c59d58b53e19a146e2d880ca8f183883c Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Wed, 10 Aug 2011 00:34:33 +0000 Subject: [PATCH] Autofire is smarter now and keeps track of when a button was pressed and then uses that for the basis of the autofire pattern --- .../Input/ControllerBinding.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index 6f8c44faf3..2c2c0a3a51 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -95,17 +95,20 @@ namespace BizHawk.MultiClient private ControllerDefinition type; private WorkingDictionary> bindings = new WorkingDictionary>(); private WorkingDictionary buttons = new WorkingDictionary(); + private WorkingDictionary buttonStarts = new WorkingDictionary(); private bool autofire = true; public bool Autofire { get { return false; } set { autofire = value; } } public int On { get; set; } public int Off { get; set; } + //public int StartFrame { get; set; } public AutofireController(ControllerDefinition definition) { On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn; Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff; + //StartFrame = 0; type = definition; } @@ -115,7 +118,7 @@ namespace BizHawk.MultiClient { if (autofire) { - int a = Global.Emulator.Frame % (On + Off); + int a = (Global.Emulator.Frame - buttonStarts[button]) % (On + Off); if (a < On) return buttons[button]; else @@ -144,26 +147,32 @@ namespace BizHawk.MultiClient return ret; } - int frameStarted = 0; - /// /// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding). /// this will clobber any existing data (use OR_* or other functions to layer in additional input sources) /// public void LatchFromPhysical(IController controller) { + foreach (var kvp in bindings) + { + foreach (var bound_button in kvp.Value) + { + if (buttons[kvp.Key] == false && controller[bound_button] == true) + buttonStarts[kvp.Key] = Global.Emulator.Frame; + } + } + buttons.Clear(); foreach (var kvp in bindings) { buttons[kvp.Key] = false; foreach (var bound_button in kvp.Value) { - if (buttons[kvp.Key] == false && controller[bound_button] == true) - frameStarted = Global.Emulator.Frame; - else - frameStarted = 0; + if (controller[bound_button]) + { buttons[kvp.Key] = true; + } } } }