diff options
| -rw-r--r-- | quantum/quantum.c | 13 | ||||
| -rw-r--r-- | quantum/quantum.h | 4 | ||||
| -rw-r--r-- | tmk_core/common/action.c | 2 | ||||
| -rw-r--r-- | tmk_core/common/action_tapping.c | 8 | ||||
| -rw-r--r-- | tmk_core/common/action_tapping.h | 2 |
5 files changed, 16 insertions, 13 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 76a48cc77..2053a1a5f 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -149,18 +149,21 @@ void reset_keyboard(void) { | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | /* Convert record into usable keycode via the contained event. */ | 151 | /* Convert record into usable keycode via the contained event. */ |
| 152 | uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); } | 152 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { return get_event_keycode(record->event, update_layer_cache); } |
| 153 | 153 | ||
| 154 | /* Convert event into usable keycode. Checks the layer cache to ensure that it | 154 | /* Convert event into usable keycode. Checks the layer cache to ensure that it |
| 155 | * retains the correct keycode after a layer change, if the key is still pressed. | 155 | * retains the correct keycode after a layer change, if the key is still pressed. |
| 156 | * "update_layer_cache" is to ensure that it only updates the layer cache when | ||
| 157 | * appropriate, otherwise, it will update it and cause layer tap (and other keys) | ||
| 158 | * from triggering properly. | ||
| 156 | */ | 159 | */ |
| 157 | uint16_t get_event_keycode(keyevent_t event) { | 160 | uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) { |
| 158 | #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) | 161 | #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) |
| 159 | /* TODO: Use store_or_get_action() or a similar function. */ | 162 | /* TODO: Use store_or_get_action() or a similar function. */ |
| 160 | if (!disable_action_cache) { | 163 | if (!disable_action_cache) { |
| 161 | uint8_t layer; | 164 | uint8_t layer; |
| 162 | 165 | ||
| 163 | if (event.pressed) { | 166 | if (event.pressed && update_layer_cache) { |
| 164 | layer = layer_switch_get_layer(event.key); | 167 | layer = layer_switch_get_layer(event.key); |
| 165 | update_source_layers_cache(event.key, layer); | 168 | update_source_layers_cache(event.key, layer); |
| 166 | } else { | 169 | } else { |
| @@ -174,7 +177,7 @@ uint16_t get_event_keycode(keyevent_t event) { | |||
| 174 | 177 | ||
| 175 | /* Get keycode, and then call keyboard function */ | 178 | /* Get keycode, and then call keyboard function */ |
| 176 | void post_process_record_quantum(keyrecord_t *record) { | 179 | void post_process_record_quantum(keyrecord_t *record) { |
| 177 | uint16_t keycode = get_record_keycode(record); | 180 | uint16_t keycode = get_record_keycode(record, false); |
| 178 | post_process_record_kb(keycode, record); | 181 | post_process_record_kb(keycode, record); |
| 179 | } | 182 | } |
| 180 | 183 | ||
| @@ -182,7 +185,7 @@ void post_process_record_quantum(keyrecord_t *record) { | |||
| 182 | then processes internal quantum keycodes, and then processes | 185 | then processes internal quantum keycodes, and then processes |
| 183 | ACTIONs. */ | 186 | ACTIONs. */ |
| 184 | bool process_record_quantum(keyrecord_t *record) { | 187 | bool process_record_quantum(keyrecord_t *record) { |
| 185 | uint16_t keycode = get_record_keycode(record); | 188 | uint16_t keycode = get_record_keycode(record, true); |
| 186 | 189 | ||
| 187 | // This is how you use actions here | 190 | // This is how you use actions here |
| 188 | // if (keycode == KC_LEAD) { | 191 | // if (keycode == KC_LEAD) { |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 4b94ebcc0..45f44f49a 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -252,8 +252,8 @@ void matrix_init_kb(void); | |||
| 252 | void matrix_scan_kb(void); | 252 | void matrix_scan_kb(void); |
| 253 | void matrix_init_user(void); | 253 | void matrix_init_user(void); |
| 254 | void matrix_scan_user(void); | 254 | void matrix_scan_user(void); |
| 255 | uint16_t get_record_keycode(keyrecord_t *record); | 255 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache); |
| 256 | uint16_t get_event_keycode(keyevent_t event); | 256 | uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); |
| 257 | bool process_action_kb(keyrecord_t *record); | 257 | bool process_action_kb(keyrecord_t *record); |
| 258 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); | 258 | bool process_record_kb(uint16_t keycode, keyrecord_t *record); |
| 259 | bool process_record_user(uint16_t keycode, keyrecord_t *record); | 259 | bool process_record_user(uint16_t keycode, keyrecord_t *record); |
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 74db245c1..27c0abe6f 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -324,7 +324,7 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 324 | # if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) | 324 | # if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) |
| 325 | if ( | 325 | if ( |
| 326 | # ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY | 326 | # ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY |
| 327 | !get_ignore_mod_tap_interrupt(get_event_keycode(record->event)) && | 327 | !get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false)) && |
| 328 | # endif | 328 | # endif |
| 329 | record->tap.interrupted) { | 329 | record->tap.interrupted) { |
| 330 | dprint("mods_tap: tap: cancel: add_mods\n"); | 330 | dprint("mods_tap: tap: cancel: add_mods\n"); |
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index acce3ee51..34f08d890 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPING_TERM; } | 22 | __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPING_TERM; } |
| 23 | 23 | ||
| 24 | # ifdef TAPPING_TERM_PER_KEY | 24 | # ifdef TAPPING_TERM_PER_KEY |
| 25 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event))) | 25 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event, false))) |
| 26 | # else | 26 | # else |
| 27 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) | 27 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) |
| 28 | # endif | 28 | # endif |
| @@ -122,10 +122,10 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 122 | # if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) | 122 | # if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) |
| 123 | else if ( | 123 | else if ( |
| 124 | # ifdef TAPPING_TERM_PER_KEY | 124 | # ifdef TAPPING_TERM_PER_KEY |
| 125 | (get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && | 125 | (get_tapping_term(get_event_keycode(tapping_key.event, false)) >= 500) && |
| 126 | # endif | 126 | # endif |
| 127 | # ifdef PERMISSIVE_HOLD_PER_KEY | 127 | # ifdef PERMISSIVE_HOLD_PER_KEY |
| 128 | !get_permissive_hold(get_event_keycode(tapping_key.event), keyp) && | 128 | !get_permissive_hold(get_event_keycode(tapping_key.event, false), keyp) && |
| 129 | # endif | 129 | # endif |
| 130 | IS_RELEASED(event) && waiting_buffer_typed(event)) { | 130 | IS_RELEASED(event) && waiting_buffer_typed(event)) { |
| 131 | debug("Tapping: End. No tap. Interfered by typing key\n"); | 131 | debug("Tapping: End. No tap. Interfered by typing key\n"); |
| @@ -246,7 +246,7 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 246 | # if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY) | 246 | # if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY) |
| 247 | if ( | 247 | if ( |
| 248 | # ifdef TAPPING_FORCE_HOLD_PER_KEY | 248 | # ifdef TAPPING_FORCE_HOLD_PER_KEY |
| 249 | !get_tapping_force_hold(get_event_keycode(tapping_key.event), keyp) && | 249 | !get_tapping_force_hold(get_event_keycode(tapping_key.event, false), keyp) && |
| 250 | # endif | 250 | # endif |
| 251 | !tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | 251 | !tapping_key.tap.interrupted && tapping_key.tap.count > 0) { |
| 252 | // sequential tap. | 252 | // sequential tap. |
diff --git a/tmk_core/common/action_tapping.h b/tmk_core/common/action_tapping.h index 509d5eabd..5eaef1c5f 100644 --- a/tmk_core/common/action_tapping.h +++ b/tmk_core/common/action_tapping.h | |||
| @@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 32 | #define WAITING_BUFFER_SIZE 8 | 32 | #define WAITING_BUFFER_SIZE 8 |
| 33 | 33 | ||
| 34 | #ifndef NO_ACTION_TAPPING | 34 | #ifndef NO_ACTION_TAPPING |
| 35 | uint16_t get_event_keycode(keyevent_t event); | 35 | uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache); |
| 36 | uint16_t get_tapping_term(uint16_t keycode); | 36 | uint16_t get_tapping_term(uint16_t keycode); |
| 37 | void action_tapping_process(keyrecord_t record); | 37 | void action_tapping_process(keyrecord_t record); |
| 38 | #endif | 38 | #endif |
