From 8b6204bbfaa8cf2eb049c8b50b24049920eb718e Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Wed, 16 Sep 2026 12:21:57 +0100 Subject: [PATCH] mouse_tracker.cpp: Deduplicate code for mouse and touch input --- src/citra_libretro/input/mouse_tracker.cpp | 26 ++-------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/citra_libretro/input/mouse_tracker.cpp b/src/citra_libretro/input/mouse_tracker.cpp index 230ddd050..6140ebf1b 100644 --- a/src/citra_libretro/input/mouse_tracker.cpp +++ b/src/citra_libretro/input/mouse_tracker.cpp @@ -103,36 +103,14 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight, bool wasMoved = false; if (LibRetro::settings.enable_mouse_touchscreen) { - // Check mouse input state |= LibRetro::CheckInput(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); - - // Read in and convert pointer values to absolute values on the canvas - auto pointerX = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); - auto pointerY = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); - auto newX = static_cast((pointerX + 0x7fff) / (float)(0x7fff * 2) * bufferWidth); - auto newY = static_cast((pointerY + 0x7fff) / (float)(0x7fff * 2) * bufferHeight); - - // Use mouse pointer movement - if ((pointerX != 0 || pointerY != 0) && (newX != lastMouseX || newY != lastMouseY)) { - lastMouseX = newX; - lastMouseY = newY; - - // Use layout system to validate and map coordinates - if (layout.IsWithinTouchscreen(newX, newY)) { - x = std::clamp(newX, static_cast(layout.bottom_screen.left), - static_cast(layout.bottom_screen.right)) - - layout.bottom_screen.left; - y = std::clamp(newY, static_cast(layout.bottom_screen.top), - static_cast(layout.bottom_screen.bottom)) - - layout.bottom_screen.top; - } - } } if (LibRetro::settings.enable_touch_touchscreen) { - // Check touchscreen input state |= LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); + } + if (state == true) { // Read in and convert pointer values to absolute values on the canvas auto pointerX = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); auto pointerY = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);