diff options
Diffstat (limited to 'main-sdl.c')
-rw-r--r-- | main-sdl.c | 35 |
1 files changed, 29 insertions, 6 deletions
@@ -42,14 +42,14 @@ find_harfe() | |||
42 | 42 | ||
43 | while ((dp = readdir(dev)) != NULL) { | 43 | while ((dp = readdir(dev)) != NULL) { |
44 | size_t len = dp->d_namlen; | 44 | size_t len = dp->d_namlen; |
45 | char *name = dp->d_name, *H, *A, *R; | 45 | char *name = dp->d_name; |
46 | int i; | 46 | int i, tail = 3; |
47 | 47 | ||
48 | if (len < 6 || name[0] != 'c' || name[1] != 'u' || name[2] != '.') | 48 | if (len < 6 || name[0] != 'c' || name[1] != 'u' || name[2] != '.') |
49 | continue; | 49 | continue; |
50 | 50 | ||
51 | for (i = 0; i < len - 3; ++i) | 51 | for (i = 0; i < len - tail; ++i) |
52 | if (name[i] == 'H' && name[i + 1] == 'A' && name[i + 2] == 'R') { | 52 | if (name[i] == 'H' && name[i + 1] == 'A' && name[i + 2] == 'R' ) { |
53 | if ((harfe = calloc(1, 5 + len + 1))) { | 53 | if ((harfe = calloc(1, 5 + len + 1))) { |
54 | sprintf(harfe, "/dev/"); | 54 | sprintf(harfe, "/dev/"); |
55 | memcpy(harfe + 5, name, len); | 55 | memcpy(harfe + 5, name, len); |
@@ -58,6 +58,7 @@ find_harfe() | |||
58 | } | 58 | } |
59 | } | 59 | } |
60 | closedir(dev); | 60 | closedir(dev); |
61 | |||
61 | return harfe; | 62 | return harfe; |
62 | } | 63 | } |
63 | 64 | ||
@@ -176,7 +177,7 @@ harfe_worker(void) | |||
176 | *lineend = 0; | 177 | *lineend = 0; |
177 | if (text_fill && lineend[-1] == '\r') | 178 | if (text_fill && lineend[-1] == '\r') |
178 | lineend[-1] = 0; | 179 | lineend[-1] = 0; |
179 | 180 | printf( "%s\n", text ); | |
180 | int num_points = sscanf(text, "%04d:%04d %04d:%04d %04d:%04d %04d:%04d", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y, &p[3].x, &p[3].y); | 181 | int num_points = sscanf(text, "%04d:%04d %04d:%04d %04d:%04d %04d:%04d", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y, &p[3].x, &p[3].y); |
181 | 182 | ||
182 | ptime = now(); | 183 | ptime = now(); |
@@ -259,7 +260,29 @@ main(int argc, char **argv) | |||
259 | printf( "String order (left to right) is now %sscending.\n", g_stringsdescending ? "de" : "a" ); | 260 | printf( "String order (left to right) is now %sscending.\n", g_stringsdescending ? "de" : "a" ); |
260 | } | 261 | } |
261 | */ | 262 | */ |
262 | break; | 263 | if( ev.key.keysym.scancode == SDL_SCANCODE_R) { |
264 | fprintf( stderr, "re-read config\n" ); | ||
265 | write(g_harfe_fd, "R\n", 2); | ||
266 | } | ||
267 | if( ev.key.keysym.scancode == SDL_SCANCODE_D) { | ||
268 | fprintf( stderr, "Dumping\n" ); | ||
269 | write(g_harfe_fd, "D\n", 2); | ||
270 | } | ||
271 | if( ev.key.keysym.scancode == SDL_SCANCODE_C) { | ||
272 | char confdump[512]; | ||
273 | config_dumpglobals( confdump, sizeof(confdump)); | ||
274 | fputs( confdump, stderr); | ||
275 | for (i=0; i<g_string_count; ++i) { | ||
276 | config_dumpstring(i, confdump, sizeof(confdump)); | ||
277 | fputs( confdump, stderr); | ||
278 | } | ||
279 | } | ||
280 | if( ev.key.keysym.scancode == SDL_SCANCODE_M) { | ||
281 | fprintf( stderr, "MIDIing on %d\n", g_harfe_fd ); | ||
282 | if (g_harfe_connected && (g_harfe_fd != -1)) | ||
283 | write(g_harfe_fd, "ME20020\nM824C00\n", 16); | ||
284 | } | ||
285 | break; | ||
263 | case SDL_MOUSEBUTTONDOWN: | 286 | case SDL_MOUSEBUTTONDOWN: |
264 | /* | 287 | /* |
265 | if( ( g_last_mouse_event / 1000 ) != ( engine_now( ) / 1000 ) || ev.button.x != last_click_x || ev.button.y != last_click_y ) | 288 | if( ( g_last_mouse_event / 1000 ) != ( engine_now( ) / 1000 ) || ev.button.x != last_click_x || ev.button.y != last_click_y ) |