Browse Source

Optimize gesture handling for PLATFORM_DRM (#3616)

ubkp 1 year ago
parent
commit
44eeda2475
1 changed files with 2 additions and 10 deletions
  1. 2 10
      src/platforms/rcore_drm.c

+ 2 - 10
src/platforms/rcore_drm.c

@@ -612,7 +612,6 @@ void PollInputEvents(void)
         struct input_event event = { 0 };
         struct input_event event = { 0 };
 
 
         int touchAction = -1;           // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
         int touchAction = -1;           // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
-        bool gestureUpdate = false;     // Flag to note gestures require to update
 
 
         // Try to read data from the mouse/touch/gesture and only continue if successful
         // Try to read data from the mouse/touch/gesture and only continue if successful
         while (read(fd, &event, sizeof(event)) == (int)sizeof(event))
         while (read(fd, &event, sizeof(event)) == (int)sizeof(event))
@@ -631,7 +630,6 @@ void PollInputEvents(void)
                     CORE.Input.Touch.position[0].x = CORE.Input.Mouse.currentPosition.x;
                     CORE.Input.Touch.position[0].x = CORE.Input.Mouse.currentPosition.x;
 
 
                     touchAction = 2;    // TOUCH_ACTION_MOVE
                     touchAction = 2;    // TOUCH_ACTION_MOVE
-                    gestureUpdate = true;
                 }
                 }
 
 
                 if (event.code == REL_Y)
                 if (event.code == REL_Y)
@@ -645,7 +643,6 @@ void PollInputEvents(void)
                     CORE.Input.Touch.position[0].y = CORE.Input.Mouse.currentPosition.y;
                     CORE.Input.Touch.position[0].y = CORE.Input.Mouse.currentPosition.y;
 
 
                     touchAction = 2;    // TOUCH_ACTION_MOVE
                     touchAction = 2;    // TOUCH_ACTION_MOVE
-                    gestureUpdate = true;
                 }
                 }
 
 
                 if (event.code == REL_WHEEL) platform.eventWheelMove.y += event.value;
                 if (event.code == REL_WHEEL) platform.eventWheelMove.y += event.value;
@@ -661,7 +658,6 @@ void PollInputEvents(void)
                     CORE.Input.Touch.position[0].x = (event.value - platform.absRange.x)*CORE.Window.screen.width/platform.absRange.width;        // Scale according to absRange
                     CORE.Input.Touch.position[0].x = (event.value - platform.absRange.x)*CORE.Window.screen.width/platform.absRange.width;        // Scale according to absRange
 
 
                     touchAction = 2;    // TOUCH_ACTION_MOVE
                     touchAction = 2;    // TOUCH_ACTION_MOVE
-                    gestureUpdate = true;
                 }
                 }
 
 
                 if (event.code == ABS_Y)
                 if (event.code == ABS_Y)
@@ -670,7 +666,6 @@ void PollInputEvents(void)
                     CORE.Input.Touch.position[0].y = (event.value - platform.absRange.y)*CORE.Window.screen.height/platform.absRange.height;      // Scale according to absRange
                     CORE.Input.Touch.position[0].y = (event.value - platform.absRange.y)*CORE.Window.screen.height/platform.absRange.height;      // Scale according to absRange
 
 
                     touchAction = 2;    // TOUCH_ACTION_MOVE
                     touchAction = 2;    // TOUCH_ACTION_MOVE
-                    gestureUpdate = true;
                 }
                 }
 
 
                 // Multitouch movement
                 // Multitouch movement
@@ -706,7 +701,6 @@ void PollInputEvents(void)
                         platform.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 0;
                         platform.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 0;
 
 
                         touchAction = 0;    // TOUCH_ACTION_UP
                         touchAction = 0;    // TOUCH_ACTION_UP
-                        gestureUpdate = true;
                     }
                     }
 
 
                     if (event.value && !previousMouseLeftButtonState)
                     if (event.value && !previousMouseLeftButtonState)
@@ -714,7 +708,6 @@ void PollInputEvents(void)
                         platform.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 1;
                         platform.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 1;
 
 
                         touchAction = 1;    // TOUCH_ACTION_DOWN
                         touchAction = 1;    // TOUCH_ACTION_DOWN
-                        gestureUpdate = true;
                     }
                     }
                 }
                 }
 
 
@@ -730,7 +723,6 @@ void PollInputEvents(void)
 
 
                     if (event.value > 0) touchAction = 1;   // TOUCH_ACTION_DOWN
                     if (event.value > 0) touchAction = 1;   // TOUCH_ACTION_DOWN
                     else touchAction = 0;       // TOUCH_ACTION_UP
                     else touchAction = 0;       // TOUCH_ACTION_UP
-                    gestureUpdate = true;
                 }
                 }
 
 
                 if (event.code == BTN_RIGHT) platform.currentButtonStateEvdev[MOUSE_BUTTON_RIGHT] = event.value;
                 if (event.code == BTN_RIGHT) platform.currentButtonStateEvdev[MOUSE_BUTTON_RIGHT] = event.value;
@@ -759,7 +751,7 @@ void PollInputEvents(void)
             }
             }
 
 
 #if defined(SUPPORT_GESTURES_SYSTEM)
 #if defined(SUPPORT_GESTURES_SYSTEM)
-            if (gestureUpdate)
+            if (touchAction > -1)
             {
             {
                 GestureEvent gestureEvent = { 0 };
                 GestureEvent gestureEvent = { 0 };
 
 
@@ -774,7 +766,7 @@ void PollInputEvents(void)
 
 
                 ProcessGestureEvent(gestureEvent);
                 ProcessGestureEvent(gestureEvent);
 
 
-                gestureUpdate = false;
+                touchAction = -1;
             }
             }
 #endif
 #endif
         }
         }