mainform - use InputManager property instead of GlobalWin reference

This commit is contained in:
adelikat 2020-07-03 10:31:41 -05:00
parent 42ceba7d21
commit a3c586b480
1 changed files with 26 additions and 26 deletions

View File

@ -281,7 +281,7 @@ namespace BizHawk.Client.EmuHawk
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt")); Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb")); BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb"));
GlobalWin.InputManager.ControllerInputCoalescer = new ControllerInputCoalescer(); InputManager.ControllerInputCoalescer = new ControllerInputCoalescer();
GlobalWin.FirmwareManager = new FirmwareManager(); GlobalWin.FirmwareManager = new FirmwareManager();
MovieSession = new MovieSession( MovieSession = new MovieSession(
Config.Movies, Config.Movies,
@ -418,9 +418,9 @@ namespace BizHawk.Client.EmuHawk
Input.Instance.Adapter.FirstInitAll(Handle); Input.Instance.Adapter.FirstInitAll(Handle);
InitControls(); InitControls();
GlobalWin.InputManager.ActiveController = new Controller(NullController.Instance.Definition); InputManager.ActiveController = new Controller(NullController.Instance.Definition);
GlobalWin.InputManager.AutoFireController = _autofireNullControls; InputManager.AutoFireController = _autofireNullControls;
GlobalWin.InputManager.AutofireStickyXorAdapter.SetOnOffPatternFromConfig(Config.AutofireOn, Config.AutofireOff); InputManager.AutofireStickyXorAdapter.SetOnOffPatternFromConfig(Config.AutofireOn, Config.AutofireOff);
try try
{ {
GlobalWin.Sound = new Sound(Handle); GlobalWin.Sound = new Sound(Handle);
@ -659,26 +659,26 @@ namespace BizHawk.Client.EmuHawk
ProcessInput(); ProcessInput();
InputManager.ClientControls.LatchFromPhysical(_hotkeyCoalescer); InputManager.ClientControls.LatchFromPhysical(_hotkeyCoalescer);
GlobalWin.InputManager.ActiveController.LatchFromPhysical(GlobalWin.InputManager.ControllerInputCoalescer); InputManager.ActiveController.LatchFromPhysical(InputManager.ControllerInputCoalescer);
GlobalWin.InputManager.ActiveController.ApplyAxisConstraints( InputManager.ActiveController.ApplyAxisConstraints(
(Emulator is N64 && Config.N64UseCircularAnalogConstraint) ? "Natural Circle" : null); (Emulator is N64 && Config.N64UseCircularAnalogConstraint) ? "Natural Circle" : null);
GlobalWin.InputManager.ActiveController.OR_FromLogical(InputManager.ClickyVirtualPadController); InputManager.ActiveController.OR_FromLogical(InputManager.ClickyVirtualPadController);
InputManager.AutoFireController.LatchFromPhysical(GlobalWin.InputManager.ControllerInputCoalescer); InputManager.AutoFireController.LatchFromPhysical(InputManager.ControllerInputCoalescer);
if (InputManager.ClientControls["Autohold"]) if (InputManager.ClientControls["Autohold"])
{ {
GlobalWin.InputManager.StickyXorAdapter.MassToggleStickyState(GlobalWin.InputManager.ActiveController.PressedButtons); InputManager.StickyXorAdapter.MassToggleStickyState(InputManager.ActiveController.PressedButtons);
GlobalWin.InputManager.AutofireStickyXorAdapter.MassToggleStickyState(InputManager.AutoFireController.PressedButtons); InputManager.AutofireStickyXorAdapter.MassToggleStickyState(InputManager.AutoFireController.PressedButtons);
} }
else if (InputManager.ClientControls["Autofire"]) else if (InputManager.ClientControls["Autofire"])
{ {
GlobalWin.InputManager.AutofireStickyXorAdapter.MassToggleStickyState(GlobalWin.InputManager.ActiveController.PressedButtons); InputManager.AutofireStickyXorAdapter.MassToggleStickyState(InputManager.ActiveController.PressedButtons);
} }
// autohold/autofire must not be affected by the following inputs // autohold/autofire must not be affected by the following inputs
GlobalWin.InputManager.ActiveController.Overrides(GlobalWin.InputManager.ButtonOverrideAdapter); InputManager.ActiveController.Overrides(InputManager.ButtonOverrideAdapter);
if (Tools.Has<LuaConsole>()) if (Tools.Has<LuaConsole>())
{ {
@ -814,8 +814,8 @@ namespace BizHawk.Client.EmuHawk
public void ClearHolds() public void ClearHolds()
{ {
GlobalWin.InputManager.StickyXorAdapter.ClearStickies(); InputManager.StickyXorAdapter.ClearStickies();
GlobalWin.InputManager.AutofireStickyXorAdapter.ClearStickies(); InputManager.AutofireStickyXorAdapter.ClearStickies();
if (Tools.Has<VirtualpadTool>()) if (Tools.Has<VirtualpadTool>())
{ {
@ -896,7 +896,7 @@ namespace BizHawk.Client.EmuHawk
private void ProcessInput() private void ProcessInput()
{ {
var conInput = (ControllerInputCoalescer)GlobalWin.InputManager.ControllerInputCoalescer; var conInput = (ControllerInputCoalescer)InputManager.ControllerInputCoalescer;
for (; ; ) for (; ; )
{ {
@ -962,7 +962,7 @@ namespace BizHawk.Client.EmuHawk
break; break;
case 1: // Input overrides Hotkeys case 1: // Input overrides Hotkeys
conInput.Receive(ie); conInput.Receive(ie);
if (!GlobalWin.InputManager.ActiveController.HasBinding(ie.LogicalButton.ToString())) if (!InputManager.ActiveController.HasBinding(ie.LogicalButton.ToString()))
{ {
handled = false; handled = false;
if (ie.EventType == Input.InputEventType.Press) if (ie.EventType == Input.InputEventType.Press)
@ -1201,7 +1201,7 @@ namespace BizHawk.Client.EmuHawk
// prohibit this operation if the current controls include LMouse // prohibit this operation if the current controls include LMouse
if (allowSuppress) if (allowSuppress)
{ {
if (GlobalWin.InputManager.ActiveController.HasBinding("WMouse L")) if (InputManager.ActiveController.HasBinding("WMouse L"))
{ {
return; return;
} }
@ -1959,7 +1959,7 @@ namespace BizHawk.Client.EmuHawk
controls.BindMulti(b.DisplayName, b.Bindings); controls.BindMulti(b.DisplayName, b.Bindings);
} }
GlobalWin.InputManager.ClientControls = controls; InputManager.ClientControls = controls;
_autofireNullControls = new AutofireController( _autofireNullControls = new AutofireController(
Emulator, Emulator,
Config.AutofireOn, Config.AutofireOn,
@ -2838,7 +2838,7 @@ namespace BizHawk.Client.EmuHawk
// zero 03-may-2014 - moved this before call to UpdateToolsBefore(), since it seems to clear the state which a lua event.framestart is going to want to alter // zero 03-may-2014 - moved this before call to UpdateToolsBefore(), since it seems to clear the state which a lua event.framestart is going to want to alter
InputManager.ClickyVirtualPadController.FrameTick(); InputManager.ClickyVirtualPadController.FrameTick();
GlobalWin.InputManager.ButtonOverrideAdapter.FrameTick(); InputManager.ButtonOverrideAdapter.FrameTick();
if (IsTurboing) if (IsTurboing)
{ {
@ -2896,7 +2896,7 @@ namespace BizHawk.Client.EmuHawk
} }
bool render = !InvisibleEmulation && (!_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false)); bool render = !InvisibleEmulation && (!_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false));
bool newFrame = Emulator.FrameAdvance(GlobalWin.InputManager.ControllerOutput, render, renderSound); bool newFrame = Emulator.FrameAdvance(InputManager.ControllerOutput, render, renderSound);
MovieSession.HandleFrameAfter(); MovieSession.HandleFrameAfter();
@ -2917,7 +2917,7 @@ namespace BizHawk.Client.EmuHawk
InputManager.AutoFireController.IncrementStarts(); InputManager.AutoFireController.IncrementStarts();
} }
GlobalWin.InputManager.AutofireStickyXorAdapter.IncrementLoops(Emulator.CanPollInput() && Emulator.AsInputPollable().IsLagFrame); InputManager.AutofireStickyXorAdapter.IncrementLoops(Emulator.CanPollInput() && Emulator.AsInputPollable().IsLagFrame);
PressFrameAdvance = false; PressFrameAdvance = false;
@ -3700,9 +3700,9 @@ namespace BizHawk.Client.EmuHawk
DisplayManager.Blank(); DisplayManager.Blank();
CreateRewinder(); CreateRewinder();
GlobalWin.InputManager.StickyXorAdapter.ClearStickies(); InputManager.StickyXorAdapter.ClearStickies();
GlobalWin.InputManager.StickyXorAdapter.ClearStickyAxes(); InputManager.StickyXorAdapter.ClearStickyAxes();
GlobalWin.InputManager.AutofireStickyXorAdapter.ClearStickies(); InputManager.AutofireStickyXorAdapter.ClearStickies();
RewireSound(); RewireSound();
Tools.UpdateCheatRelatedTools(null, null); Tools.UpdateCheatRelatedTools(null, null);
@ -3825,8 +3825,8 @@ namespace BizHawk.Client.EmuHawk
Emulator.Dispose(); Emulator.Dispose();
Emulator = new NullEmulator(); Emulator = new NullEmulator();
ClientApi.UpdateEmulatorAndVP(Emulator); ClientApi.UpdateEmulatorAndVP(Emulator);
GlobalWin.InputManager.ActiveController = new Controller(NullController.Instance.Definition); InputManager.ActiveController = new Controller(NullController.Instance.Definition);
GlobalWin.InputManager.AutoFireController = _autofireNullControls; InputManager.AutoFireController = _autofireNullControls;
RewireSound(); RewireSound();
RebootStatusBarIcon.Visible = false; RebootStatusBarIcon.Visible = false;
GameIsClosing = false; GameIsClosing = false;