Go to the documentation of this file.
21 #include "../SDL_internal.h"
28 #include "../video/SDL_sysvideo.h"
36 #define SYNTHESIZE_TOUCH_TO_MOUSE 1
38 #if SYNTHESIZE_TOUCH_TO_MOUSE
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);
217 finger->
id = fingerid;
243 SDL_bool down,
float x,
float y,
float pressure)
256 #if SYNTHESIZE_TOUCH_TO_MOUSE
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;
279 if (pos_y < 0) pos_y = 0;
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;
392 if (pos_y < 0) pos_y = 0;
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;
SDL_Mouse * SDL_GetMouse(void)
@ SDL_TOUCH_DEVICE_INVALID
SDL_TouchID SDL_GetTouchDevice(int index)
Get the touch ID with the given index, or 0 if the index is invalid.
SDL_bool touch_mouse_events
static SDL_FingerID track_fingerid
static SDL_bool finger_touching
static SDL_Finger * SDL_GetFinger(const SDL_Touch *touch, SDL_FingerID id)
static int SDL_DelFinger(SDL_Touch *touch, SDL_FingerID fingerid)
void(* ResetTouch)(_THIS)
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
The type used to identify a window.
#define SDL_GetKeyboardFocus
#define SDL_TOUCH_MOUSEID
static SDL_TouchID track_touchid
static int SDL_GetTouchIndex(SDL_TouchID id)
SDL_bool mouse_touch_events
int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
GLint GLint GLint GLint GLint x
#define SDL_GetEventState(type)
EGLSurface EGLNativeWindowType * window
SDL_TouchDeviceType SDL_GetTouchDeviceType(SDL_TouchID id)
Get the type of the given touch device.
int SDL_GetNumTouchFingers(SDL_TouchID touchID)
Get the number of active fingers for a given touch device.
GLuint const GLchar * name
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
int SDL_GestureDelTouch(SDL_TouchID touchId)
SDL_Finger * SDL_GetTouchFinger(SDL_TouchID touchID, int index)
Get the finger object of the given touch, with the given index.
void SDL_DelTouch(SDL_TouchID id)
#define SDL_assert(condition)
static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure)
#define SDL_OutOfMemory()
GLint GLint GLint GLint GLint GLint y
int SDL_GestureAddTouch(SDL_TouchID touchId)
#define SDL_MOUSE_TOUCHID
#define SDL_GetMouseFocus
int SDL_GetNumTouchDevices(void)
Get the number of registered touch devices.
static SDL_Touch ** SDL_touchDevices
SDL_VideoDevice * SDL_GetVideoDevice(void)
static int SDL_GetFingerIndex(const SDL_Touch *touch, SDL_FingerID fingerid)
GLuint GLuint GLsizei GLenum type
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)
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
SDL_Touch * SDL_GetTouch(SDL_TouchID id)