diff options
author | erdgeist <erdgeist@bauklotz.local> | 2017-04-10 13:07:27 +0200 |
---|---|---|
committer | erdgeist <erdgeist@bauklotz.local> | 2017-04-10 13:07:27 +0200 |
commit | ac992a6375f4c2e82510dd0106b7bd4b4fec008f (patch) | |
tree | f30fbeef67c37b2f60826cf108d29bb39d7c82b8 | |
parent | b9802b744654ca13510270cd6c4d845a233e0a12 (diff) |
Touch up default output. Also react to mouse moves
-rw-r--r-- | main-sdl.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -143,7 +143,7 @@ harfe_worker(void) | |||
143 | char *portname = find_harfe(); | 143 | char *portname = find_harfe(); |
144 | 144 | ||
145 | if (!portname) { | 145 | if (!portname) { |
146 | printf("Can't find harfe serial device.\n"); | 146 | printf("Can't find harfe serial device..."); |
147 | return; | 147 | return; |
148 | } | 148 | } |
149 | g_harfe_fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC); | 149 | g_harfe_fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC); |
@@ -230,7 +230,7 @@ worker(void *args) | |||
230 | while (1) { | 230 | while (1) { |
231 | harfe_worker(); | 231 | harfe_worker(); |
232 | g_harfe_connected = 0; | 232 | g_harfe_connected = 0; |
233 | printf("retrying in 5 seconds.\n"); | 233 | printf(" retrying in 5 seconds.\n"); |
234 | sleep(5); | 234 | sleep(5); |
235 | } | 235 | } |
236 | } | 236 | } |
@@ -441,6 +441,13 @@ main(int argc, char **argv) | |||
441 | write(g_harfe_fd, "ME20020\nM824C00\n", 16); | 441 | write(g_harfe_fd, "ME20020\nM824C00\n", 16); |
442 | } | 442 | } |
443 | break; | 443 | break; |
444 | case SDL_MOUSEMOTION: | ||
445 | if (ev.motion.state & SDL_BUTTON_LMASK) | ||
446 | { | ||
447 | LPoint p = { display_scale_screen_to_harfe(ev.motion.x), 768 - display_scale_screen_to_harfe(ev.motion.y) }; | ||
448 | engine_handle_point(&p, now()); | ||
449 | } | ||
450 | break; | ||
444 | case SDL_MOUSEBUTTONDOWN: | 451 | case SDL_MOUSEBUTTONDOWN: |
445 | /* | 452 | /* |
446 | if ( ( g_last_mouse_event / 1000 ) != ( engine_now( ) / 1000 ) || ev.button.x != last_click_x || ev.button.y != last_click_y ) | 453 | if ( ( g_last_mouse_event / 1000 ) != ( engine_now( ) / 1000 ) || ev.button.x != last_click_x || ev.button.y != last_click_y ) |
@@ -479,7 +486,8 @@ main(int argc, char **argv) | |||
479 | 486 | ||
480 | } | 487 | } |
481 | if (runtime / 1000 - g_last_avg > 10) { | 488 | if (runtime / 1000 - g_last_avg > 10) { |
482 | printf("avg: %i\n", g_events / 10); | 489 | if (g_events) |
490 | printf("avg: %i\n", g_events / 10); | ||
483 | g_events = 0; | 491 | g_events = 0; |
484 | g_last_avg = runtime / 1000; | 492 | g_last_avg = runtime / 1000; |
485 | } | 493 | } |