From b92f6480a0b7517666ad139fc81c89033f84830f Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Fri, 24 Jan 2020 00:06:39 -0600 Subject: InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio. --- .../ControllerInterface/Quartz/QuartzKeyboardAndMouse.h | 6 ++---- .../ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Quartz') 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 +#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 #include +#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 -- cgit v1.2.3