diff options
| author | Tilka <tilkax@gmail.com> | 2020-01-25 20:28:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-25 20:28:01 +0000 |
| commit | b0e040431a633ea3b0486673592e0de753110823 (patch) | |
| tree | 5b2e36a8cc6259de49d28461a00778960f254faa /Source/Core/InputCommon/ControllerInterface/Quartz | |
| parent | 9827aa7a37e444cb359d4db50f5d73cb58eda77c (diff) | |
| parent | b92f6480a0b7517666ad139fc81c89033f84830f (diff) | |
Merge pull request #8581 from jordan-woyak/ciface-ar-aware
InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Quartz')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h | 6 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h index 902621cddc..5d3ea86f3e 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.h @@ -6,6 +6,7 @@ #include <QuartzCore/QuartzCore.h> +#include "Common/Matrix.h" #include "InputCommon/ControllerInterface/Device.h" namespace ciface::Quartz @@ -64,10 +65,7 @@ public: std::string GetSource() const override; private: - struct - { - float x, y; - } m_cursor; + Common::Vec2 m_cursor; uint32_t m_windowid; }; diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index 6cbc0a3f11..7c4673acd7 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -9,6 +9,8 @@ #include <Carbon/Carbon.h> #include <Cocoa/Cocoa.h> +#include "InputCommon/ControllerInterface/ControllerInterface.h" + namespace ciface::Quartz { std::string KeycodeToName(const CGKeyCode keycode) @@ -177,10 +179,12 @@ void KeyboardAndMouse::UpdateInput() CGPoint loc = CGEventGetLocation(event); CFRelease(event); + const auto window_scale = g_controller_interface.GetWindowInputScale(); + loc.x -= bounds.origin.x; loc.y -= bounds.origin.y; - m_cursor.x = loc.x / bounds.size.width * 2 - 1.0; - m_cursor.y = loc.y / bounds.size.height * 2 - 1.0; + m_cursor.x = (loc.x / bounds.size.width * 2 - 1.0) * window_scale.x; + m_cursor.y = (loc.y / bounds.size.height * 2 - 1.0) * window_scale.y; } std::string KeyboardAndMouse::GetName() const |
