Forráskód Böngészése

Added SDL_EVENT_FINGER_CANCELED

Fixes https://github.com/libsdl-org/SDL/issues/10528
Sam Lantinga 3 hónapja
szülő
commit
d4d5faedab

+ 1 - 2
android-project/app/src/main/java/org/libsdl/app/SDLSurface.java

@@ -287,8 +287,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
                     p = 1.0f;
                 }
 
-                SDLActivity.onNativeTouch(touchDevId, pointerId,
-                        action == MotionEvent.ACTION_CANCEL ? MotionEvent.ACTION_UP : action, x, y, p);
+                SDLActivity.onNativeTouch(touchDevId, pointerId, action, x, y, p);
             }
 
             // Non-primary up/down

+ 2 - 1
include/SDL3/SDL_events.h

@@ -212,6 +212,7 @@ typedef enum SDL_EventType
     SDL_EVENT_FINGER_DOWN      = 0x700,
     SDL_EVENT_FINGER_UP,
     SDL_EVENT_FINGER_MOTION,
+    SDL_EVENT_FINGER_CANCELED,
 
     /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */
 
@@ -764,7 +765,7 @@ typedef struct SDL_RenderEvent
  */
 typedef struct SDL_TouchFingerEvent
 {
-    SDL_EventType type; /**< SDL_EVENT_FINGER_MOTION or SDL_EVENT_FINGER_DOWN or SDL_EVENT_FINGER_UP */
+    SDL_EventType type; /**< SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED */
     Uint32 reserved;
     Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
     SDL_TouchID touchID; /**< The touch device id */

+ 2 - 2
src/core/linux/SDL_evdev.c

@@ -546,11 +546,11 @@ void SDL_EVDEV_Poll(void)
                              * be window-relative in that case. */
                             switch (item->touchscreen_data->slots[j].delta) {
                             case EVDEV_TOUCH_SLOTDELTA_DOWN:
-                                SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, true, norm_x, norm_y, norm_pressure);
+                                SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_EVENT_FINGER_DOWN, norm_x, norm_y, norm_pressure);
                                 item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
                                 break;
                             case EVDEV_TOUCH_SLOTDELTA_UP:
-                                SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, false, norm_x, norm_y, norm_pressure);
+                                SDL_SendTouch(SDL_EVDEV_GetEventTimestamp(event), item->fd, item->touchscreen_data->slots[j].tracking_id, NULL, SDL_EVENT_FINGER_UP, norm_x, norm_y, norm_pressure);
                                 item->touchscreen_data->slots[j].tracking_id = 0;
                                 item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
                                 break;

+ 1 - 0
src/events/SDL_categories.c

@@ -136,6 +136,7 @@ SDL_EventCategory SDL_GetEventCategory(Uint32 type)
 
     case SDL_EVENT_FINGER_DOWN:
     case SDL_EVENT_FINGER_UP:
+    case SDL_EVENT_FINGER_CANCELED:
     case SDL_EVENT_FINGER_MOTION:
         return SDL_EVENTCATEGORY_TFINGER;
 

+ 3 - 0
src/events/SDL_events.c

@@ -705,6 +705,9 @@ static void SDL_LogEvent(const SDL_Event *event)
         SDL_EVENT_CASE(SDL_EVENT_FINGER_UP)
         PRINT_FINGER_EVENT(event);
         break;
+        SDL_EVENT_CASE(SDL_EVENT_FINGER_CANCELED)
+        PRINT_FINGER_EVENT(event);
+        break;
         SDL_EVENT_CASE(SDL_EVENT_FINGER_MOTION)
         PRINT_FINGER_EVENT(event);
         break;

+ 3 - 2
src/events/SDL_mouse.c

@@ -827,7 +827,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_MouseInputSource *source, Uin
 static void SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down, int clicks)
 {
     SDL_Mouse *mouse = SDL_GetMouse();
-    Uint32 type;
+    SDL_EventType type;
     Uint32 buttonstate;
     SDL_MouseInputSource *source;
 
@@ -851,9 +851,10 @@ static void SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL
                 track_mouse_down = false;
             }
             if (window) {
+                type = track_mouse_down ? SDL_EVENT_FINGER_DOWN : SDL_EVENT_FINGER_UP;
                 float normalized_x = mouse->x / (float)window->w;
                 float normalized_y = mouse->y / (float)window->h;
-                SDL_SendTouch(timestamp, SDL_MOUSE_TOUCHID, SDL_BUTTON_LEFT, window, track_mouse_down, normalized_x, normalized_y, 1.0f);
+                SDL_SendTouch(timestamp, SDL_MOUSE_TOUCHID, SDL_BUTTON_LEFT, window, type, normalized_x, normalized_y, 1.0f);
             }
         }
     }

