Resolve TODO re: encapsulation of r/w InputManager props

This commit is contained in:
YoshiRulz 2021-07-18 12:57:09 +10:00
parent 778098e8b7
commit 25da1153b6
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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;