From 25da1153b69a25ba9bac21ccf394a8f439640536 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 18 Jul 2021 12:57:09 +1000 Subject: [PATCH] Resolve TODO re: encapsulation of r/w InputManager props --- .../inputAdapters/InputManager.cs | 10 ++++++++-- src/BizHawk.Client.EmuHawk/MainForm.cs | 6 ++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Client.Common/inputAdapters/InputManager.cs b/src/BizHawk.Client.Common/inputAdapters/InputManager.cs index f93bef998e..96e91f53fb 100644 --- a/src/BizHawk.Client.Common/inputAdapters/InputManager.cs +++ b/src/BizHawk.Client.Common/inputAdapters/InputManager.cs @@ -14,10 +14,10 @@ namespace BizHawk.Client.Common public class InputManager { // the original source controller, bound to the user, sort of the "input" port for the chain, i think - public Controller ActiveController { get; set; } // TODO: private setter, add a method that takes both controllers in + public Controller ActiveController { get; private set; } // rapid fire version on the user controller, has its own key bindings and is OR'ed against ActiveController - public AutofireController AutoFireController { get; set; } // TODO: private setter, add a method that takes both controllers in + public AutofireController AutoFireController { get; private set; } // the "output" port for the controller chain. public CopyControllerAdapter ControllerOutput { get; } = new CopyControllerAdapter(); @@ -49,6 +49,12 @@ namespace BizHawk.Client.Common public Func<(Point Pos, long Scroll, bool LMB, bool MMB, bool RMB, bool X1MB, bool X2MB)> GetMainFormMouseInfo { get; set; } + public void ResetMainControllers(AutofireController nullAutofireController) + { + ActiveController = new(NullController.Instance.Definition); + AutoFireController = nullAutofireController; + } + public void SyncControls(IEmulator emulator, IMovieSession session, Config config) { var def = emulator.ControllerDefinition; diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 3c00b8ebe6..6bc291e74a 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -459,8 +459,7 @@ namespace BizHawk.Client.EmuHawk ); InitControls(); - InputManager.ActiveController = new Controller(NullController.Instance.Definition); - InputManager.AutoFireController = _autofireNullControls; + InputManager.ResetMainControllers(_autofireNullControls); InputManager.AutofireStickyXorAdapter.SetOnOffPatternFromConfig(Config.AutofireOn, Config.AutofireOff); try { @@ -4036,8 +4035,7 @@ namespace BizHawk.Client.EmuHawk CheatList.SaveOnClose(); Emulator.Dispose(); Emulator = new NullEmulator(); - InputManager.ActiveController = new Controller(NullController.Instance.Definition); - InputManager.AutoFireController = _autofireNullControls; + InputManager.ResetMainControllers(_autofireNullControls); RewireSound(); RebootStatusBarIcon.Visible = false; GameIsClosing = false;