summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-04-12 08:27:17 -0700
committerGitHub <noreply@github.com>2020-04-12 17:27:17 +0200
commit23124b9fd1d667b3457410b771153361e22ae133 (patch)
treecc5bf6744ff5e02bb0f9c0b0e0a1808be5cc3094 /quantum
parenteb7fc7f9d99231e4c59dee2bef8659b089f4846a (diff)
Fix bug with layer caching in get_event_keycode (#8693)
* Fix bug with layer caching in get_event_keycode * Improve naming
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.c13
-rw-r--r--quantum/quantum.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 76a48cc77c..2053a1a5f4 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -149,18 +149,21 @@ void reset_keyboard(void) {
}
/* Convert record into usable keycode via the contained event. */
-uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
+uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { return get_event_keycode(record->event, update_layer_cache); }
/* Convert event into usable keycode. Checks the layer cache to ensure that it
* retains the correct keycode after a layer change, if the key is still pressed.
+ * "update_layer_cache" is to ensure that it only updates the layer cache when
+ * appropriate, otherwise, it will update it and cause layer tap (and other keys)
+ * from triggering properly.
*/
-uint16_t get_event_keycode(keyevent_t event) {
+uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
/* TODO: Use store_or_get_action() or a similar function. */
if (!disable_action_cache) {
uint8_t layer;
- if (event.pressed) {
+ if (event.pressed && update_layer_cache) {
layer = layer_switch_get_layer(event.key);
update_source_layers_cache(event.key, layer);
} else {
@@ -174,7 +177,7 @@ uint16_t get_event_keycode(keyevent_t event) {
/* Get keycode, and then call keyboard function */
void post_process_record_quantum(keyrecord_t *record) {
- uint16_t keycode = get_record_keycode(record);
+ uint16_t keycode = get_record_keycode(record, false);
post_process_record_kb(keycode, record);
}
@@ -182,7 +185,7 @@ void post_process_record_quantum(keyrecord_t *record) {
then processes internal quantum keycodes, and then processes
ACTIONs. */
bool process_record_quantum(keyrecord_t *record) {
- uint16_t keycode = get_record_keycode(record);
+ uint16_t keycode = get_record_keycode(record, true);
// This is how you use actions here
// if (keycode == KC_LEAD) {
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 4b94ebcc05..45f44f49a1 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -252,8 +252,8 @@ void matrix_init_kb(void);
void matrix_scan_kb(void);
void matrix_init_user(void);
void matrix_scan_user(void);
-uint16_t get_record_keycode(keyrecord_t *record);
-uint16_t get_event_keycode(keyevent_t event);
+uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
+uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
bool process_action_kb(keyrecord_t *record);
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
bool process_record_user(uint16_t keycode, keyrecord_t *record);