From d4d5faedabec674bde0581b7508d13e0c2d0d982 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 30 Dec 2024 18:43:09 -0800
Subject: [PATCH] Added SDL_EVENT_FINGER_CANCELED
Fixes https://github.com/libsdl-org/SDL/issues/10528
---
.../main/java/org/libsdl/app/SDLSurface.java | 3 +-
include/SDL3/SDL_events.h | 3 +-
src/core/linux/SDL_evdev.c | 4 +-
src/events/SDL_categories.c | 1 +
src/events/SDL_events.c | 3 ++
src/events/SDL_mouse.c | 5 ++-
src/events/SDL_touch.c | 15 ++++---
src/events/SDL_touch_c.h | 2 +-
src/render/SDL_render.c | 1 +
src/test/SDL_test_common.c | 4 +-
src/video/android/SDL_androidtouch.c | 10 +++--
src/video/cocoa/SDL_cocoawindow.m | 8 ++--
src/video/emscripten/SDL_emscriptenevents.c | 8 ++--
src/video/n3ds/SDL_n3dstouch.c | 2 +-
src/video/uikit/SDL_uikitview.m | 43 ++++++++++++++++---
src/video/vita/SDL_vitatouch.c | 4 +-
src/video/wayland/SDL_waylandevents.c | 6 +--
src/video/windows/SDL_windowsevents.c | 4 +-
src/video/x11/SDL_x11xinput2.c | 4 +-
19 files changed, 90 insertions(+), 40 deletions(-)
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLSurface.java b/android-project/app/src/main/java/org/libsdl/app/SDLSurface.java
index 6b5f4346622db..165882134050e 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLSurface.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLSurface.java
@@ -287,8 +287,7 @@ public boolean onTouch(View v, MotionEvent event) {
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
diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h
index 2850b76394a5a..e67559437bab1 100644
--- a/include/SDL3/SDL_events.h
+++ b/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 */
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 456a04f18ec22..16a4cfe08f98a 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/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;
diff --git a/src/events/SDL_categories.c b/src/events/SDL_categories.c
index 5f0853476f3ac..900e7beabb2cf 100644
--- a/src/events/SDL_categories.c
+++ b/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;
diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index bc04ee91a348c..3764d62e886a3 100644
--- a/src/events/SDL_events.c
+++ b/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;
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 5cad582e21409..86c8a472430ba 100644
--- a/src/events/SDL_mouse.c
+++ b/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);
}
}
}
diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c
index 3ad041d817a11..c2d7971bfdab7 100644
--- a/src/events/SDL_touch.c
+++ b/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;
}
diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h
index 43e4fd1720771..d3330878fea63 100644
--- a/src/events/SDL_touch_c.h
+++ b/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);
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 6e8c7ad33fa2d..4ea7b2d156c62 100644
--- a/src/render/SDL_render.c
+++ b/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) {
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 62602f66a9329..62fab7eee49fb 100644
--- a/src/test/SDL_test_common.c
+++ b/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,
diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c
index 75b0c04181c39..293fd22afc163 100644
--- a/src/video/android/SDL_androidtouch.c
+++ b/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:
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index c4512033fdfcd..38b89d8edeeca 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1844,7 +1844,7 @@ - (void)touchesBeganWithEvent:(NSEvent *)theEvent
* 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 @@ - (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent
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);
diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c
index aeffef64cca40..f770f6d59f286 100644
--- a/src/video/emscripten/SDL_emscriptenevents.c
+++ b/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);
}
}
diff --git a/src/video/n3ds/SDL_n3dstouch.c b/src/video/n3ds/SDL_n3dstouch.c
index 7379ea15ea213..323f2d92ae66d 100644
--- a/src/video/n3ds/SDL_n3dstouch.c
+++ b/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);
diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m
index 82d66adef2346..e99fbb51f637f 100644
--- a/src/video/uikit/SDL_uikitview.m
+++ b/src/video/uikit/SDL_uikitview.m
@@ -353,7 +353,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
}
}
#endif
-
+
#if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
@@ -377,7 +377,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
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 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
}
}
#endif
-
+
#if defined(__IPHONE_13_4)
if (@available(iOS 13.4, *)) {
if (touch.type == UITouchTypeIndirectPointer) {
@@ -417,13 +417,46 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
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
diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c
index 2f2183357fdf5..d5daef25c5484 100644
--- a/src/video/vita/SDL_vitatouch.c
+++ b/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);
}
}
}
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 14cc9f3901eb3..28b37315dac10 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/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);
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index e1a4af4430a47..73f3c627e46ad 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/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);
}
}
}
diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c
index 214a5c01b23e2..46df78de40638 100644
--- a/src/video/x11/SDL_x11xinput2.c
+++ b/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: