Ver código fonte

touch: Don't call ResetTouch() if SDL_GetTouch() can't find a virtual device.

Fixes #12577.
Ryan C. Gordon 3 semanas atrás
pai
commit
289f5cfdbb
1 arquivos alterados com 4 adições e 2 exclusões
  1. 4 2
      src/events/SDL_touch.c

+ 4 - 2
src/events/SDL_touch.c

@@ -83,9 +83,11 @@ SDL_Touch *SDL_GetTouch(SDL_TouchID id)
 {
     int index = SDL_GetTouchIndex(id);
     if (index < 0 || index >= SDL_num_touch) {
-        if (SDL_GetVideoDevice()->ResetTouch != NULL) {
+        if ((id == SDL_MOUSE_TOUCHID) || (id == SDL_PEN_TOUCHID)) {
+            // this is a virtual touch device, but for some reason they aren't added to the system. Just ignore it.
+        } else if ( SDL_GetVideoDevice()->ResetTouch) {
             SDL_SetError("Unknown touch id %d, resetting", (int)id);
-            (SDL_GetVideoDevice()->ResetTouch)(SDL_GetVideoDevice());
+            SDL_GetVideoDevice()->ResetTouch(SDL_GetVideoDevice());
         } else {
             SDL_SetError("Unknown touch device id %d, cannot reset", (int)id);
         }