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

Fixes #12577.
This commit is contained in:
Ryan C. Gordon 2025-03-27 12:01:02 -04:00
parent b00b08f832
commit 289f5cfdbb
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 4 additions and 2 deletions

View File

@ -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);
}