diff --git a/src/BizHawk.Client.EmuHawk/Input/Input.cs b/src/BizHawk.Client.EmuHawk/Input/Input.cs
index e4b84c48e9..a3685b1443 100644
--- a/src/BizHawk.Client.EmuHawk/Input/Input.cs
+++ b/src/BizHawk.Client.EmuHawk/Input/Input.cs
@@ -331,6 +331,11 @@ namespace BizHawk.Client.EmuHawk
}
+ ///
+ /// Controls whether MainForm generates input events. should be turned off for most modal dialogs
+ ///
+ public Func MainFormInputAllowedCallback;
+
private void UpdateThreadProc()
{
while (true)
@@ -390,12 +395,12 @@ namespace BizHawk.Client.EmuHawk
if (_newEvents.Count != 0)
{
//WHAT!? WE SHOULD NOT BE SO NAIVELY TOUCHING MAINFORM FROM THE INPUTTHREAD. ITS BUSY RUNNING.
- AllowInput allowInput = GlobalWin.MainForm.AllowInput(false);
+ AllowInput allowInput = MainFormInputAllowedCallback(false);
foreach (var ie in _newEvents)
{
//events are swallowed in some cases:
- if (ie.LogicalButton.Alt && ShouldSwallow(GlobalWin.MainForm.AllowInput(true), ie))
+ if (ie.LogicalButton.Alt && ShouldSwallow(MainFormInputAllowedCallback(true), ie))
continue;
if (ie.EventType == InputEventType.Press && ShouldSwallow(allowInput, ie))
continue;
@@ -461,7 +466,7 @@ namespace BizHawk.Client.EmuHawk
lock (this)
{
if (_inputEvents.Count == 0) return null;
- AllowInput allowInput = GlobalWin.MainForm.AllowInput(false);
+ AllowInput allowInput = MainFormInputAllowedCallback(false);
//wait for the first release after a press to complete input binding, because we need to distinguish pure modifierkeys from modified keys
//if you just pressed ctrl, wanting to bind ctrl, we'd see: pressed:ctrl, unpressed:ctrl
diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs
index f954bfb85f..4153f3023e 100644
--- a/src/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/src/BizHawk.Client.EmuHawk/MainForm.cs
@@ -372,6 +372,40 @@ namespace BizHawk.Client.EmuHawk
Sound?.StartSound();
};
+ Input.Instance.MainFormInputAllowedCallback = yieldAlt => {
+ // the main form gets input
+ if (ActiveForm == this)
+ {
+ return Input.AllowInput.All;
+ }
+
+ // even more special logic for TAStudio:
+ // TODO - implement by event filter in TAStudio
+ if (ActiveForm is TAStudio maybeTAStudio)
+ {
+ if (yieldAlt || maybeTAStudio.IsInMenuLoop)
+ {
+ return Input.AllowInput.None;
+ }
+ }
+
+ // modals that need to capture input for binding purposes get input, of course
+ if (ActiveForm is HotkeyConfig
+ || ActiveForm is ControllerConfig
+ || ActiveForm is TAStudio
+ || ActiveForm is VirtualpadTool)
+ {
+ return Input.AllowInput.All;
+ }
+
+ // if no form is active on this process, then the background input setting applies
+ if (ActiveForm == null && Config.AcceptBackgroundInput)
+ {
+ return Config.AcceptBackgroundInputControllerOnly ? Input.AllowInput.OnlyController : Input.AllowInput.All;
+ }
+
+ return Input.AllowInput.None;
+ };
Input.Instance.Adapter.FirstInitAll(Handle);
InitControls();
@@ -798,45 +832,6 @@ namespace BizHawk.Client.EmuHawk
AddOnScreenMessage("Core reboot needed for this setting");
}
- ///
- /// Controls whether the app generates input events. should be turned off for most modal dialogs
- ///
- public Input.AllowInput AllowInput(bool yieldAlt)
- {
- // the main form gets input
- if (ActiveForm == this)
- {
- return Input.AllowInput.All;
- }
-
- // even more special logic for TAStudio:
- // TODO - implement by event filter in TAStudio
- if (ActiveForm is TAStudio maybeTAStudio)
- {
- if (yieldAlt || maybeTAStudio.IsInMenuLoop)
- {
- return Input.AllowInput.None;
- }
- }
-
- // modals that need to capture input for binding purposes get input, of course
- if (ActiveForm is HotkeyConfig
- || ActiveForm is ControllerConfig
- || ActiveForm is TAStudio
- || ActiveForm is VirtualpadTool)
- {
- return Input.AllowInput.All;
- }
-
- // if no form is active on this process, then the background input setting applies
- if (ActiveForm == null && Config.AcceptBackgroundInput)
- {
- return Config.AcceptBackgroundInputControllerOnly ? Input.AllowInput.OnlyController : Input.AllowInput.All;
- }
-
- return Input.AllowInput.None;
- }
-
// TODO: make these actual properties
// This is a quick hack to reduce the dependency on Globals
public IEmulator Emulator