Added SDL_EVENT_FINGER_CANCELED
Fixes https://github.com/libsdl-org/SDL/issues/10528
This commit is contained in:
parent
8704ab8422
commit
d4d5faedab
19 changed files with 90 additions and 40 deletions
|
@ -287,8 +287,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||||
p = 1.0f;
|
p = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLActivity.onNativeTouch(touchDevId, pointerId,
|
SDLActivity.onNativeTouch(touchDevId, pointerId, action, x, y, p);
|
||||||
action == MotionEvent.ACTION_CANCEL ? MotionEvent.ACTION_UP : action, x, y, p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Non-primary up/down
|
// Non-primary up/down
|
||||||
|
|
|
@ -212,6 +212,7 @@ typedef enum SDL_EventType
|
||||||
SDL_EVENT_FINGER_DOWN = 0x700,
|
SDL_EVENT_FINGER_DOWN = 0x700,
|
||||||
SDL_EVENT_FINGER_UP,
|
SDL_EVENT_FINGER_UP,
|
||||||
SDL_EVENT_FINGER_MOTION,
|
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! */
|
/* 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
|
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;
|
Uint32 reserved;
|
||||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||||
SDL_TouchID touchID; /**< The touch device id */
|
SDL_TouchID touchID; /**< The touch device id */
|
||||||
|
|
|
@ -546,11 +546,11 @@ void SDL_EVDEV_Poll(void)
|
||||||
* be window-relative in that case. */
|
* be window-relative in that case. */
|
||||||
switch (item->touchscreen_data->slots[j].delta) {
|
switch (item->touchscreen_data->slots[j].delta) {
|
||||||
case EVDEV_TOUCH_SLOTDELTA_DOWN:
|
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;
|
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
||||||
break;
|
break;
|
||||||
case EVDEV_TOUCH_SLOTDELTA_UP:
|
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].tracking_id = 0;
|
||||||
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -136,6 +136,7 @@ SDL_EventCategory SDL_GetEventCategory(Uint32 type)
|
||||||
|
|
||||||
case SDL_EVENT_FINGER_DOWN:
|
case SDL_EVENT_FINGER_DOWN:
|
||||||
case SDL_EVENT_FINGER_UP:
|
case SDL_EVENT_FINGER_UP:
|
||||||
|
case SDL_EVENT_FINGER_CANCELED:
|
||||||
case SDL_EVENT_FINGER_MOTION:
|
case SDL_EVENT_FINGER_MOTION:
|
||||||
return SDL_EVENTCATEGORY_TFINGER;
|
return SDL_EVENTCATEGORY_TFINGER;
|
||||||
|
|
||||||
|
|
|
@ -705,6 +705,9 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||||
SDL_EVENT_CASE(SDL_EVENT_FINGER_UP)
|
SDL_EVENT_CASE(SDL_EVENT_FINGER_UP)
|
||||||
PRINT_FINGER_EVENT(event);
|
PRINT_FINGER_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
SDL_EVENT_CASE(SDL_EVENT_FINGER_CANCELED)
|
||||||
|
PRINT_FINGER_EVENT(event);
|
||||||
|
break;
|
||||||
SDL_EVENT_CASE(SDL_EVENT_FINGER_MOTION)
|
SDL_EVENT_CASE(SDL_EVENT_FINGER_MOTION)
|
||||||
PRINT_FINGER_EVENT(event);
|
PRINT_FINGER_EVENT(event);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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)
|
static void SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, Uint8 button, bool down, int clicks)
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
Uint32 type;
|
SDL_EventType type;
|
||||||
Uint32 buttonstate;
|
Uint32 buttonstate;
|
||||||
SDL_MouseInputSource *source;
|
SDL_MouseInputSource *source;
|
||||||
|
|
||||||
|
@ -851,9 +851,10 @@ static void SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL
|
||||||
track_mouse_down = false;
|
track_mouse_down = false;
|
||||||
}
|
}
|
||||||
if (window) {
|
if (window) {
|
||||||
|
type = track_mouse_down ? SDL_EVENT_FINGER_DOWN : SDL_EVENT_FINGER_UP;
|
||||||
float normalized_x = mouse->x / (float)window->w;
|
float normalized_x = mouse->x / (float)window->w;
|
||||||
float normalized_y = mouse->y / (float)window->h;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_Finger *finger;
|
||||||
SDL_Mouse *mouse;
|
SDL_Mouse *mouse;
|
||||||
|
bool down = (type == SDL_EVENT_FINGER_DOWN);
|
||||||
|
|
||||||
SDL_Touch *touch = SDL_GetTouch(id);
|
SDL_Touch *touch = SDL_GetTouch(id);
|
||||||
if (!touch) {
|
if (!touch) {
|
||||||
|
@ -331,16 +332,16 @@ void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_
|
||||||
if (finger) {
|
if (finger) {
|
||||||
/* This finger is already down.
|
/* This finger is already down.
|
||||||
Assume the finger-up for the previous touch was lost, and send it. */
|
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)) {
|
if (!SDL_AddFinger(touch, fingerid, x, y, pressure)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) {
|
if (SDL_EventEnabled(type)) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_EVENT_FINGER_DOWN;
|
event.type = type;
|
||||||
event.common.timestamp = timestamp;
|
event.common.timestamp = timestamp;
|
||||||
event.tfinger.touchID = id;
|
event.tfinger.touchID = id;
|
||||||
event.tfinger.fingerID = fingerid;
|
event.tfinger.fingerID = fingerid;
|
||||||
|
@ -358,9 +359,9 @@ void SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_EventEnabled(SDL_EVENT_FINGER_UP)) {
|
if (SDL_EventEnabled(type)) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_EVENT_FINGER_UP;
|
event.type = type;
|
||||||
event.common.timestamp = timestamp;
|
event.common.timestamp = timestamp;
|
||||||
event.tfinger.touchID = id;
|
event.tfinger.touchID = id;
|
||||||
event.tfinger.fingerID = fingerid;
|
event.tfinger.fingerID = fingerid;
|
||||||
|
@ -431,7 +432,7 @@ void SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid
|
||||||
|
|
||||||
finger = SDL_GetFinger(touch, fingerid);
|
finger = SDL_GetFinger(touch, fingerid);
|
||||||
if (!finger) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
extern SDL_Touch *SDL_GetTouch(SDL_TouchID id);
|
||||||
|
|
||||||
// Send a touch down/up event for a touch
|
// 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
|
// 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);
|
extern void SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, float x, float y, float pressure);
|
||||||
|
|
|
@ -2897,6 +2897,7 @@ bool SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *even
|
||||||
}
|
}
|
||||||
} else if (event->type == SDL_EVENT_FINGER_DOWN ||
|
} else if (event->type == SDL_EVENT_FINGER_DOWN ||
|
||||||
event->type == SDL_EVENT_FINGER_UP ||
|
event->type == SDL_EVENT_FINGER_UP ||
|
||||||
|
event->type == SDL_EVENT_FINGER_CANCELED ||
|
||||||
event->type == SDL_EVENT_FINGER_MOTION) {
|
event->type == SDL_EVENT_FINGER_MOTION) {
|
||||||
// FIXME: Are these events guaranteed to be window relative?
|
// FIXME: Are these events guaranteed to be window relative?
|
||||||
if (renderer->window) {
|
if (renderer->window) {
|
||||||
|
|
|
@ -1910,8 +1910,10 @@ void SDLTest_PrintEvent(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_FINGER_DOWN:
|
case SDL_EVENT_FINGER_DOWN:
|
||||||
case SDL_EVENT_FINGER_UP:
|
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",
|
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.touchID,
|
||||||
event->tfinger.fingerID,
|
event->tfinger.fingerID,
|
||||||
event->tfinger.x, event->tfinger.y,
|
event->tfinger.x, event->tfinger.y,
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#define ACTION_DOWN 0
|
#define ACTION_DOWN 0
|
||||||
#define ACTION_UP 1
|
#define ACTION_UP 1
|
||||||
#define ACTION_MOVE 2
|
#define ACTION_MOVE 2
|
||||||
// #define ACTION_CANCEL 3
|
#define ACTION_CANCEL 3
|
||||||
// #define ACTION_OUTSIDE 4
|
// #define ACTION_OUTSIDE 4
|
||||||
#define ACTION_POINTER_DOWN 5
|
#define ACTION_POINTER_DOWN 5
|
||||||
#define ACTION_POINTER_UP 6
|
#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) {
|
switch (action) {
|
||||||
case ACTION_DOWN:
|
case ACTION_DOWN:
|
||||||
case ACTION_POINTER_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;
|
break;
|
||||||
|
|
||||||
case ACTION_MOVE:
|
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_UP:
|
||||||
case ACTION_POINTER_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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1844,7 +1844,7 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL
|
||||||
* events from being generated from touch events.
|
* events from being generated from touch events.
|
||||||
*/
|
*/
|
||||||
SDL_Window *window = NULL;
|
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);
|
SDL_free(fingers);
|
||||||
}
|
}
|
||||||
|
@ -1914,11 +1914,13 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL
|
||||||
|
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case NSTouchPhaseBegan:
|
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;
|
break;
|
||||||
case NSTouchPhaseEnded:
|
case NSTouchPhaseEnded:
|
||||||
|
SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_UP, x, y, 1.0f);
|
||||||
|
break;
|
||||||
case NSTouchPhaseCancelled:
|
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;
|
break;
|
||||||
case NSTouchPhaseMoved:
|
case NSTouchPhaseMoved:
|
||||||
SDL_SendTouchMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, x, y, 1.0f);
|
SDL_SendTouchMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, x, y, 1.0f);
|
||||||
|
|
|
@ -433,7 +433,7 @@ static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) {
|
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
|
// disable browser scrolling/pinch-to-zoom if app handles touch events
|
||||||
if (!preventDefault && SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) {
|
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) {
|
} else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) {
|
||||||
SDL_SendTouchMotion(0, deviceId, id, window_data->window, x, y, 1.0f);
|
SDL_SendTouchMotion(0, deviceId, id, window_data->window, x, y, 1.0f);
|
||||||
} else {
|
} else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) {
|
||||||
SDL_SendTouch(0, deviceId, id, window_data->window, false, x, y, 1.0f);
|
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
|
// block browser's simulated mousedown/mouseup on touchscreen devices
|
||||||
preventDefault = 1;
|
preventDefault = 1;
|
||||||
|
} else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) {
|
||||||
|
SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_CANCELED, x, y, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ void N3DS_PollTouch(SDL_VideoDevice *_this)
|
||||||
was_pressed = pressed;
|
was_pressed = pressed;
|
||||||
SDL_SendTouch(0, N3DS_TOUCH_ID, N3DS_TOUCH_FINGER,
|
SDL_SendTouch(0, N3DS_TOUCH_ID, N3DS_TOUCH_FINGER,
|
||||||
window,
|
window,
|
||||||
pressed,
|
pressed ? SDL_EVENT_FINGER_DOWN : SDL_EVENT_FINGER_UP,
|
||||||
touch.px * TOUCHSCREEN_SCALE_X,
|
touch.px * TOUCHSCREEN_SCALE_X,
|
||||||
touch.py * TOUCHSCREEN_SCALE_Y,
|
touch.py * TOUCHSCREEN_SCALE_Y,
|
||||||
pressed ? 1.0f : 0.0f);
|
pressed ? 1.0f : 0.0f);
|
||||||
|
|
|
@ -353,7 +353,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__IPHONE_13_4)
|
#if defined(__IPHONE_13_4)
|
||||||
if (@available(iOS 13.4, *)) {
|
if (@available(iOS 13.4, *)) {
|
||||||
if (touch.type == UITouchTypeIndirectPointer) {
|
if (touch.type == UITouchTypeIndirectPointer) {
|
||||||
|
@ -377,7 +377,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||||
SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
|
SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
|
||||||
touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
|
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
|
#endif
|
||||||
|
|
||||||
#if defined(__IPHONE_13_4)
|
#if defined(__IPHONE_13_4)
|
||||||
if (@available(iOS 13.4, *)) {
|
if (@available(iOS 13.4, *)) {
|
||||||
if (touch.type == UITouchTypeIndirectPointer) {
|
if (touch.type == UITouchTypeIndirectPointer) {
|
||||||
|
@ -417,13 +417,46 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
||||||
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
|
||||||
SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
|
SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]),
|
||||||
touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow,
|
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
|
- (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
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
|
|
|
@ -125,7 +125,7 @@ void VITA_PollTouch(void)
|
||||||
// Skip if finger was already previously down
|
// Skip if finger was already previously down
|
||||||
if (!finger_down) {
|
if (!finger_down) {
|
||||||
// Send an initial touch
|
// 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
|
// 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);
|
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_id = (SDL_FingerID)(touch_old[port].report[i].id + 1);
|
||||||
// Finger released from screen
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1148,7 +1148,7 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri
|
||||||
SDL_SetMouseFocus(window_data->sdlwindow);
|
SDL_SetMouseFocus(window_data->sdlwindow);
|
||||||
|
|
||||||
SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
|
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;
|
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_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
|
/* 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.
|
* 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);
|
const float y = (float)(wl_fixed_to_double(tp->fy) / window_data->current.logical_height);
|
||||||
|
|
||||||
SDL_SendTouch(0, (SDL_TouchID)(uintptr_t)touch,
|
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.
|
// Remove the touch from the list before checking for still-active touches on the surface.
|
||||||
WAYLAND_wl_list_remove(&tp->link);
|
WAYLAND_wl_list_remove(&tp->link);
|
||||||
|
|
|
@ -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?
|
// FIXME: Should we use the input->dwTime field for the tick source of the timestamp?
|
||||||
if (input->dwFlags & TOUCHEVENTF_DOWN) {
|
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) {
|
if (input->dwFlags & TOUCHEVENTF_MOVE) {
|
||||||
SDL_SendTouchMotion(WIN_GetEventTimestamp(), touchId, fingerId, data->window, x, y, 1.0f);
|
SDL_SendTouchMotion(WIN_GetEventTimestamp(), touchId, fingerId, data->window, x, y, 1.0f);
|
||||||
}
|
}
|
||||||
if (input->dwFlags & TOUCHEVENTF_UP) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,7 +482,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
||||||
float x, y;
|
float x, y;
|
||||||
SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
|
SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
|
||||||
xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y);
|
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;
|
} break;
|
||||||
|
|
||||||
case XI_TouchEnd:
|
case XI_TouchEnd:
|
||||||
|
@ -491,7 +491,7 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
||||||
float x, y;
|
float x, y;
|
||||||
SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
|
SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
|
||||||
xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y);
|
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;
|
} break;
|
||||||
|
|
||||||
case XI_TouchUpdate:
|
case XI_TouchUpdate:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue