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