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:
parent
be5ec5c0ed
commit
bdaae19854
62
Input.cpp
62
Input.cpp
|
@ -50,31 +50,65 @@ void Input::getInput()
|
|||
appData.mapMoved = 1;
|
||||
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) {
|
||||
appData.tapCount = 0;
|
||||
}
|
||||
appData.touchDownTime = mstime();
|
||||
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:;
|
||||
appData.touchx = event.motion.x;
|
||||
appData.touchy = event.motion.y;
|
||||
appData.tapCount = event.button.clicks;
|
||||
if(event.button.which != SDL_TOUCH_MOUSEID) {
|
||||
appData.touchx = event.motion.x;
|
||||
appData.touchy = event.motion.y;
|
||||
appData.tapCount = event.button.clicks;
|
||||
appData.isDragging = 0;
|
||||
|
||||
view->registerClick();
|
||||
|
||||
appData.isDragging = 0;
|
||||
view->registerClick();
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:;
|
||||
appData.mouseMovedTime = mstime();
|
||||
appData.mousex = event.motion.x;
|
||||
appData.mousey = event.motion.y;
|
||||
|
||||
if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
|
||||
appData.isDragging = 1;
|
||||
view->moveCenterRelative(event.motion.xrel, event.motion.yrel);
|
||||
|
||||
if(event.motion.which != SDL_TOUCH_MOUSEID) {
|
||||
appData.mouseMovedTime = mstime();
|
||||
appData.mousex = event.motion.x;
|
||||
appData.mousey = event.motion.y;
|
||||
|
||||
if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
|
||||
appData.isDragging = 1;
|
||||
view->moveCenterRelative(event.motion.xrel, event.motion.yrel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
93406437edceb4cd6d39e963d3094663472f660b
|
||||
3e3eb8a1241fe042f8979c8ab0fb931f24e6100f
|
Loading…
Reference in a new issue