+ 8 - 7
src/events/SDL_touch.c

@@ -254,10 +254,11 @@ static void SDL_DelFinger(SDL_Touch *touch, SDL_FingerID fingerid)
     }
 }
 
-void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, bool down, float x, float y, float pressure)
+void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_EventType type, float x, float y, float pressure)
 {
     SDL_Finger *finger;
     SDL_Mouse *mouse;
+    bool down = (type == SDL_EVENT_FINGER_DOWN);
 
     SDL_Touch *touch = SDL_GetTouch(id);
     if (!touch) {
@@ -331,16 +332,16 @@ void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_
         if (finger) {
             /* This finger is already down.
                Assume the finger-up for the previous touch was lost, and send it. */
-            SDL_SendTouch(timestamp, id, fingerid, window, false, x, y, pressure);
+            SDL_SendTouch(timestamp, id, fingerid, window, SDL_EVENT_FINGER_CANCELED, x, y, pressure);
         }
 
         if (!SDL_AddFinger(touch, fingerid, x, y, pressure)) {
             return;
         }
 
-        if (SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) {
+        if (SDL_EventEnabled(type)) {
             SDL_Event event;
-            event.type = SDL_EVENT_FINGER_DOWN;
+            event.type = type;
             event.common.timestamp = timestamp;
             event.tfinger.touchID = id;
             event.tfinger.fingerID = fingerid;
@@ -358,9 +359,9 @@ void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_
             return;
         }
 
-        if (SDL_EventEnabled(SDL_EVENT_FINGER_UP)) {
+        if (SDL_EventEnabled(type)) {
             SDL_Event event;
-            event.type = SDL_EVENT_FINGER_UP;
+            event.type = type;
             event.common.timestamp = timestamp;
             event.tfinger.touchID = id;
             event.tfinger.fingerID = fingerid;
@@ -431,7 +432,7 @@ void SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid
 
     finger = SDL_GetFinger(touch, fingerid);
     if (!finger) {
-        SDL_SendTouch(timestamp, id, fingerid, window, true, x, y, pressure);
+        SDL_SendTouch(timestamp, id, fingerid, window, SDL_EVENT_FINGER_DOWN, x, y, pressure);
         return;
     }
 

+ 1 - 1
src/events/SDL_touch_c.h

@@ -46,7 +46,7 @@ extern int SDL_AddTouch(SDL_TouchID id, SDL_TouchDeviceType type, const char *na
 extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
 
 // Send a touch down/up event for a touch
-extern void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, bool down, float x, float y, float pressure);
+extern void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_EventType type, float x, float y, float pressure);
 
 // Send a touch motion event for a touch
 extern void SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, float x, float y, float pressure);

+ 1 - 0
src/render/SDL_render.c

@@ -2897,6 +2897,7 @@ bool SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *even
         }
     } else if (event->type == SDL_EVENT_FINGER_DOWN ||
                event->type == SDL_EVENT_FINGER_UP ||
+               event->type == SDL_EVENT_FINGER_CANCELED ||
                event->type == SDL_EVENT_FINGER_MOTION) {
         // FIXME: Are these events guaranteed to be window relative?
         if (renderer->window) {

+ 3 - 1
src/test/SDL_test_common.c

@@ -1910,8 +1910,10 @@ void SDLTest_PrintEvent(const SDL_Event *event)
         break;
     case SDL_EVENT_FINGER_DOWN:
     case SDL_EVENT_FINGER_UP:
+    case SDL_EVENT_FINGER_CANCELED:
         SDL_Log("SDL EVENT: Finger: %s touch=%" SDL_PRIu64 ", finger=%" SDL_PRIu64 ", x=%f, y=%f, dx=%f, dy=%f, pressure=%f",
-                (event->type == SDL_EVENT_FINGER_DOWN) ? "down" : "up",
+                (event->type == SDL_EVENT_FINGER_DOWN) ? "down" :
+                (event->type == SDL_EVENT_FINGER_UP) ? "up" : "cancel",
                 event->tfinger.touchID,
                 event->tfinger.fingerID,
                 event->tfinger.x, event->tfinger.y,

+ 7 - 3
src/video/android/SDL_androidtouch.c

@@ -32,7 +32,7 @@
 #define ACTION_DOWN 0
 #define ACTION_UP   1
 #define ACTION_MOVE 2
-// #define ACTION_CANCEL 3
+#define ACTION_CANCEL 3
 // #define ACTION_OUTSIDE 4
 #define ACTION_POINTER_DOWN 5
 #define ACTION_POINTER_UP   6
@@ -72,7 +72,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin
     switch (action) {
     case ACTION_DOWN:
     case ACTION_POINTER_DOWN:
-        SDL_SendTouch(0, touchDeviceId, fingerId, window, true, x, y, p);
+        SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_EVENT_FINGER_DOWN, x, y, p);
         break;
 
     case ACTION_MOVE:
@@ -81,7 +81,11 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin
 
     case ACTION_UP:
     case ACTION_POINTER_UP:
-        SDL_SendTouch(0, touchDeviceId, fingerId, window, false, x, y, p);
+        SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_EVENT_FINGER_UP, x, y, p);
+        break;
+
+    case ACTION_CANCEL:
+        SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_EVENT_FINGER_CANCELED, x, y, p);
         break;
 
     default:

+ 5 - 3
src/video/cocoa/SDL_cocoawindow.m

@@ -1844,7 +1844,7 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL
                  * events from being generated from touch events.
                  */
                 SDL_Window *window = NULL;
-                SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, false, 0, 0, 0);
+                SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, SDL_EVENT_FINGER_CANCELED, 0, 0, 0);
             }
             SDL_free(fingers);
         }
