Fixed bug 2054 - SDL_GetError: "Unknown touch device" Volumetric The "Unknown touch device" message appears because the initial touch device setup loop uses SDL_GetTouch() as a guard for calling SDL_AddTouch(). SDL_GetTouch() will always report "Unknown touch device" since the device hasn't been added yet. The SDL_GetTouch() call is unnecessary since SDL_AddTouch() calls SDL_GetTouchIndex() to verify that the device hasn't been added yet, and SDL_GetTouchIndex() has the benefit of not reporting an error for a device it can't find.
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
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 288e55d..eff5b0c 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -951,10 +951,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
for (NSTouch *touch in touches) {
const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
- if (!SDL_GetTouch(touchId)) {
- if (SDL_AddTouch(touchId, "") < 0) {
- return;
- }
+ if (SDL_AddTouch(touchId, "") < 0) {
+ return;
}
const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c
index 93cf28f..d87be82 100644
--- a/src/video/emscripten/SDL_emscriptenevents.c
+++ b/src/video/emscripten/SDL_emscriptenevents.c
@@ -376,10 +376,8 @@ Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, vo
int i;
SDL_TouchID deviceId = 0;
- if (!SDL_GetTouch(deviceId)) {
- if (SDL_AddTouch(deviceId, "") < 0) {
- return 0;
- }
+ if (SDL_AddTouch(deviceId, "") < 0) {
+ return 0;
}
for (i = 0; i < touchEvent->numTouches; i++) {
diff --git a/src/video/wayland/SDL_waylandtouch.c b/src/video/wayland/SDL_waylandtouch.c
index 7dbedac..98b2214 100644
--- a/src/video/wayland/SDL_waylandtouch.c
+++ b/src/video/wayland/SDL_waylandtouch.c
@@ -89,11 +89,9 @@ touch_handle_touch(void *data,
*/
SDL_TouchID deviceId = 0;
- if (!SDL_GetTouch(deviceId)) {
- if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
- SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
- }
- }
+ if (SDL_AddTouch(deviceId, "qt_touch_extension") < 0) {
+ SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
+ }
switch (touchState) {
case QtWaylandTouchPointPressed:
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 92e58d4..7ade709 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -849,10 +849,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
PTOUCHINPUT input = &inputs[i];
const SDL_TouchID touchId = (SDL_TouchID)((size_t)input->hSource);
- if (!SDL_GetTouch(touchId)) {
- if (SDL_AddTouch(touchId, "") < 0) {
- continue;
- }
+ if (SDL_AddTouch(touchId, "") < 0) {
+ continue;
}
/* Get the normalized coordinates for the window */
diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c
index 4497f38..5cb7109 100644
--- a/src/video/x11/SDL_x11xinput2.c
+++ b/src/video/x11/SDL_x11xinput2.c
@@ -197,9 +197,7 @@ X11_InitXinput2Multitouch(_THIS)
continue;
touchId = t->sourceid;
- if (!SDL_GetTouch(touchId)) {
- SDL_AddTouch(touchId, dev->name);
- }
+ SDL_AddTouch(touchId, dev->name);
}
}
X11_XIFreeDeviceInfo(info);