diff options
author | Bad Diode <bd@badd10de.dev> | 2024-01-08 15:32:13 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-01-08 15:32:13 +0100 |
commit | be37f274be067e92f9240112b7a047b8ef9e09b0 (patch) | |
tree | fb5a45cd6f605e607c5bd8e7e5a4127b95230976 | |
parent | 2eb3cfba2bdd569ffeaf94e6e29faac9a83b5b77 (diff) | |
download | stepper-be37f274be067e92f9240112b7a047b8ef9e09b0.tar.gz stepper-be37f274be067e92f9240112b7a047b8ef9e09b0.zip |
Add input retriggering with configurable rate and offset
-rw-r--r-- | src/gba/gba.h | 111 | ||||
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/sequencer.c | 80 | ||||
-rw-r--r-- | src/settings.c | 8 |
4 files changed, 157 insertions, 45 deletions
diff --git a/src/gba/gba.h b/src/gba/gba.h index 8ba3de5..b5868f0 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h | |||
@@ -327,6 +327,117 @@ key_hold(u32 key) { | |||
327 | return key_curr & key_prev & key; | 327 | return key_curr & key_prev & key; |
328 | } | 328 | } |
329 | 329 | ||
330 | // Stores number of frames since a keay was pressed. | ||
331 | typedef struct Controller { | ||
332 | int key_up; | ||
333 | int key_down; | ||
334 | int key_left; | ||
335 | int key_right; | ||
336 | int key_select; | ||
337 | int key_start; | ||
338 | int key_b; | ||
339 | int key_a; | ||
340 | int key_l; | ||
341 | int key_r; | ||
342 | } Controller; | ||
343 | |||
344 | static Controller ctrl = {0}; | ||
345 | |||
346 | #define RETRIG_OFFSET 16 | ||
347 | #define RETRIG_FRAMES 3 | ||
348 | |||
349 | static inline | ||
350 | bool | ||
351 | _key_retrig(int key, int offset, int frames) { | ||
352 | if (key_tap(key)) { | ||
353 | return true; | ||
354 | } | ||
355 | switch (key) { | ||
356 | case KEY_L: { | ||
357 | if (key_hold(key)) { | ||
358 | if (ctrl.key_l < offset) { return false; } | ||
359 | if (ctrl.key_l % frames == 0) { return true; } | ||
360 | } | ||
361 | } break; | ||
362 | case KEY_R: { | ||
363 | if (key_hold(key)) { | ||
364 | if (ctrl.key_r < offset) { return false; } | ||
365 | if (ctrl.key_r % frames == 0) { return true; } | ||
366 | } | ||
367 | } break; | ||
368 | case KEY_A: { | ||
369 | if (key_hold(key)) { | ||
370 | if (ctrl.key_a < offset) { return false; } | ||
371 | if (ctrl.key_a % frames == 0) { return true; } | ||
372 | } | ||
373 | } break; | ||
374 | case KEY_B: { | ||
375 | if (key_hold(key)) { | ||
376 | if (ctrl.key_b < offset) { return false; } | ||
377 | if (ctrl.key_b % frames == 0) { return true; } | ||
378 | } | ||
379 | } break; | ||
380 | case KEY_SELECT: { | ||
381 | if (key_hold(key)) { | ||
382 | if (ctrl.key_select < offset) { return false; } | ||
383 | if (ctrl.key_select % frames == 0) { return true; } | ||
384 | } | ||
385 | } break; | ||
386 | case KEY_START: { | ||
387 | if (key_hold(key)) { | ||
388 | if (ctrl.key_start < offset) { return false; } | ||
389 | if (ctrl.key_start % frames == 0) { return true; } | ||
390 | } | ||
391 | } break; | ||
392 | case KEY_UP: { | ||
393 | if (key_hold(key)) { | ||
394 | if (ctrl.key_up < offset) { return false; } | ||
395 | if (ctrl.key_up % frames == 0) { return true; } | ||
396 | } | ||
397 | } break; | ||
398 | case KEY_DOWN: { | ||
399 | if (key_hold(key)) { | ||
400 | if (ctrl.key_down < offset) { return false; } | ||
401 | if (ctrl.key_down % frames == 0) { return true; } | ||
402 | } | ||
403 | } break; | ||
404 | case KEY_LEFT: { | ||
405 | if (key_hold(key)) { | ||
406 | if (ctrl.key_left < offset) { return false; } | ||
407 | if (ctrl.key_left % frames == 0) { return true; } | ||
408 | } | ||
409 | } break; | ||
410 | case KEY_RIGHT: { | ||
411 | if (key_hold(key)) { | ||
412 | if (ctrl.key_right < offset) { return false; } | ||
413 | if (ctrl.key_right % frames == 0) { return true; } | ||
414 | } | ||
415 | } break; | ||
416 | } | ||
417 | return false; | ||
418 | } | ||
419 | |||
420 | static inline | ||
421 | bool | ||
422 | key_retrig(int key) { | ||
423 | return _key_retrig(key, RETRIG_OFFSET, RETRIG_FRAMES); | ||
424 | } | ||
425 | |||
426 | static inline | ||
427 | void | ||
428 | update_controller(void) { | ||
429 | if (key_pressed(KEY_UP)) { ctrl.key_up++; } else if (key_released(KEY_UP)) { ctrl.key_up = 0; } | ||
430 | if (key_pressed(KEY_DOWN)) { ctrl.key_down++; } else if (key_released(KEY_DOWN)) { ctrl.key_down = 0; } | ||
431 | if (key_pressed(KEY_LEFT)) { ctrl.key_left++; } else if (key_released(KEY_LEFT)) { ctrl.key_left = 0; } | ||
432 | if (key_pressed(KEY_RIGHT)) { ctrl.key_right++; } else if (key_released(KEY_RIGHT)) { ctrl.key_right = 0; } | ||
433 | if (key_pressed(KEY_L)) { ctrl.key_l++; } else if (key_released(KEY_L)) { ctrl.key_l = 0; } | ||
434 | if (key_pressed(KEY_R)) { ctrl.key_r++; } else if (key_released(KEY_R)) { ctrl.key_r = 0; } | ||
435 | if (key_pressed(KEY_A)) { ctrl.key_a++; } else if (key_released(KEY_A)) { ctrl.key_a = 0; } | ||
436 | if (key_pressed(KEY_B)) { ctrl.key_b++; } else if (key_released(KEY_B)) { ctrl.key_b = 0; } | ||
437 | if (key_pressed(KEY_SELECT)) { ctrl.key_select++; } else if (key_released(KEY_SELECT)) { ctrl.key_select = 0; } | ||
438 | if (key_pressed(KEY_START)) { ctrl.key_start++; } else if (key_released(KEY_START)) { ctrl.key_start = 0; } | ||
439 | } | ||
440 | |||
330 | // | 441 | // |
331 | // Direct Memory Access (DMA) | 442 | // Direct Memory Access (DMA) |
332 | // | 443 | // |
@@ -24,7 +24,7 @@ WITH REGARD TO THIS SOFTWARE. | |||
24 | // + Fix scale being active for noise channel (makes no sense) | 24 | // + Fix scale being active for noise channel (makes no sense) |
25 | // + Save scale on metadata | 25 | // + Save scale on metadata |
26 | // + Allow using B + dpad to nudge trigs. This will potentially mean switching | 26 | // + Allow using B + dpad to nudge trigs. This will potentially mean switching |
27 | // - Hold L/R retriggers at short intervals? | 27 | // + Hold L/R retriggers at short intervals? |
28 | // to key release to enable trigs. | 28 | // to key release to enable trigs. |
29 | // - Fix any bugs we currently have | 29 | // - Fix any bugs we currently have |
30 | // - Add an envelope to ch3, would need to work with a timer in order to make | 30 | // - Add an envelope to ch3, would need to work with a timer in order to make |
@@ -192,6 +192,7 @@ handle_input(void) { | |||
192 | 192 | ||
193 | void | 193 | void |
194 | update(void) { | 194 | update(void) { |
195 | update_controller(); | ||
195 | if (next_scene != scene) { | 196 | if (next_scene != scene) { |
196 | scene = next_scene; | 197 | scene = next_scene; |
197 | clear_screen = true; | 198 | clear_screen = true; |
diff --git a/src/sequencer.c b/src/sequencer.c index a032481..3433da1 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -442,7 +442,7 @@ handle_channel_selection(void) { | |||
442 | } | 442 | } |
443 | } | 443 | } |
444 | redraw_params = true; | 444 | redraw_params = true; |
445 | } else if (key_tap(KEY_L)) { | 445 | } else if (key_retrig(KEY_L)) { |
446 | s32 inc = -1; | 446 | s32 inc = -1; |
447 | if (key_hold(KEY_SELECT)) { | 447 | if (key_hold(KEY_SELECT)) { |
448 | inc = -12; | 448 | inc = -12; |
@@ -466,7 +466,7 @@ handle_channel_selection(void) { | |||
466 | } | 466 | } |
467 | } | 467 | } |
468 | redraw_trigs = true; | 468 | redraw_trigs = true; |
469 | } else if (key_tap(KEY_R)) { | 469 | } else if (key_retrig(KEY_R)) { |
470 | s32 inc = 1; | 470 | s32 inc = 1; |
471 | if (key_hold(KEY_SELECT)) { | 471 | if (key_hold(KEY_SELECT)) { |
472 | inc = 12; | 472 | inc = 12; |
@@ -491,16 +491,16 @@ handle_channel_selection(void) { | |||
491 | } | 491 | } |
492 | redraw_trigs = true; | 492 | redraw_trigs = true; |
493 | } | 493 | } |
494 | if (key_tap(KEY_RIGHT)) { | 494 | if (key_retrig(KEY_RIGHT)) { |
495 | trig_selection_loc = 0; | 495 | trig_selection_loc = 0; |
496 | param_selection_loc = 0; | 496 | param_selection_loc = 0; |
497 | input_handler = handle_trigger_selection; | 497 | input_handler = handle_trigger_selection; |
498 | redraw_params = true; | 498 | redraw_params = true; |
499 | } else if (key_tap(KEY_LEFT)) { | 499 | } else if (key_retrig(KEY_LEFT)) { |
500 | input_handler = handle_pattern_selection; | 500 | input_handler = handle_pattern_selection; |
501 | param_selection_loc = 0; | 501 | param_selection_loc = 0; |
502 | redraw_params = true; | 502 | redraw_params = true; |
503 | } else if (key_tap(KEY_UP)) { | 503 | } else if (key_retrig(KEY_UP)) { |
504 | if (channel_selection_loc == 0) { | 504 | if (channel_selection_loc == 0) { |
505 | channel_selection_loc = SEQ_N_CHANNELS - 1; | 505 | channel_selection_loc = SEQ_N_CHANNELS - 1; |
506 | } else { | 506 | } else { |
@@ -509,7 +509,7 @@ handle_channel_selection(void) { | |||
509 | param_selection_loc = 0; | 509 | param_selection_loc = 0; |
510 | redraw_trigs = true; | 510 | redraw_trigs = true; |
511 | redraw_params = true; | 511 | redraw_params = true; |
512 | } else if (key_tap(KEY_DOWN)) { | 512 | } else if (key_retrig(KEY_DOWN)) { |
513 | if (channel_selection_loc == SEQ_N_CHANNELS - 1) { | 513 | if (channel_selection_loc == SEQ_N_CHANNELS - 1) { |
514 | channel_selection_loc = 0; | 514 | channel_selection_loc = 0; |
515 | } else { | 515 | } else { |
@@ -601,7 +601,7 @@ toggle_playing(void) { | |||
601 | 601 | ||
602 | void | 602 | void |
603 | handle_right_col_selection(void) { | 603 | handle_right_col_selection(void) { |
604 | if (key_tap(KEY_LEFT)) { | 604 | if (key_retrig(KEY_LEFT)) { |
605 | switch (right_col_selection_loc) { | 605 | switch (right_col_selection_loc) { |
606 | case R_COL_STOP: | 606 | case R_COL_STOP: |
607 | case R_COL_BANK_B: | 607 | case R_COL_BANK_B: |
@@ -624,7 +624,7 @@ handle_right_col_selection(void) { | |||
624 | } else { | 624 | } else { |
625 | trig_selection_loc = 7; | 625 | trig_selection_loc = 7; |
626 | } | 626 | } |
627 | } else if (key_tap(KEY_RIGHT)) { | 627 | } else if (key_retrig(KEY_RIGHT)) { |
628 | switch (right_col_selection_loc) { | 628 | switch (right_col_selection_loc) { |
629 | case R_COL_PLAY: | 629 | case R_COL_PLAY: |
630 | case R_COL_BANK_A: | 630 | case R_COL_BANK_A: |
@@ -638,7 +638,7 @@ handle_right_col_selection(void) { | |||
638 | case R_COL_SETTINGS: | 638 | case R_COL_SETTINGS: |
639 | case R_COL_STOP: { input_handler = handle_pattern_selection; } break; | 639 | case R_COL_STOP: { input_handler = handle_pattern_selection; } break; |
640 | } | 640 | } |
641 | } else if (key_tap(KEY_UP)) { | 641 | } else if (key_retrig(KEY_UP)) { |
642 | switch (right_col_selection_loc) { | 642 | switch (right_col_selection_loc) { |
643 | case R_COL_BANK_A: { right_col_selection_loc = R_COL_PLAY; } break; | 643 | case R_COL_BANK_A: { right_col_selection_loc = R_COL_PLAY; } break; |
644 | case R_COL_BANK_B: { right_col_selection_loc = R_COL_STOP; } break; | 644 | case R_COL_BANK_B: { right_col_selection_loc = R_COL_STOP; } break; |
@@ -650,7 +650,7 @@ handle_right_col_selection(void) { | |||
650 | case R_COL_SCALE: { right_col_selection_loc -= 2; } break; | 650 | case R_COL_SCALE: { right_col_selection_loc -= 2; } break; |
651 | default: { right_col_selection_loc--; } break; | 651 | default: { right_col_selection_loc--; } break; |
652 | } | 652 | } |
653 | } else if (key_tap(KEY_DOWN)) { | 653 | } else if (key_retrig(KEY_DOWN)) { |
654 | switch (right_col_selection_loc) { | 654 | switch (right_col_selection_loc) { |
655 | case R_COL_BANK_A: | 655 | case R_COL_BANK_A: |
656 | case R_COL_BANK_B: | 656 | case R_COL_BANK_B: |
@@ -661,7 +661,7 @@ handle_right_col_selection(void) { | |||
661 | case R_COL_STOP: { right_col_selection_loc = R_COL_BANK_B; } break; | 661 | case R_COL_STOP: { right_col_selection_loc = R_COL_BANK_B; } break; |
662 | default: { right_col_selection_loc++; } break; | 662 | default: { right_col_selection_loc++; } break; |
663 | } | 663 | } |
664 | } else if (key_tap(KEY_L)) { | 664 | } else if (key_retrig(KEY_L)) { |
665 | switch (right_col_selection_loc) { | 665 | switch (right_col_selection_loc) { |
666 | case R_COL_BPM: { | 666 | case R_COL_BPM: { |
667 | s32 bpm_inc = -1; | 667 | s32 bpm_inc = -1; |
@@ -701,7 +701,7 @@ handle_right_col_selection(void) { | |||
701 | } | 701 | } |
702 | } break; | 702 | } break; |
703 | } | 703 | } |
704 | } else if (key_tap(KEY_R)) { | 704 | } else if (key_retrig(KEY_R)) { |
705 | switch (right_col_selection_loc) { | 705 | switch (right_col_selection_loc) { |
706 | case R_COL_BPM: { | 706 | case R_COL_BPM: { |
707 | s32 bpm_inc = 1; | 707 | s32 bpm_inc = 1; |
@@ -759,7 +759,7 @@ handle_pattern_chain(void) { | |||
759 | static int previous_loc = 0; | 759 | static int previous_loc = 0; |
760 | if (key_tap(KEY_A)) { | 760 | if (key_tap(KEY_A)) { |
761 | input_handler = handle_pattern_selection; | 761 | input_handler = handle_pattern_selection; |
762 | } else if (key_tap(KEY_LEFT)) { | 762 | } else if (key_retrig(KEY_LEFT)) { |
763 | if (param_selection_loc == 8) { | 763 | if (param_selection_loc == 8) { |
764 | param_selection_loc = 15; | 764 | param_selection_loc = 15; |
765 | } else if (param_selection_loc == 16) { | 765 | } else if (param_selection_loc == 16) { |
@@ -769,7 +769,7 @@ handle_pattern_chain(void) { | |||
769 | } else if (param_selection_loc == 0) { | 769 | } else if (param_selection_loc == 0) { |
770 | param_selection_loc = 7; | 770 | param_selection_loc = 7; |
771 | } | 771 | } |
772 | } else if (key_tap(KEY_RIGHT)) { | 772 | } else if (key_retrig(KEY_RIGHT)) { |
773 | if (param_selection_loc < 15 && param_selection_loc != 7) { | 773 | if (param_selection_loc < 15 && param_selection_loc != 7) { |
774 | param_selection_loc++; | 774 | param_selection_loc++; |
775 | } else if (param_selection_loc < 18 && param_selection_loc >= 16) { | 775 | } else if (param_selection_loc < 18 && param_selection_loc >= 16) { |
@@ -885,14 +885,14 @@ handle_pattern_chain(void) { | |||
885 | } | 885 | } |
886 | } break; | 886 | } break; |
887 | } | 887 | } |
888 | } else if (key_tap(KEY_L)) { | 888 | } else if (key_retrig(KEY_L)) { |
889 | if (chain.active[param_selection_loc] | 889 | if (chain.active[param_selection_loc] |
890 | && chain.chain[param_selection_loc] > 0 | 890 | && chain.chain[param_selection_loc] > 0 |
891 | && param_selection_loc <= 15 | 891 | && param_selection_loc <= 15 |
892 | && (!play_status || param_selection_loc != chain.current)) { | 892 | && (!play_status || param_selection_loc != chain.current)) { |
893 | chain.chain[param_selection_loc]--; | 893 | chain.chain[param_selection_loc]--; |
894 | } | 894 | } |
895 | } else if (key_tap(KEY_R)) { | 895 | } else if (key_retrig(KEY_R)) { |
896 | if (chain.active[param_selection_loc] | 896 | if (chain.active[param_selection_loc] |
897 | && chain.chain[param_selection_loc] < 7 | 897 | && chain.chain[param_selection_loc] < 7 |
898 | && param_selection_loc <= 15 | 898 | && param_selection_loc <= 15 |
@@ -934,11 +934,11 @@ handle_pattern_selection(void) { | |||
934 | if (key_tap(KEY_A)) { | 934 | if (key_tap(KEY_A)) { |
935 | input_handler = handle_pattern_chain; | 935 | input_handler = handle_pattern_chain; |
936 | } | 936 | } |
937 | if (key_tap(KEY_RIGHT)) { | 937 | if (key_retrig(KEY_RIGHT)) { |
938 | param_selection_loc = 0; | 938 | param_selection_loc = 0; |
939 | input_handler = handle_channel_selection; | 939 | input_handler = handle_channel_selection; |
940 | redraw_params = true; | 940 | redraw_params = true; |
941 | } else if (key_tap(KEY_UP)) { | 941 | } else if (key_retrig(KEY_UP)) { |
942 | if (pattern_selection_loc > 0) { | 942 | if (pattern_selection_loc > 0) { |
943 | pattern_selection_loc = pattern_selection_loc - 1; | 943 | pattern_selection_loc = pattern_selection_loc - 1; |
944 | } else { | 944 | } else { |
@@ -947,7 +947,7 @@ handle_pattern_selection(void) { | |||
947 | redraw_channels = true; | 947 | redraw_channels = true; |
948 | redraw_trigs = true; | 948 | redraw_trigs = true; |
949 | redraw_bpm = true; | 949 | redraw_bpm = true; |
950 | } else if (key_tap(KEY_DOWN)) { | 950 | } else if (key_retrig(KEY_DOWN)) { |
951 | if (pattern_selection_loc < 7) { | 951 | if (pattern_selection_loc < 7) { |
952 | pattern_selection_loc = pattern_selection_loc + 1; | 952 | pattern_selection_loc = pattern_selection_loc + 1; |
953 | } else { | 953 | } else { |
@@ -957,7 +957,7 @@ handle_pattern_selection(void) { | |||
957 | redraw_trigs = true; | 957 | redraw_trigs = true; |
958 | redraw_bpm = true; | 958 | redraw_bpm = true; |
959 | } | 959 | } |
960 | if (key_tap(KEY_LEFT)) { | 960 | if (key_retrig(KEY_LEFT)) { |
961 | redraw_params = true; | 961 | redraw_params = true; |
962 | input_handler = handle_right_col_selection; | 962 | input_handler = handle_right_col_selection; |
963 | param_selection_loc = 0; | 963 | param_selection_loc = 0; |
@@ -1032,8 +1032,8 @@ set_param_selection_sq1(ChannelSquareParams *params, InputHandler return_handler | |||
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | // Cursor movement. | 1034 | // Cursor movement. |
1035 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 1035 | if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) { |
1036 | if (key_tap(KEY_RIGHT)) { | 1036 | if (key_retrig(KEY_RIGHT)) { |
1037 | if (param_selection_loc == 4) { | 1037 | if (param_selection_loc == 4) { |
1038 | param_selection_loc = 0; | 1038 | param_selection_loc = 0; |
1039 | } else if (param_selection_loc == 9) { | 1039 | } else if (param_selection_loc == 9) { |
@@ -1073,9 +1073,9 @@ set_param_selection_sq1(ChannelSquareParams *params, InputHandler return_handler | |||
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | // Adjust parameter. | 1075 | // Adjust parameter. |
1076 | if (key_tap(KEY_R) || key_tap(KEY_L)) { | 1076 | if (key_retrig(KEY_R) || key_retrig(KEY_L)) { |
1077 | int inc; | 1077 | int inc; |
1078 | if (key_tap(KEY_L)) { | 1078 | if (key_retrig(KEY_L)) { |
1079 | inc = -1; | 1079 | inc = -1; |
1080 | } else { | 1080 | } else { |
1081 | inc = 1; | 1081 | inc = 1; |
@@ -1116,8 +1116,8 @@ set_param_selection_sq2(ChannelSquareParams *params, InputHandler return_handler | |||
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | // Cursor movement. | 1118 | // Cursor movement. |
1119 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 1119 | if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) { |
1120 | if (key_tap(KEY_RIGHT)) { | 1120 | if (key_retrig(KEY_RIGHT)) { |
1121 | if (param_selection_loc == 4) { | 1121 | if (param_selection_loc == 4) { |
1122 | param_selection_loc = 0; | 1122 | param_selection_loc = 0; |
1123 | } else if (param_selection_loc == 7) { | 1123 | } else if (param_selection_loc == 7) { |
@@ -1149,9 +1149,9 @@ set_param_selection_sq2(ChannelSquareParams *params, InputHandler return_handler | |||
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | // Adjust parameter. | 1151 | // Adjust parameter. |
1152 | if (key_tap(KEY_R) || key_tap(KEY_L)) { | 1152 | if (key_retrig(KEY_R) || key_retrig(KEY_L)) { |
1153 | int inc; | 1153 | int inc; |
1154 | if (key_tap(KEY_L)) { | 1154 | if (key_retrig(KEY_L)) { |
1155 | inc = -1; | 1155 | inc = -1; |
1156 | } else { | 1156 | } else { |
1157 | inc = 1; | 1157 | inc = 1; |
@@ -1189,8 +1189,8 @@ set_param_selection_wave(ChannelWaveParams *params, InputHandler return_handler) | |||
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | // Cursor movement. | 1191 | // Cursor movement. |
1192 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 1192 | if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) { |
1193 | if (key_tap(KEY_RIGHT)) { | 1193 | if (key_retrig(KEY_RIGHT)) { |
1194 | if (param_selection_loc == 4) { | 1194 | if (param_selection_loc == 4) { |
1195 | param_selection_loc = 0; | 1195 | param_selection_loc = 0; |
1196 | } else if (param_selection_loc == 6) { | 1196 | } else if (param_selection_loc == 6) { |
@@ -1230,9 +1230,9 @@ set_param_selection_wave(ChannelWaveParams *params, InputHandler return_handler) | |||
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | // Adjust parameter. | 1232 | // Adjust parameter. |
1233 | if (key_tap(KEY_R) || key_tap(KEY_L)) { | 1233 | if (key_retrig(KEY_R) || key_retrig(KEY_L)) { |
1234 | int inc; | 1234 | int inc; |
1235 | if (key_tap(KEY_L)) { | 1235 | if (key_retrig(KEY_L)) { |
1236 | inc = -1; | 1236 | inc = -1; |
1237 | } else { | 1237 | } else { |
1238 | inc = 1; | 1238 | inc = 1; |
@@ -1264,8 +1264,8 @@ set_param_selection_noise(ChannelNoiseParams *params, InputHandler return_handle | |||
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | // Cursor movement. | 1266 | // Cursor movement. |
1267 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 1267 | if (key_retrig(KEY_LEFT) || key_retrig(KEY_RIGHT)) { |
1268 | if (key_tap(KEY_RIGHT)) { | 1268 | if (key_retrig(KEY_RIGHT)) { |
1269 | if (param_selection_loc == 4) { | 1269 | if (param_selection_loc == 4) { |
1270 | param_selection_loc = 0; | 1270 | param_selection_loc = 0; |
1271 | } else if (param_selection_loc == 7) { | 1271 | } else if (param_selection_loc == 7) { |
@@ -1297,9 +1297,9 @@ set_param_selection_noise(ChannelNoiseParams *params, InputHandler return_handle | |||
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | // Adjust parameter. | 1299 | // Adjust parameter. |
1300 | if (key_tap(KEY_R) || key_tap(KEY_L)) { | 1300 | if (key_retrig(KEY_R) || key_retrig(KEY_L)) { |
1301 | int inc; | 1301 | int inc; |
1302 | if (key_tap(KEY_L)) { | 1302 | if (key_retrig(KEY_L)) { |
1303 | inc = -1; | 1303 | inc = -1; |
1304 | } else { | 1304 | } else { |
1305 | inc = 1; | 1305 | inc = 1; |
@@ -1547,7 +1547,7 @@ handle_trigger_selection(void) { | |||
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | redraw_trigs = true; | 1549 | redraw_trigs = true; |
1550 | } else if (key_tap(KEY_L)) { | 1550 | } else if (key_retrig(KEY_L)) { |
1551 | s32 inc = -1; | 1551 | s32 inc = -1; |
1552 | if (key_hold(KEY_SELECT)) { | 1552 | if (key_hold(KEY_SELECT)) { |
1553 | inc = -12; | 1553 | inc = -12; |
@@ -1564,7 +1564,7 @@ handle_trigger_selection(void) { | |||
1564 | } | 1564 | } |
1565 | } | 1565 | } |
1566 | redraw_trigs = true; | 1566 | redraw_trigs = true; |
1567 | } else if (key_tap(KEY_R)) { | 1567 | } else if (key_retrig(KEY_R)) { |
1568 | s32 inc = 1; | 1568 | s32 inc = 1; |
1569 | if (key_hold(KEY_SELECT)) { | 1569 | if (key_hold(KEY_SELECT)) { |
1570 | inc = 12; | 1570 | inc = 12; |
@@ -1584,7 +1584,7 @@ handle_trigger_selection(void) { | |||
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | // Move trigger cursor. | 1586 | // Move trigger cursor. |
1587 | if (key_tap(KEY_LEFT)) { | 1587 | if (key_retrig(KEY_LEFT)) { |
1588 | if (key_hold(KEY_B)) { | 1588 | if (key_hold(KEY_B)) { |
1589 | if (trig_selection_loc != 0 && trig_selection_loc != 8) { | 1589 | if (trig_selection_loc != 0 && trig_selection_loc != 8) { |
1590 | int next_selection_loc = MAX(trig_selection_loc - 1, 0); | 1590 | int next_selection_loc = MAX(trig_selection_loc - 1, 0); |
@@ -1602,7 +1602,7 @@ handle_trigger_selection(void) { | |||
1602 | } | 1602 | } |
1603 | } | 1603 | } |
1604 | redraw_params = true; | 1604 | redraw_params = true; |
1605 | } else if (key_tap(KEY_RIGHT)) { | 1605 | } else if (key_retrig(KEY_RIGHT)) { |
1606 | if (key_hold(KEY_B)) { | 1606 | if (key_hold(KEY_B)) { |
1607 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { | 1607 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { |
1608 | int next_selection_loc = MIN(trig_selection_loc + 1, 15); | 1608 | int next_selection_loc = MIN(trig_selection_loc + 1, 15); |
diff --git a/src/settings.c b/src/settings.c index 7e86be7..9fc2f3d 100644 --- a/src/settings.c +++ b/src/settings.c | |||
@@ -70,7 +70,7 @@ set_audio_settings(void) { | |||
70 | 70 | ||
71 | void | 71 | void |
72 | handle_settings_input(void) { | 72 | handle_settings_input(void) { |
73 | if (key_tap(KEY_DOWN)) { | 73 | if (key_retrig(KEY_DOWN)) { |
74 | if (settings_cursor_loc == (SETTINGS_NUM - 1)) { | 74 | if (settings_cursor_loc == (SETTINGS_NUM - 1)) { |
75 | settings_cursor_loc = 0; | 75 | settings_cursor_loc = 0; |
76 | } else { | 76 | } else { |
@@ -78,7 +78,7 @@ handle_settings_input(void) { | |||
78 | } | 78 | } |
79 | clear_screen = true; | 79 | clear_screen = true; |
80 | } | 80 | } |
81 | if (key_tap(KEY_UP)) { | 81 | if (key_retrig(KEY_UP)) { |
82 | if (settings_cursor_loc == 0) { | 82 | if (settings_cursor_loc == 0) { |
83 | settings_cursor_loc = SETTINGS_NUM - 1; | 83 | settings_cursor_loc = SETTINGS_NUM - 1; |
84 | } else { | 84 | } else { |
@@ -86,7 +86,7 @@ handle_settings_input(void) { | |||
86 | } | 86 | } |
87 | clear_screen = true; | 87 | clear_screen = true; |
88 | } | 88 | } |
89 | if (key_tap(KEY_R)) { | 89 | if (key_retrig(KEY_R)) { |
90 | switch (settings_cursor_loc) { | 90 | switch (settings_cursor_loc) { |
91 | case SETTINGS_SYNC: { | 91 | case SETTINGS_SYNC: { |
92 | if ((settings.sync + 1) >= SYNC_NUM) { | 92 | if ((settings.sync + 1) >= SYNC_NUM) { |
@@ -142,7 +142,7 @@ handle_settings_input(void) { | |||
142 | save_metadata(); | 142 | save_metadata(); |
143 | clear_screen = true; | 143 | clear_screen = true; |
144 | } | 144 | } |
145 | if (key_tap(KEY_L)) { | 145 | if (key_retrig(KEY_L)) { |
146 | switch (settings_cursor_loc) { | 146 | switch (settings_cursor_loc) { |
147 | case SETTINGS_SYNC: { | 147 | case SETTINGS_SYNC: { |
148 | if (settings.sync == 0) { | 148 | if (settings.sync == 0) { |