From 8659de4d713ead782bf4a81a2ab94688b30b9c46 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sat, 31 Dec 2022 23:34:09 -0600 Subject: [PATCH] InputCommon:QuartzKB&M: Fix mouse y coordinates Cocoa uses a different coordinate system from Carbon (Carbon's origin is the top left while Cocoa's is the bottom left) --- .../ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index a610956d93..5ea4ff2624 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -259,16 +259,14 @@ void KeyboardAndMouse::UpdateInput() } else { - CGEventRef event = CGEventCreate(nil); - CGPoint loc = CGEventGetLocation(event); - CFRelease(event); + NSPoint loc = [NSEvent mouseLocation]; const auto window_scale = g_controller_interface.GetWindowInputScale(); loc.x -= bounds.origin.x; loc.y -= bounds.origin.y; m_cursor.x = (loc.x / window_width * 2 - 1.0) * window_scale.x; - m_cursor.y = (loc.y / window_height * 2 - 1.0) * window_scale.y; + m_cursor.y = (loc.y / window_height * 2 - 1.0) * -window_scale.y; } }