mirror of https://github.com/encounter/SDL.git
Bug 4576: track both FingerId and TrackId
This commit is contained in:
parent
e39c0a1f7d
commit
ab03892ddf
|
@ -270,9 +270,7 @@ SDL_EVDEV_Poll(void)
|
||||||
/* BTH_TOUCH event value 1 indicates there is contact with
|
/* BTH_TOUCH event value 1 indicates there is contact with
|
||||||
a touchscreen or trackpad (earlist finger's current
|
a touchscreen or trackpad (earlist finger's current
|
||||||
position is sent in EV_ABS ABS_X/ABS_Y, switching to
|
position is sent in EV_ABS ABS_X/ABS_Y, switching to
|
||||||
next finger after earlist is released) however using it
|
next finger after earlist is released) */
|
||||||
for virtual mouse SDL_TOUCH_MOUSEID would differ from
|
|
||||||
other SDL backends which require a new finger touch. */
|
|
||||||
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
|
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,10 +298,6 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
||||||
int xrel;
|
int xrel;
|
||||||
int yrel;
|
int yrel;
|
||||||
|
|
||||||
if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
|
if (mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
|
||||||
int center_x = 0, center_y = 0;
|
int center_x = 0, center_y = 0;
|
||||||
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
|
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
|
||||||
|
@ -447,10 +443,6 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
|
||||||
Uint32 type;
|
Uint32 type;
|
||||||
Uint32 buttonstate = mouse->buttonstate;
|
Uint32 buttonstate = mouse->buttonstate;
|
||||||
|
|
||||||
if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Figure out which event to perform */
|
/* Figure out which event to perform */
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SDL_PRESSED:
|
case SDL_PRESSED:
|
||||||
|
|
|
@ -32,11 +32,9 @@ static int SDL_num_touch = 0;
|
||||||
static SDL_Touch **SDL_touchDevices = NULL;
|
static SDL_Touch **SDL_touchDevices = NULL;
|
||||||
|
|
||||||
/* for mapping touch events to mice */
|
/* for mapping touch events to mice */
|
||||||
#define DUPLICATE_TO_MOUSE_EVENT
|
|
||||||
#if defined(DUPLICATE_TO_MOUSE_EVENT)
|
|
||||||
static SDL_bool finger_touching = SDL_FALSE;
|
static SDL_bool finger_touching = SDL_FALSE;
|
||||||
static SDL_FingerID first_finger;
|
static SDL_FingerID track_fingerid;
|
||||||
#endif
|
static SDL_TouchID track_touchid;
|
||||||
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
int
|
int
|
||||||
|
@ -247,8 +245,10 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DUPLICATE_TO_MOUSE_EVENT)
|
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
||||||
{
|
{
|
||||||
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
if (mouse->touch_mouse_events) {
|
||||||
SDL_Window *window = SDL_GetMouseFocus();
|
SDL_Window *window = SDL_GetMouseFocus();
|
||||||
if (window) {
|
if (window) {
|
||||||
if (down) {
|
if (down) {
|
||||||
|
@ -256,19 +256,20 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
|
||||||
int pos_x = (int)(x * (float)window->w);
|
int pos_x = (int)(x * (float)window->w);
|
||||||
int pos_y = (int)(y * (float)window->h);
|
int pos_y = (int)(y * (float)window->h);
|
||||||
finger_touching = SDL_TRUE;
|
finger_touching = SDL_TRUE;
|
||||||
first_finger = fingerid;
|
track_touchid = id;
|
||||||
|
track_fingerid = fingerid;
|
||||||
SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
|
SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
|
||||||
SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
|
SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (finger_touching == SDL_TRUE && first_finger == fingerid) {
|
if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
|
||||||
SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
|
SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||||
finger_touching = SDL_FALSE;
|
finger_touching = SDL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
finger = SDL_GetFinger(touch, fingerid);
|
finger = SDL_GetFinger(touch, fingerid);
|
||||||
if (down) {
|
if (down) {
|
||||||
|
@ -334,18 +335,20 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DUPLICATE_TO_MOUSE_EVENT)
|
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
||||||
{
|
{
|
||||||
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
if (mouse->touch_mouse_events) {
|
||||||
SDL_Window *window = SDL_GetMouseFocus();
|
SDL_Window *window = SDL_GetMouseFocus();
|
||||||
if (window) {
|
if (window) {
|
||||||
if (finger_touching == SDL_TRUE && first_finger == fingerid) {
|
if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
|
||||||
int pos_x = (int)(x * (float)window->w);
|
int pos_x = (int)(x * (float)window->w);
|
||||||
int pos_y = (int)(y * (float)window->h);
|
int pos_y = (int)(y * (float)window->h);
|
||||||
SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
|
SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
finger = SDL_GetFinger(touch,fingerid);
|
finger = SDL_GetFinger(touch,fingerid);
|
||||||
if (!finger) {
|
if (!finger) {
|
||||||
|
|
Loading…
Reference in New Issue