separating touch and mouse events to avoid doubling up on touch laptops

Former-commit-id: 52e7e5b694b63f32983161c30c7c303e65eeb948
Former-commit-id: 0dbb0763a6ee302365429495cdcc3ebe9029a584
This commit is contained in:
nathan 2020-03-11 22:07:57 -07:00
parent be5ec5c0ed
commit bdaae19854
2 changed files with 49 additions and 15 deletions

View file

@ -50,31 +50,65 @@ void Input::getInput()
appData.mapMoved = 1; appData.mapMoved = 1;
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_FINGERMOTION:;
appData.isDragging = 1;
view->moveCenterRelative( appData.screen_width * event.tfinger.dx, appData.screen_height * event.tfinger.dy);
break;
case SDL_FINGERDOWN:
if(mstime() - appData.touchDownTime > 500) { if(mstime() - appData.touchDownTime > 500) {
appData.tapCount = 0; appData.tapCount = 0;
} }
appData.touchDownTime = mstime(); appData.touchDownTime = mstime();
break; break;
case SDL_FINGERUP:
if(mstime() - appData.touchDownTime < 120) {
appData.touchx = appData.screen_width * event.tfinger.x;
appData.touchy = appData.screen_height * event.tfinger.y;
appData.tapCount++;
appData.isDragging = 0;
view->registerClick();
} else {
appData.touchx = 0;
appData.touchy = 0;
appData.tapCount = 0;
}
break;
case SDL_MOUSEBUTTONDOWN:
if(event.button.which != SDL_TOUCH_MOUSEID) {
if(mstime() - appData.touchDownTime > 500) {
appData.tapCount = 0;
}
appData.touchDownTime = mstime();
}
break;
case SDL_MOUSEBUTTONUP:; case SDL_MOUSEBUTTONUP:;
appData.touchx = event.motion.x; if(event.button.which != SDL_TOUCH_MOUSEID) {
appData.touchy = event.motion.y; appData.touchx = event.motion.x;
appData.tapCount = event.button.clicks; appData.touchy = event.motion.y;
appData.tapCount = event.button.clicks;
appData.isDragging = 0;
view->registerClick(); view->registerClick();
}
appData.isDragging = 0;
break; break;
case SDL_MOUSEMOTION:; case SDL_MOUSEMOTION:;
appData.mouseMovedTime = mstime();
appData.mousex = event.motion.x; if(event.motion.which != SDL_TOUCH_MOUSEID) {
appData.mousey = event.motion.y; appData.mouseMovedTime = mstime();
appData.mousex = event.motion.x;
if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) { appData.mousey = event.motion.y;
appData.isDragging = 1;
view->moveCenterRelative(event.motion.xrel, event.motion.yrel); if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
appData.isDragging = 1;
view->moveCenterRelative(event.motion.xrel, event.motion.yrel);
}
} }
break; break;
} }

View file

@ -1 +1 @@
93406437edceb4cd6d39e963d3094663472f660b 3e3eb8a1241fe042f8979c8ab0fb931f24e6100f