TAS Input: Enable hotkeys and controller input when Input has focus

Enable emulator hotkeys and controller input (when that option is
enabled) when a TAS Input window has focus, as if it was the render
window instead.  This allows TASers to use frame advance and the like
without having to switch the focused window or disabling Hotkeys Require
Window Focus which also picks up keypresses while other apps are active.

Cursor updates are disabled when the TAS Input window has focus, as
otherwise the Wii IR widget (and anything else controlled by the mouse)
becomes unusable. The cursor continues to work normally when the render
window has focus.
This commit is contained in:
Dentomologist
2024-05-26 16:50:12 -07:00
parent 8ac22378a1
commit c3bdd05d2a
14 changed files with 92 additions and 7 deletions

View File

@ -391,9 +391,16 @@ Core::DeviceRemoval KeyboardMouse::UpdateInput()
m_state.axis.z += delta_z;
m_state.axis.z /= SCROLL_AXIS_DECAY;
const bool should_center_mouse =
g_controller_interface.IsMouseCenteringRequested() && Host_RendererHasFocus();
if (update_mouse || should_center_mouse)
const bool should_center_mouse = g_controller_interface.IsMouseCenteringRequested() &&
(Host_RendererHasFocus() || Host_TASInputHasFocus());
// When a TAS Input window has focus and "Enable Controller Input" is checked most types of
// input should be read normally as if the render window had focus instead. The cursor is an
// exception, as otherwise using the mouse to set any control in the TAS Input window will also
// update the Wii IR value (or any other input controlled by the cursor).
const bool should_update_mouse = update_mouse && !Host_TASInputHasFocus();
if (should_update_mouse || should_center_mouse)
UpdateCursor(should_center_mouse);
if (update_keyboard)