Fixed bug 2054 - SDL_GetError: "Unknown touch device"
authorSam Lantinga <slouken@libsdl.org>
Thu, 28 May 2015 12:55:01 -0700
changeset 9679 7fc4a8be47a8
parent 9678 9e8323b058d6
child 9680 1d13a878b066
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.
src/video/cocoa/SDL_cocoawindow.m
src/video/emscripten/SDL_emscriptenevents.c
src/video/wayland/SDL_waylandtouch.c
src/video/windows/SDL_windowsevents.c
src/video/x11/SDL_x11xinput2.c
--- a/src/video/cocoa/SDL_cocoawindow.m	Thu May 28 12:48:20 2015 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.m	Thu May 28 12:55:01 2015 -0700
@@ -951,10 +951,8 @@
 
     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];
--- a/src/video/emscripten/SDL_emscriptenevents.c	Thu May 28 12:48:20 2015 -0700
+++ b/src/video/emscripten/SDL_emscriptenevents.c	Thu May 28 12:55:01 2015 -0700
@@ -376,10 +376,8 @@
     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++) {
--- a/src/video/wayland/SDL_waylandtouch.c	Thu May 28 12:48:20 2015 -0700
+++ b/src/video/wayland/SDL_waylandtouch.c	Thu May 28 12:55:01 2015 -0700
@@ -89,11 +89,9 @@
     */
 
     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:
--- a/src/video/windows/SDL_windowsevents.c	Thu May 28 12:48:20 2015 -0700
+++ b/src/video/windows/SDL_windowsevents.c	Thu May 28 12:55:01 2015 -0700
@@ -849,10 +849,8 @@
                     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 */
--- a/src/video/x11/SDL_x11xinput2.c	Thu May 28 12:48:20 2015 -0700
+++ b/src/video/x11/SDL_x11xinput2.c	Thu May 28 12:55:01 2015 -0700
@@ -197,9 +197,7 @@
                 continue;
 
             touchId = t->sourceid;
-            if (!SDL_GetTouch(touchId)) {
-                SDL_AddTouch(touchId, dev->name);
-            }
+            SDL_AddTouch(touchId, dev->name);
         }
     }
     X11_XIFreeDeviceInfo(info);