21 #include "../SDL_internal.h" 28 #include "../video/SDL_sysvideo.h" 36 #define SYNTHESIZE_TOUCH_TO_MOUSE 1 38 #if SYNTHESIZE_TOUCH_TO_MOUSE 64 return SDL_touchDevices[
index]->
id;
74 touch = SDL_touchDevices[
index];
75 if (touch->
id ==
id) {
88 SDL_SetError(
"Unknown touch id %d, resetting", (
int)
id);
91 SDL_SetError(
"Unknown touch device id %d, cannot reset", (
int)
id);
95 return SDL_touchDevices[
index];
113 if (touch->
fingers[index]->
id == fingerid) {
172 SDL_touchDevices = touchDevices;
176 if (!SDL_touchDevices[index]) {
184 SDL_touchDevices[
index]->
id = touchID;
217 finger->
id = fingerid;
243 SDL_bool down,
float x,
float y,
float pressure)
256 #if SYNTHESIZE_TOUCH_TO_MOUSE 263 if (window ==
NULL) {
275 int pos_x = (int)(x * (
float)window->
w);
276 int pos_y = (int)(y * (
float)window->
h);
277 if (pos_x < 0) pos_x = 0;
278 if (pos_x > window->
w - 1) pos_x = window->
w - 1;
279 if (pos_y < 0) pos_y = 0;
280 if (pos_y > window->
h - 1) pos_y = window->
h - 1;
328 event.tfinger.touchId =
id;
329 event.tfinger.fingerId = fingerid;
332 event.tfinger.dx = 0;
333 event.tfinger.dy = 0;
334 event.tfinger.pressure = pressure;
347 event.tfinger.touchId =
id;
348 event.tfinger.fingerId = fingerid;
350 event.tfinger.x = finger->
x;
351 event.tfinger.y = finger->
y;
352 event.tfinger.dx = 0;
353 event.tfinger.dy = 0;
354 event.tfinger.pressure = pressure;
365 float x,
float y,
float pressure)
371 float xrel, yrel, prel;
380 #if SYNTHESIZE_TOUCH_TO_MOUSE 388 int pos_x = (int)(x * (
float)window->
w);
389 int pos_y = (int)(y * (
float)window->
h);
390 if (pos_x < 0) pos_x = 0;
391 if (pos_x > window->
w - 1) pos_x = window->
w - 1;
392 if (pos_y < 0) pos_y = 0;
393 if (pos_y > window->
h - 1) pos_y = window->
h - 1;
414 xrel = x - finger->
x;
415 yrel = y - finger->
y;
419 if (xrel == 0.0
f && yrel == 0.0
f && prel == 0.0
f) {
421 printf(
"Touch event didn't change state - dropped!\n");
436 event.tfinger.touchId =
id;
437 event.tfinger.fingerId = fingerid;
440 event.tfinger.dx = xrel;
441 event.tfinger.dy = yrel;
442 event.tfinger.pressure = pressure;
483 SDL_touchDevices =
NULL;
SDL_Mouse * SDL_GetMouse(void)
SDL_TouchID SDL_GetTouchDevice(int index)
Get the touch ID with the given index, or 0 if the index is invalid.
int SDL_GestureDelTouch(SDL_TouchID touchId)
GLint GLint GLint GLint GLint x
static int SDL_DelFinger(SDL_Touch *touch, SDL_FingerID fingerid)
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
static SDL_Finger * SDL_GetFinger(const SDL_Touch *touch, SDL_FingerID id)
static SDL_FingerID track_fingerid
#define SDL_GetKeyboardFocus
static SDL_bool finger_touching
#define SDL_TOUCH_MOUSEID
static int SDL_GetTouchIndex(SDL_TouchID id)
GLuint const GLchar * name
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
SDL_TouchDeviceType SDL_GetTouchDeviceType(SDL_TouchID id)
Get the type of the given touch device.
int SDL_GestureAddTouch(SDL_TouchID touchId)
static SDL_TouchID track_touchid
#define SDL_GetEventState(type)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
SDL_bool touch_mouse_events
int SDL_GetNumTouchFingers(SDL_TouchID touchID)
Get the number of active fingers for a given touch device.
void SDL_DelTouch(SDL_TouchID id)
static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
GLint GLint GLint GLint GLint GLint y
SDL_Finger * SDL_GetTouchFinger(SDL_TouchID touchID, int index)
Get the finger object of the given touch, with the given index.
void(* ResetTouch)(_THIS)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
#define SDL_GetMouseFocus
#define SDL_MOUSE_TOUCHID
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
GLuint GLuint GLsizei GLenum type
SDL_VideoDevice * SDL_GetVideoDevice(void)
int SDL_GetNumTouchDevices(void)
Get the number of registered touch devices.
static SDL_Touch ** SDL_touchDevices
SDL_bool mouse_touch_events
static int SDL_GetFingerIndex(const SDL_Touch *touch, SDL_FingerID fingerid)
SDL_Touch * SDL_GetTouch(SDL_TouchID id)
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)