From 96fa84ff8b61b59f4ee0a361ac8a29270732a351 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 31 May 2020 12:05:58 -0500 Subject: [PATCH] remove globals from AutofireController --- src/BizHawk.Client.Common/AutofireController.cs | 6 +++--- .../inputAdapters/InputManager.cs | 11 ++++++++--- src/BizHawk.Client.EmuHawk/MainForm.cs | 6 +++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/BizHawk.Client.Common/AutofireController.cs b/src/BizHawk.Client.Common/AutofireController.cs index 60865ad75f..c0aa363792 100644 --- a/src/BizHawk.Client.Common/AutofireController.cs +++ b/src/BizHawk.Client.Common/AutofireController.cs @@ -9,10 +9,10 @@ namespace BizHawk.Client.Common { public class AutofireController : IController { - public AutofireController(ControllerDefinition definition, IEmulator emulator) + public AutofireController(ControllerDefinition definition, IEmulator emulator, int on, int off) { - On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn; - Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff; + On = on < 1 ? 0 : on; + Off = off < 1 ? 0 : off; Definition = definition; _emulator = emulator; } diff --git a/src/BizHawk.Client.Common/inputAdapters/InputManager.cs b/src/BizHawk.Client.Common/inputAdapters/InputManager.cs index 77c812a47e..2cee3d9a1d 100644 --- a/src/BizHawk.Client.Common/inputAdapters/InputManager.cs +++ b/src/BizHawk.Client.Common/inputAdapters/InputManager.cs @@ -84,7 +84,7 @@ namespace BizHawk.Client.Common var def = emulator.ControllerDefinition; ActiveController = BindToDefinition(def, config.AllTrollers, config.AllTrollersAnalog); - AutoFireController = BindToDefinitionAF(def, emulator, config.AllTrollersAutoFire); + AutoFireController = BindToDefinitionAF(def, emulator, config.AllTrollersAutoFire, config.AutofireOn, config.AutofireOff); // allow propagating 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? @@ -121,9 +121,14 @@ namespace BizHawk.Client.Common return ret; } - private static AutofireController BindToDefinitionAF(ControllerDefinition def, IEmulator emulator, IDictionary> allBinds) + private static AutofireController BindToDefinitionAF( + ControllerDefinition def, + IEmulator emulator, + IDictionary> allBinds, + int on, + int off) { - var ret = new AutofireController(def, emulator); + var ret = new AutofireController(def, emulator, on, off); if (allBinds.TryGetValue(def.Name, out var binds)) { foreach (var btn in def.BoolButtons) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index a5d10be889..106bd92715 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -1947,7 +1947,11 @@ namespace BizHawk.Client.EmuHawk } Global.InputManager.ClientControls = controls; - _autofireNullControls = new AutofireController(NullController.Instance.Definition, Emulator); + _autofireNullControls = new AutofireController( + NullController.Instance.Definition, + Emulator, + Config.AutofireOn, + Config.AutofireOff); } private void LoadMoviesFromRecent(string path)