Change Details
ubb-la/README |
82 | 82 | |
83 | 83 | In the GUI, the following keys are available: |
84 | 84 | |
85 | | Left/Right Pan the waveform left/right |
| 85 | Left/Right Pan the waveform left/right. With Shift, jump to the |
| 86 | next change on any channel in the specified direction. |
86 | 87 | Up/Down Zoom in/out |
87 | 88 | Space Set the user origin (upward-facing green triangle) |
88 | 89 | at the current position and display the time to |
ubb-la/gui.c |
485 | 485 | } |
486 | 486 | |
487 | 487 | |
| 488 | static int smart_pos(const uint8_t *buf, int skip, int nibbles, |
| 489 | int pos, int dir) |
| 490 | { |
| 491 | uint8_t ref; |
| 492 | |
| 493 | if (dir < 0) { |
| 494 | if (!pos) |
| 495 | return pos; |
| 496 | ref = get_sample(buf, skip+pos-1); |
| 497 | } else { |
| 498 | ref = get_sample(buf, skip+pos); |
| 499 | } |
| 500 | do { |
| 501 | pos += dir; |
| 502 | if (pos < 0 || pos == nibbles-skip) |
| 503 | return pos-dir; |
| 504 | } while (get_sample(buf, skip+pos) == ref); |
| 505 | if (dir < 0) |
| 506 | pos++; |
| 507 | return pos; |
| 508 | } |
| 509 | |
| 510 | |
488 | 511 | void gui(const uint8_t *buf, int skip, int nibbles, double freq) |
489 | 512 | { |
490 | 513 | SDL_Event event; |
491 | 514 | int pos = (skip+nibbles) >> 1; |
492 | 515 | int zoom; /* < 0: zoom out; 0: 1 pixel = 1 sample; > 1: zoom in */ |
493 | 516 | int min_zoom = 0; |
494 | | int i; |
| 517 | int i, shift; |
495 | 518 | |
496 | 519 | while (XWIDTH < (nibbles-skip) >> -min_zoom) |
497 | 520 | min_zoom--; |
... | ... | |
515 | 538 | SDL_WaitEvent(&event); |
516 | 539 | switch (event.type) { |
517 | 540 | case SDL_KEYDOWN: |
| 541 | shift = event.key.keysym.mod & KMOD_SHIFT; |
518 | 542 | switch (event.key.keysym.sym) { |
519 | 543 | case SDLK_UP: |
520 | 544 | if (zoom < MAX_ZOOM) |
... | ... | |
525 | 549 | zoom--; |
526 | 550 | break; |
527 | 551 | case SDLK_LEFT: |
528 | | pos -= pos_step(zoom); |
529 | | if (pos < 0) |
530 | | pos = 0; |
| 552 | if (shift) { |
| 553 | pos = smart_pos(buf, |
| 554 | skip, nibbles, pos, -1); |
| 555 | } else { |
| 556 | pos -= pos_step(zoom); |
| 557 | if (pos < 0) |
| 558 | pos = 0; |
| 559 | } |
531 | 560 | break; |
532 | 561 | case SDLK_RIGHT: |
533 | | pos += pos_step(zoom); |
534 | | if (pos > nibbles-skip-1) |
535 | | pos = nibbles-skip-1; |
| 562 | if (shift) { |
| 563 | pos = smart_pos(buf, |
| 564 | skip, nibbles, pos, 1); |
| 565 | } else { |
| 566 | pos += pos_step(zoom); |
| 567 | if (pos > nibbles-skip-1) |
| 568 | pos = nibbles-skip-1; |
| 569 | } |
536 | 570 | break; |
537 | 571 | case SDLK_SPACE: |
538 | 572 | if (pos == user_ref) |
... | ... | |
543 | 577 | case SDLK_RETURN: |
544 | 578 | case SDLK_q: |
545 | 579 | return; |
| 580 | case SDLK_LSHIFT: |
| 581 | case SDLK_RSHIFT: |
| 582 | continue; |
546 | 583 | default: |
547 | 584 | printf("%x\n", event.key.keysym.sym); |
548 | 585 | continue; |
Download the corresponding diff file