diff options
| author | Dentomologist <dentomologist@gmail.com> | 2024-05-26 16:50:12 -0700 |
|---|---|---|
| committer | Dentomologist <dentomologist@gmail.com> | 2024-05-31 15:14:44 -0700 |
| commit | c3bdd05d2a7d5c0a5b513481ab929cef66e5249b (patch) | |
| tree | 13adbe2c4226ca23fc6b80553edced0048d089df /Source/Core/InputCommon/ControllerInterface | |
| parent | 8ac22378a18217859f518ca6a07119ecea8c9cb7 (diff) | |
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.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
3 files changed, 29 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp index 3c6a82dcd8..8d7f7c7ada 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp @@ -179,7 +179,8 @@ void KeyboardMouse::UpdateCursorInput() const auto win_height = std::max(rect.bottom - rect.top, 1l); POINT point = {}; - if (g_controller_interface.IsMouseCenteringRequested() && Host_RendererHasFocus()) + if (g_controller_interface.IsMouseCenteringRequested() && + (Host_RendererHasFocus() || Host_TASInputHasFocus())) { point.x = win_width / 2; point.y = win_height / 2; @@ -189,6 +190,15 @@ void KeyboardMouse::UpdateCursorInput() SetCursorPos(screen_point.x, screen_point.y); g_controller_interface.SetMouseCenteringRequested(false); } + else if (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). + + return; + } else { GetCursorPos(&point); diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index 55f212900d..9a8ddfc6df 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -244,7 +244,8 @@ Core::DeviceRemoval KeyboardAndMouse::UpdateInput() const double window_width = std::max(bounds.size.width, 1.0); const double window_height = std::max(bounds.size.height, 1.0); - if (g_controller_interface.IsMouseCenteringRequested() && Host_RendererHasFocus()) + if (g_controller_interface.IsMouseCenteringRequested() && + (Host_RendererHasFocus() || Host_TASInputHasFocus())) { m_cursor.x = 0; m_cursor.y = 0; @@ -258,8 +259,13 @@ Core::DeviceRemoval KeyboardAndMouse::UpdateInput() g_controller_interface.SetMouseCenteringRequested(false); } - else + else if (!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). + NSPoint loc = [NSEvent mouseLocation]; const auto window_scale = g_controller_interface.GetWindowInputScale(); diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index e4b717e3af..057d774c5b 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -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) |
