Bug 4576: track both FingerId and TrackId
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 7b51e4b..0ae3194 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -270,9 +270,7 @@ SDL_EVDEV_Poll(void)
/* BTH_TOUCH event value 1 indicates there is contact with
a touchscreen or trackpad (earlist finger's current
position is sent in EV_ABS ABS_X/ABS_Y, switching to
- next finger after earlist is released) however using it
- for virtual mouse SDL_TOUCH_MOUSEID would differ from
- other SDL backends which require a new finger touch. */
+ next finger after earlist is released) */
if (item->is_touchscreen && events[i].code == BTN_TOUCH) {
break;
}
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 2d9ad8f..451b451 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -298,10 +298,6 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
int xrel;
int yrel;
- if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
- return 0;
- }
-
if (mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
int center_x = 0, center_y = 0;
SDL_GetWindowSize(window, ¢er_x, ¢er_y);
@@ -447,10 +443,6 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
Uint32 type;
Uint32 buttonstate = mouse->buttonstate;
- if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) {
- return 0;
- }
-
/* Figure out which event to perform */
switch (state) {
case SDL_PRESSED:
@@ -520,7 +512,7 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
if (window && state == SDL_RELEASED) {
SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate);
}
-
+
return posted;
}
diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c
index 0d227b4..1f5810a 100644
--- a/src/events/SDL_touch.c
+++ b/src/events/SDL_touch.c
@@ -32,11 +32,9 @@ static int SDL_num_touch = 0;
static SDL_Touch **SDL_touchDevices = NULL;
/* 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_FingerID first_finger;
-#endif
+static SDL_FingerID track_fingerid;
+static SDL_TouchID track_touchid;
/* Public functions */
int
@@ -247,28 +245,31 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
return -1;
}
-#if defined(DUPLICATE_TO_MOUSE_EVENT)
+ /* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
{
- SDL_Window *window = SDL_GetMouseFocus();
- if (window) {
- if (down) {
- if (finger_touching == SDL_FALSE) {
- int pos_x = (int)(x * (float)window->w);
- int pos_y = (int)(y * (float)window->h);
- finger_touching = SDL_TRUE;
- first_finger = fingerid;
- SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
- SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
- }
- } else {
- if (finger_touching == SDL_TRUE && first_finger == fingerid) {
- SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
- finger_touching = SDL_FALSE;
+ SDL_Mouse *mouse = SDL_GetMouse();
+ if (mouse->touch_mouse_events) {
+ SDL_Window *window = SDL_GetMouseFocus();
+ if (window) {
+ if (down) {
+ if (finger_touching == SDL_FALSE) {
+ int pos_x = (int)(x * (float)window->w);
+ int pos_y = (int)(y * (float)window->h);
+ finger_touching = SDL_TRUE;
+ track_touchid = id;
+ track_fingerid = fingerid;
+ SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
+ SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
+ }
+ } else {
+ if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
+ SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
+ finger_touching = SDL_FALSE;
+ }
}
}
}
}
-#endif
finger = SDL_GetFinger(touch, fingerid);
if (down) {
@@ -334,18 +335,20 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
return -1;
}
-#if defined(DUPLICATE_TO_MOUSE_EVENT)
+ /* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
{
- SDL_Window *window = SDL_GetMouseFocus();
- if (window) {
- if (finger_touching == SDL_TRUE && first_finger == fingerid) {
- int pos_x = (int)(x * (float)window->w);
- int pos_y = (int)(y * (float)window->h);
- SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
+ SDL_Mouse *mouse = SDL_GetMouse();
+ if (mouse->touch_mouse_events) {
+ SDL_Window *window = SDL_GetMouseFocus();
+ if (window) {
+ if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
+ int pos_x = (int)(x * (float)window->w);
+ int pos_y = (int)(y * (float)window->h);
+ SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
+ }
}
}
}
-#endif
finger = SDL_GetFinger(touch,fingerid);
if (!finger) {