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 :
if (event.tfinger.x * winW > rtData.screenOffset.x &&
event.tfinger.x * winW < winW - rtData.screenOffset.x) {
i = event.tfinger.fingerId; i = event.tfinger.fingerId;
touchState.fingers[i].down = true; 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 :
if (event.tfinger.x * winW > rtData.screenOffset.x &&
event.tfinger.x * winW < winW - rtData.screenOffset.x) {
i = event.tfinger.fingerId; i = event.tfinger.fingerId;
touchState.fingers[i].x = event.tfinger.x * winW; touchState.fingers[i].x = event.tfinger.x * winW;
touchState.fingers[i].y = event.tfinger.y * winH; touchState.fingers[i].y = event.tfinger.y * winH;
}
break; break;
case SDL_FINGERUP : case SDL_FINGERUP :