diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/action.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/quantum/action.c b/quantum/action.c index 395340d9d7..be85192d25 100644 --- a/quantum/action.c +++ b/quantum/action.c | |||
| @@ -47,7 +47,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 47 | int tp_buttons; | 47 | int tp_buttons; |
| 48 | 48 | ||
| 49 | #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | 49 | #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) |
| 50 | int retro_tapping_counter = 0; | 50 | bool retro_tap_primed = false; |
| 51 | uint16_t retro_tap_curr_key = 0; | ||
| 52 | # if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | ||
| 53 | uint8_t retro_tap_curr_mods = 0; | ||
| 54 | uint8_t retro_tap_next_mods = 0; | ||
| 55 | # endif | ||
| 51 | #endif | 56 | #endif |
| 52 | 57 | ||
| 53 | #if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) | 58 | #if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) |
| @@ -77,7 +82,13 @@ void action_exec(keyevent_t event) { | |||
| 77 | debug_event(event); | 82 | debug_event(event); |
| 78 | ac_dprintf("\n"); | 83 | ac_dprintf("\n"); |
| 79 | #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | 84 | #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) |
| 80 | retro_tapping_counter++; | 85 | uint16_t event_keycode = get_event_keycode(event, false); |
| 86 | if (event.pressed) { | ||
| 87 | retro_tap_primed = false; | ||
| 88 | retro_tap_curr_key = event_keycode; | ||
| 89 | } else if (retro_tap_curr_key == event_keycode) { | ||
| 90 | retro_tap_primed = true; | ||
| 91 | } | ||
| 81 | #endif | 92 | #endif |
| 82 | } | 93 | } |
| 83 | 94 | ||
| @@ -531,7 +542,8 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 531 | # if defined(RETRO_TAPPING) && defined(DUMMY_MOD_NEUTRALIZER_KEYCODE) | 542 | # if defined(RETRO_TAPPING) && defined(DUMMY_MOD_NEUTRALIZER_KEYCODE) |
| 532 | // Send a dummy keycode to neutralize flashing modifiers | 543 | // Send a dummy keycode to neutralize flashing modifiers |
| 533 | // if the key was held and then released with no interruptions. | 544 | // if the key was held and then released with no interruptions. |
| 534 | if (retro_tapping_counter == 2) { | 545 | uint16_t ev_kc = get_event_keycode(event, false); |
| 546 | if (retro_tap_primed && retro_tap_curr_key == ev_kc) { | ||
| 535 | neutralize_flashing_modifiers(get_mods()); | 547 | neutralize_flashing_modifiers(get_mods()); |
| 536 | } | 548 | } |
| 537 | # endif | 549 | # endif |
| @@ -829,30 +841,44 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 829 | 841 | ||
| 830 | #ifndef NO_ACTION_TAPPING | 842 | #ifndef NO_ACTION_TAPPING |
| 831 | # if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | 843 | # if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) |
| 832 | if (!is_tap_action(action)) { | 844 | if (is_tap_action(action)) { |
| 833 | retro_tapping_counter = 0; | ||
| 834 | } else { | ||
| 835 | if (event.pressed) { | 845 | if (event.pressed) { |
| 836 | if (tap_count > 0) { | 846 | if (tap_count > 0) { |
| 837 | retro_tapping_counter = 0; | 847 | retro_tap_primed = false; |
| 848 | } else { | ||
| 849 | # if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | ||
| 850 | retro_tap_curr_mods = retro_tap_next_mods; | ||
| 851 | retro_tap_next_mods = get_mods(); | ||
| 852 | # endif | ||
| 838 | } | 853 | } |
| 839 | } else { | 854 | } else { |
| 855 | uint16_t event_keycode = get_event_keycode(event, false); | ||
| 856 | # if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | ||
| 857 | uint8_t curr_mods = get_mods(); | ||
| 858 | # endif | ||
| 840 | if (tap_count > 0) { | 859 | if (tap_count > 0) { |
| 841 | retro_tapping_counter = 0; | 860 | retro_tap_primed = false; |
| 842 | } else { | 861 | } else if (retro_tap_curr_key == event_keycode) { |
| 843 | if ( | 862 | if ( |
| 844 | # ifdef RETRO_TAPPING_PER_KEY | 863 | # ifdef RETRO_TAPPING_PER_KEY |
| 845 | get_retro_tapping(get_event_keycode(record->event, false), record) && | 864 | get_retro_tapping(event_keycode, record) && |
| 846 | # endif | 865 | # endif |
| 847 | retro_tapping_counter == 2) { | 866 | retro_tap_primed) { |
| 848 | # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) | 867 | # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) |
| 849 | process_auto_shift(action.layer_tap.code, record); | 868 | process_auto_shift(action.layer_tap.code, record); |
| 850 | # else | 869 | # else |
| 870 | register_mods(retro_tap_curr_mods); | ||
| 871 | wait_ms(TAP_CODE_DELAY); | ||
| 851 | tap_code(action.layer_tap.code); | 872 | tap_code(action.layer_tap.code); |
| 873 | wait_ms(TAP_CODE_DELAY); | ||
| 874 | unregister_mods(retro_tap_curr_mods); | ||
| 852 | # endif | 875 | # endif |
| 853 | } | 876 | } |
| 854 | retro_tapping_counter = 0; | 877 | retro_tap_primed = false; |
| 855 | } | 878 | } |
| 879 | # if !(defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) | ||
| 880 | retro_tap_next_mods = curr_mods; | ||
| 881 | # endif | ||
| 856 | } | 882 | } |
| 857 | } | 883 | } |
| 858 | # endif | 884 | # endif |
