diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-07-15 20:31:44 +0200 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-07-25 00:59:47 +0200 |
| commit | 4d27022d0ec2bc45b39f7c10fce77c02467e3448 (patch) | |
| tree | 20e63cd46201fa9ee3271a29c5bae5d5425430ed /Source | |
| parent | 8f0d702e5f9f72c543465f568a55874e19ad7b11 (diff) | |
Add hotkey for centering mouse in render window.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/HotkeyManager.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/Core/HotkeyManager.h | 1 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/HotkeyScheduler.cpp | 3 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 10 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.h | 6 |
5 files changed, 21 insertions, 0 deletions
diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 02c0191256..b7c5c161c2 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -35,6 +35,7 @@ constexpr std::array<const char*, NUM_HOTKEYS> s_hotkey_labels{{ _trans("Take Screenshot"), _trans("Exit"), _trans("Unlock Cursor"), + _trans("Center Mouse"), _trans("Activate NetPlay Chat"), _trans("Control NetPlay Golf Mode"), diff --git a/Source/Core/Core/HotkeyManager.h b/Source/Core/Core/HotkeyManager.h index b214c95a66..b58f9c2828 100644 --- a/Source/Core/Core/HotkeyManager.h +++ b/Source/Core/Core/HotkeyManager.h @@ -29,6 +29,7 @@ enum Hotkey HK_SCREENSHOT, HK_EXIT, HK_UNLOCK_CURSOR, + HK_CENTER_MOUSE, HK_ACTIVATE_CHAT, HK_REQUEST_GOLF_CONTROL, diff --git a/Source/Core/DolphinQt/HotkeyScheduler.cpp b/Source/Core/DolphinQt/HotkeyScheduler.cpp index 52fd1ac00a..6d7c91a6ee 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt/HotkeyScheduler.cpp @@ -233,6 +233,9 @@ void HotkeyScheduler::Run() if (IsHotkey(HK_UNLOCK_CURSOR)) emit UnlockCursor(); + if (IsHotkey(HK_CENTER_MOUSE, true)) + g_controller_interface.SetMouseCenteringRequested(true); + auto& settings = Settings::Instance(); // Toggle Chat diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 1c4dc71da8..442e5502fa 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -421,6 +421,16 @@ Common::Vec2 ControllerInterface::GetWindowInputScale() const return {1 / ar, 1.f}; } +void ControllerInterface::SetMouseCenteringRequested(bool center) +{ + m_requested_mouse_centering = center; +} + +bool ControllerInterface::IsMouseCenteringRequested() const +{ + return m_requested_mouse_centering.load(); +} + // Register a callback to be called when a device is added or removed (as from the input backends' // hotplug thread), or when devices are refreshed // Returns a handle for later removing the callback. diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index 2f43cacc42..3a0276de41 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -106,6 +106,11 @@ public: // Inputs based on window coordinates should be multiplied by this. Common::Vec2 GetWindowInputScale() const; + // Request that the mouse cursor should be centered in the render window at the next opportunity. + void SetMouseCenteringRequested(bool center); + + bool IsMouseCenteringRequested() const; + HotplugCallbackHandle RegisterDevicesChangedCallback(std::function<void(void)> callback); void UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle); void InvokeDevicesChangedCallbacks() const; @@ -127,6 +132,7 @@ private: std::atomic<int> m_populating_devices_counter; WindowSystemInfo m_wsi; std::atomic<float> m_aspect_ratio_adjustment = 1; + std::atomic<bool> m_requested_mouse_centering = false; }; namespace ciface |
