mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-28 00:58:09 +00:00
prepare touch events for SDL
This commit is contained in:
parent
37a33efc57
commit
1d06839b37
@ -37,16 +37,27 @@ static int HandleEvents(void *ptr)
|
|||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int x, y;
|
int x, y;
|
||||||
bool down;
|
|
||||||
while (SDL_WaitEvent(&event) >= 0) {
|
while (SDL_WaitEvent(&event) >= 0) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_MOUSEBUTTONUP:
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
x = event.button.x - DISPLAY_BORDER;
|
x = event.button.x - DISPLAY_BORDER;
|
||||||
y = event.button.y - DISPLAY_BORDER;
|
y = event.button.y - DISPLAY_BORDER;
|
||||||
if (x < 0 || y < 0 || x >= RESX || y >= RESY) continue;
|
if (x < 0 || y < 0 || x >= RESX || y >= RESY) continue;
|
||||||
down = (event.type == SDL_MOUSEBUTTONDOWN);
|
switch (event.type) {
|
||||||
printf("CLICK %s: %d %d\n", down ? "DOWN" : "UP", x, y);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user