@@ -1914,11 +1914,13 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL
 
         switch (phase) {
         case NSTouchPhaseBegan:
-            SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, true, x, y, 1.0f);
+            SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_DOWN, x, y, 1.0f);
             break;
         case NSTouchPhaseEnded:
+            SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_UP, x, y, 1.0f);
+            break;
         case NSTouchPhaseCancelled:
-            SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, false, x, y, 1.0f);
+            SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_CANCELED, x, y, 1.0f);
             break;
         case NSTouchPhaseMoved:
             SDL_SendTouchMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, x, y, 1.0f);

+ 5 - 3
src/video/emscripten/SDL_emscriptenevents.c

@@ -433,7 +433,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent
         }
 
         if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
-            SDL_SendTouch(0, deviceId, id, window_data->window, true, x, y, 1.0f);
+            SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_DOWN, x, y, 1.0f);
 
             // disable browser scrolling/pinch-to-zoom if app handles touch events
             if (!preventDefault && SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) {
@@ -441,11 +441,13 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent
             }
         } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
             SDL_SendTouchMotion(0, deviceId, id, window_data->window, x, y, 1.0f);
-        } else {
-            SDL_SendTouch(0, deviceId, id, window_data->window, false, x, y, 1.0f);
+        } else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) {
+            SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_UP, x, y, 1.0f);
 
             // block browser's simulated mousedown/mouseup on touchscreen devices
             preventDefault = 1;
+        } else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) {
+            SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_CANCELED, x, y, 1.0f);
         }
     }
 

+ 1 - 1
src/video/n3ds/SDL_n3dstouch.c

@@ -70,7 +70,7 @@ void N3DS_PollTouch(SDL_VideoDevice *_this)
         was_pressed = pressed;
         SDL_SendTouch(0, N3DS_TOUCH_ID, N3DS_TOUCH_FINGER,
                       window,
-                      pressed,
+                      pressed ? SDL_EVENT_FINGER_DOWN : SDL_EVENT_FINGER_UP,
                       touch.px * TOUCHSCREEN_SCALE_X,
                       touch.py * TOUCHSCREEN_SCALE_Y,
                       pressed ? 1.0f : 0.0f);

+ 38 - 5
src/video/uikit/SDL_uikitview.m

@@ -353,7 +353,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
             }
         }
 #endif
-        
+
 #if defined(__IPHONE_13_4)
         if (@available(iOS 13.4, *)) {
             if (touch.type == UITouchTypeIndirectPointer) {
@@ -377,7 +377,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
                       touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
-                      true, locationInView.x, locationInView.y, pressure);
+                      SDL_EVENT_FINGER_DOWN, locationInView.x, locationInView.y, pressure);
     }
 }
 
@@ -393,7 +393,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
             }
         }
 #endif
-        
+
 #if defined(__IPHONE_13_4)
         if (@available(iOS 13.4, *)) {
             if (touch.type == UITouchTypeIndirectPointer) {
@@ -417,13 +417,46 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
         SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
                       touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
-                      false, locationInView.x, locationInView.y, pressure);
+                      SDL_EVENT_FINGER_UP, locationInView.x, locationInView.y, pressure);
     }
 }
 
 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
 {
-    [self touchesEnded:touches withEvent:event];
+    for (UITouch *touch in touches) {
+#if !defined(SDL_PLATFORM_TVOS)
+#if defined(__IPHONE_13_0)
+        if (@available(iOS 13.0, *)) {
+            if (touch.type == UITouchTypePencil) {
+                [self pencilReleased:touch];
+                continue;
+            }
+        }
+#endif
+
+#if defined(__IPHONE_13_4)
+        if (@available(iOS 13.4, *)) {
+            if (touch.type == UITouchTypeIndirectPointer) {
+                [self indirectPointerReleased:touch fromEvent:event];
+                continue;
+            }
+        }
+#endif
+#endif // !defined(SDL_PLATFORM_TVOS)
+
+        SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch];
+        SDL_TouchID touchId = [self touchIdForType:touchType];
+        float pressure = [self pressureForTouch:touch];
+
+        if (SDL_AddTouch(touchId, touchType, "") < 0) {
+            continue;
+        }
+
+        CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
+        SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
+                      touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
+                      SDL_EVENT_FINGER_CANCELED, locationInView.x, locationInView.y, pressure);
+    }
 }
 
 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

