1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 08:38:07 +00:00

prepare touch events for SDL

This commit is contained in:
Pavol Rusnak 2016-04-01 00:59:09 +02:00
parent 37a33efc57
commit 1d06839b37
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -37,16 +37,27 @@ static int HandleEvents(void *ptr)
{
SDL_Event event;
int x, y;
bool down;
while (SDL_WaitEvent(&event) >= 0) {
switch (event.type) {
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONUP:
x = event.button.x - DISPLAY_BORDER;
y = event.button.y - DISPLAY_BORDER;
if (x < 0 || y < 0 || x >= RESX || y >= RESY) continue;
down = (event.type == SDL_MOUSEBUTTONDOWN);
printf("CLICK %s: %d %d\n", down ? "DOWN" : "UP", x, y);
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
printf("TOUCH START: %d %d\n", x, y);
break;
case SDL_MOUSEMOTION:
if (event.motion.state) {
printf("TOUCH MOVE: %d %d\n", x, y);
}
break;
case SDL_MOUSEBUTTONUP:
printf("TOUCH END: %d %d\n", x, y);
break;
}
break;
}
}