Add hotkey for centering mouse in render window.
This commit is contained in:
parent
8f0d702e5f
commit
4d27022d0e
|
@ -35,6 +35,7 @@ constexpr std::array<const char*, NUM_HOTKEYS> s_hotkey_labels{{
|
||||||
_trans("Take Screenshot"),
|
_trans("Take Screenshot"),
|
||||||
_trans("Exit"),
|
_trans("Exit"),
|
||||||
_trans("Unlock Cursor"),
|
_trans("Unlock Cursor"),
|
||||||
|
_trans("Center Mouse"),
|
||||||
_trans("Activate NetPlay Chat"),
|
_trans("Activate NetPlay Chat"),
|
||||||
_trans("Control NetPlay Golf Mode"),
|
_trans("Control NetPlay Golf Mode"),
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ enum Hotkey
|
||||||
HK_SCREENSHOT,
|
HK_SCREENSHOT,
|
||||||
HK_EXIT,
|
HK_EXIT,
|
||||||
HK_UNLOCK_CURSOR,
|
HK_UNLOCK_CURSOR,
|
||||||
|
HK_CENTER_MOUSE,
|
||||||
HK_ACTIVATE_CHAT,
|
HK_ACTIVATE_CHAT,
|
||||||
HK_REQUEST_GOLF_CONTROL,
|
HK_REQUEST_GOLF_CONTROL,
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,9 @@ void HotkeyScheduler::Run()
|
||||||
if (IsHotkey(HK_UNLOCK_CURSOR))
|
if (IsHotkey(HK_UNLOCK_CURSOR))
|
||||||
emit UnlockCursor();
|
emit UnlockCursor();
|
||||||
|
|
||||||
|
if (IsHotkey(HK_CENTER_MOUSE, true))
|
||||||
|
g_controller_interface.SetMouseCenteringRequested(true);
|
||||||
|
|
||||||
auto& settings = Settings::Instance();
|
auto& settings = Settings::Instance();
|
||||||
|
|
||||||
// Toggle Chat
|
// Toggle Chat
|
||||||
|
|
|
@ -421,6 +421,16 @@ Common::Vec2 ControllerInterface::GetWindowInputScale() const
|
||||||
return {1 / ar, 1.f};
|
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'
|
// 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
|
// hotplug thread), or when devices are refreshed
|
||||||
// Returns a handle for later removing the callback.
|
// Returns a handle for later removing the callback.
|
||||||
|
|
|
@ -106,6 +106,11 @@ public:
|
||||||
// Inputs based on window coordinates should be multiplied by this.
|
// Inputs based on window coordinates should be multiplied by this.
|
||||||
Common::Vec2 GetWindowInputScale() const;
|
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);
|
HotplugCallbackHandle RegisterDevicesChangedCallback(std::function<void(void)> callback);
|
||||||
void UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle);
|
void UnregisterDevicesChangedCallback(const HotplugCallbackHandle& handle);
|
||||||
void InvokeDevicesChangedCallbacks() const;
|
void InvokeDevicesChangedCallbacks() const;
|
||||||
|
@ -127,6 +132,7 @@ private:
|
||||||
std::atomic<int> m_populating_devices_counter;
|
std::atomic<int> m_populating_devices_counter;
|
||||||
WindowSystemInfo m_wsi;
|
WindowSystemInfo m_wsi;
|
||||||
std::atomic<float> m_aspect_ratio_adjustment = 1;
|
std::atomic<float> m_aspect_ratio_adjustment = 1;
|
||||||
|
std::atomic<bool> m_requested_mouse_centering = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ciface
|
namespace ciface
|
||||||
|
|
Loading…
Reference in New Issue