+ 2 - 2
src/video/vita/SDL_vitatouch.c

@@ -125,7 +125,7 @@ void VITA_PollTouch(void)
                 // Skip if finger was already previously down
                 if (!finger_down) {
                     // Send an initial touch
-                    SDL_SendTouch(0, touch_id, finger_id, Vita_Window, true, x, y, force);
+                    SDL_SendTouch(0, touch_id, finger_id, Vita_Window, SDL_EVENT_FINGER_DOWN, x, y, force);
                 }
 
                 // Always send the motion
@@ -151,7 +151,7 @@ void VITA_PollTouch(void)
                     VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port);
                     finger_id = (SDL_FingerID)(touch_old[port].report[i].id + 1);
                     // Finger released from screen
-                    SDL_SendTouch(0, touch_id, finger_id, Vita_Window, false, x, y, force);
+                    SDL_SendTouch(0, touch_id, finger_id, Vita_Window, SDL_EVENT_FINGER_UP, x, y, force);
                 }
             }
         }

+ 3 - 3
src/video/wayland/SDL_waylandevents.c

@@ -1148,7 +1148,7 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri
         SDL_SetMouseFocus(window_data->sdlwindow);
 
         SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
-                      (SDL_FingerID)(id + 1), window_data->sdlwindow, true, x, y, 1.0f);
+                      (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_EVENT_FINGER_DOWN, x, y, 1.0f);
     }
 }
 
@@ -1169,7 +1169,7 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial
             const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height;
 
             SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
-                          (SDL_FingerID)(id + 1), window_data->sdlwindow, false, x, y, 0.0f);
+                          (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_EVENT_FINGER_UP, x, y, 0.0f);
 
             /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window currently
              * has mouse focus, and the surface has no active touch events, consider mouse focus to be lost.
@@ -1223,7 +1223,7 @@ static void touch_handler_cancel(void *data, struct wl_touch *touch)
                 const float y = (float)(wl_fixed_to_double(tp->fy) / window_data->current.logical_height);
 
                 SDL_SendTouch(0, (SDL_TouchID)(uintptr_t)touch,
-                              (SDL_FingerID)(tp->id + 1), window_data->sdlwindow, false, x, y, 0.0f);
+                              (SDL_FingerID)(tp->id + 1), window_data->sdlwindow, SDL_EVENT_FINGER_CANCELED, x, y, 0.0f);
 
                 // Remove the touch from the list before checking for still-active touches on the surface.
                 WAYLAND_wl_list_remove(&tp->link);

+ 2 - 2
src/video/windows/SDL_windowsevents.c

@@ -1811,13 +1811,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
 
                     // FIXME: Should we use the input->dwTime field for the tick source of the timestamp?
                     if (input->dwFlags & TOUCHEVENTF_DOWN) {
-                        SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, true, x, y, 1.0f);
+                        SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_EVENT_FINGER_DOWN, x, y, 1.0f);
                     }
                     if (input->dwFlags & TOUCHEVENTF_MOVE) {
                         SDL_SendTouchMotion(WIN_GetEventTimestamp(), touchId, fingerId, data->window, x, y, 1.0f);
                     }
                     if (input->dwFlags & TOUCHEVENTF_UP) {
-                        SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, false, x, y, 1.0f);
+                        SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_EVENT_FINGER_UP, x, y, 1.0f);
                     }
                 }
             }

+ 2 - 2
src/video/x11/SDL_x11xinput2.c

@@ -482,7 +482,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
         float x, y;
         SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
         xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y);
-        SDL_SendTouch(0, xev->sourceid, xev->detail, window, true, x, y, 1.0);
+        SDL_SendTouch(0, xev->sourceid, xev->detail, window, SDL_EVENT_FINGER_DOWN, x, y, 1.0);
     } break;
 
     case XI_TouchEnd:
@@ -491,7 +491,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
         float x, y;
         SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
         xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y);
-        SDL_SendTouch(0, xev->sourceid, xev->detail, window, false, x, y, 1.0);
+        SDL_SendTouch(0, xev->sourceid, xev->detail, window, SDL_EVENT_FINGER_UP, x, y, 1.0);
     } break;
 
     case XI_TouchUpdate: