From 72bd34895d78b92bee7c9437c0564937c20500f6 Mon Sep 17 00:00:00 2001 From: MULTidll Date: Sat, 29 Nov 2025 16:05:31 +0530 Subject: [PATCH] Refactor touch input handling to use slot index as ID for stability and simplify touch clearing logic --- src/platforms/rcore_drm.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index c19506a6f..7c83da51f 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -2386,7 +2386,7 @@ static void PollMouseEvents(void) // If it was already active, it means we missed a lift event or the ID changed // We should treat it as a new touch platform.touchActive[platform.touchSlot] = true; - platform.touchId[platform.touchSlot] = event.value; + platform.touchId[platform.touchSlot] = platform.touchSlot; // Use slot index as ID for stability // Force DOWN action, even if we previously detected a MOVE or UP in this frame // A new touch is a significant state change that should take priority @@ -2435,21 +2435,12 @@ static void PollMouseEvents(void) { platform.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 0; - // Clear all touches if global pressure is 0 (safety net) - for (int i = 0; i < MAX_TOUCH_POINTS; i++) - { - platform.touchActive[i] = false; - platform.touchPosition[i].x = -1; - platform.touchPosition[i].y = -1; - platform.touchId[i] = -1; - } if (touchAction != 1) touchAction = 0; // TOUCH_ACTION_UP } if (event.value && !previousMouseLeftButtonState) { platform.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 1; - platform.touchActive[0] = true; touchAction = 1; // TOUCH_ACTION_DOWN } } @@ -2466,22 +2457,13 @@ static void PollMouseEvents(void) if (event.value > 0) { - platform.touchActive[0] = true; + // platform.touchActive[0] = true; touchAction = 1; // TOUCH_ACTION_DOWN } else { - if (event.code == BTN_TOUCH) - { - for (int i = 0; i < MAX_TOUCH_POINTS; i++) - { - platform.touchActive[i] = false; - platform.touchPosition[i].x = -1; - platform.touchPosition[i].y = -1; - platform.touchId[i] = -1; - } - } - else + // Only clear touch 0 for actual mouse clicks (BTN_LEFT) + if (event.code == BTN_LEFT) { platform.touchActive[0] = false; platform.touchPosition[0].x = -1;