From 3bdfec9df0e3b2fd2cd29a9059ccc61082098ea9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 2 Apr 2013 07:51:23 -0700 Subject: [PATCH] Fixed bug 1781 - SDL sets an error for the initial touch on Android. Philipp Wiesemann SDL sets an error to be queried with SDL_GetError() for the initial touch on Android. Android_OnTouch() in SDL_androidtouch.c uses SDL_GetTouch() to check if a touch device was already added. SDL_GetTouch() sets the error "Unknown touch device" for an out of range access because touch devices are added after initial touch. I think this error is confusing because it always happens by design. I attached a patch which removes the call to SDL_GetTouch() and only uses SDL_AddTouch() which does the check (if already added) again and does not set an error (if not added yet). --- src/video/android/SDL_androidtouch.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 4f4a8fdb2..c8d5ae6d5 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -63,10 +63,8 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio } touchDeviceId = (SDL_TouchID)touch_device_id_in; - if (!SDL_GetTouch(touchDeviceId)) { - if (SDL_AddTouch(touchDeviceId, "") < 0) { - SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); - } + if (SDL_AddTouch(touchDeviceId, "") < 0) { + SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); } fingerId = (SDL_FingerID)pointer_finger_id_in;