Prevent touch from leaking out of window

This has some bizzare results if allowed
This commit is contained in:
Varun Patil 2019-05-27 16:30:46 +05:30
parent 0f4de4b5f7
commit 9b9d3e42b2
1 changed files with 14 additions and 5 deletions

View File

@ -397,13 +397,22 @@ void EventThread::process(RGSSThreadData &rtData)
break; break;
case SDL_FINGERDOWN : case SDL_FINGERDOWN :
i = event.tfinger.fingerId; if (event.tfinger.x * winW > rtData.screenOffset.x &&
touchState.fingers[i].down = true; event.tfinger.x * winW < winW - rtData.screenOffset.x) {
i = event.tfinger.fingerId;
touchState.fingers[i].down = true;
touchState.fingers[i].x = event.tfinger.x * winW;
touchState.fingers[i].y = event.tfinger.y * winH;
}
break;
case SDL_FINGERMOTION : case SDL_FINGERMOTION :
i = event.tfinger.fingerId; if (event.tfinger.x * winW > rtData.screenOffset.x &&
touchState.fingers[i].x = event.tfinger.x * winW; event.tfinger.x * winW < winW - rtData.screenOffset.x) {
touchState.fingers[i].y = event.tfinger.y * winH; i = event.tfinger.fingerId;
touchState.fingers[i].x = event.tfinger.x * winW;
touchState.fingers[i].y = event.tfinger.y * winH;
}
break; break;
case SDL_FINGERUP : case SDL_FINGERUP :