diff options
| author | tmk <nobody@nowhere> | 2013-10-02 17:49:25 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-10-03 12:40:33 +0900 |
| commit | 8819cf6bb1da487de9bef9b01ee434fbdf710d4d (patch) | |
| tree | cd15000fb03aaef3d4e83095c87061c1794da1c2 /common/action_tapping.c | |
| parent | a0f9c1fb4fc86c37353b5298c7a4d8d68b368d8c (diff) | |
| download | qmk_firmware-8819cf6bb1da487de9bef9b01ee434fbdf710d4d.tar.gz qmk_firmware-8819cf6bb1da487de9bef9b01ee434fbdf710d4d.zip | |
Fix Tapping: release key immediately but modifier #65
- See https://github.com/tmk/tmk_keyboard/issues/60
- **Except for modifiers** a key pressed before the tapping starts should be released immediately
- 'Mod-Tap key'(like shift-;) didn't work from this fix: 4d0b3aa Fix Tapping: release of a key pressed before tap
This key sequence should register ':', not ';'. With the fix Shift is
released before settlement of tapping, this registers ';'.
Shift ~~___~~~~~~~
;(Tap) ~~~____~~~~
Diffstat (limited to 'common/action_tapping.c')
| -rw-r--r-- | common/action_tapping.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/common/action_tapping.c b/common/action_tapping.c index 542949ddd..826c23309 100644 --- a/common/action_tapping.c +++ b/common/action_tapping.c | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | #include <stdint.h> | 1 | #include <stdint.h> |
| 2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
| 3 | #include "action.h" | 3 | #include "action.h" |
| 4 | #include "action_layer.h" | ||
| 4 | #include "action_tapping.h" | 5 | #include "action_tapping.h" |
| 6 | #include "keycode.h" | ||
| 5 | #include "timer.h" | 7 | #include "timer.h" |
| 6 | 8 | ||
| 7 | #ifdef DEBUG_ACTION | 9 | #ifdef DEBUG_ACTION |
| @@ -95,22 +97,40 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 95 | return false; | 97 | return false; |
| 96 | } | 98 | } |
| 97 | #if TAPPING_TERM >= 500 | 99 | #if TAPPING_TERM >= 500 |
| 98 | /* This can settle mod/fn state fast but may prevent from typing fast. */ | 100 | /* Process a key typed within TAPPING_TERM |
| 99 | else if (!event.pressed && waiting_buffer_typed(event)) { | 101 | * This can register the key before settlement of tapping, |
| 100 | // other key typed. not tap. | 102 | * useful for long TAPPING_TERM but may prevent fast typing. |
| 103 | */ | ||
| 104 | else if (IS_RELEASED(event) && waiting_buffer_typed(event)) { | ||
| 101 | debug("Tapping: End. No tap. Interfered by typing key\n"); | 105 | debug("Tapping: End. No tap. Interfered by typing key\n"); |
| 102 | process_action(&tapping_key); | 106 | process_action(&tapping_key); |
| 103 | tapping_key = (keyrecord_t){}; | 107 | tapping_key = (keyrecord_t){}; |
| 104 | debug_tapping_key(); | 108 | debug_tapping_key(); |
| 105 | |||
| 106 | // enqueue | 109 | // enqueue |
| 107 | return false; | 110 | return false; |
| 108 | } | 111 | } |
| 109 | #endif | 112 | #endif |
| 110 | /* release a key pressed before tapping */ | 113 | /* Process release event of a key pressed before tapping starts |
| 111 | else if (!event.pressed && !waiting_buffer_typed(event)) { | 114 | * Without this unexpected repeating will occur with having fast repeating setting |
| 112 | /* Unexpected repeating occurs unless this event is processed immedately. */ | 115 | * https://github.com/tmk/tmk_keyboard/issues/60 |
| 113 | debug("Tapping: release a key pressed before tapping\n"); | 116 | */ |
| 117 | else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) { | ||
| 118 | // Modifier should be retained till end of this tapping. | ||
| 119 | action_t action = layer_switch_get_action(event.key); | ||
| 120 | switch (action.kind.id) { | ||
| 121 | case ACT_LMODS: | ||
| 122 | case ACT_RMODS: | ||
| 123 | if (action.key.mods && !action.key.code) return false; | ||
| 124 | if (IS_MOD(action.key.code)) return false; | ||
| 125 | break; | ||
| 126 | case ACT_LMODS_TAP: | ||
| 127 | case ACT_RMODS_TAP: | ||
| 128 | if (action.key.mods && keyp->tap.count == 0) return false; | ||
| 129 | if (IS_MOD(action.key.code)) return false; | ||
| 130 | break; | ||
| 131 | } | ||
| 132 | // Release of key should be process immediately. | ||
| 133 | debug("Tapping: release event of a key pressed before tapping\n"); | ||
| 114 | process_action(keyp); | 134 | process_action(keyp); |
| 115 | return true; | 135 | return true; |
| 116 | } | 136 | } |
