diff options
| author | Joel Challis <git@zvecr.com> | 2021-08-24 14:28:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-24 14:28:37 +0100 |
| commit | c4dbf4bf0118dd785802861beb247433b5b7411d (patch) | |
| tree | 91e5142e9c280db4fbee6c0d7e64f1abdad79109 /quantum/action_tapping.c | |
| parent | c4a2dc9a2d1b0c053272aec7672ab8df92550e88 (diff) | |
| download | qmk_firmware-c4dbf4bf0118dd785802861beb247433b5b7411d.tar.gz qmk_firmware-c4dbf4bf0118dd785802861beb247433b5b7411d.zip | |
Tidy up quantum.c now some of tmk_core has been merged (#14083)
Diffstat (limited to 'quantum/action_tapping.c')
| -rw-r--r-- | quantum/action_tapping.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index 36839f9fa..eef6ed1b7 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "action_tapping.h" | 5 | #include "action_tapping.h" |
| 6 | #include "keycode.h" | 6 | #include "keycode.h" |
| 7 | #include "timer.h" | 7 | #include "timer.h" |
| 8 | #include "keymap.h" | ||
| 8 | 9 | ||
| 9 | #ifdef DEBUG_ACTION | 10 | #ifdef DEBUG_ACTION |
| 10 | # include "debug.h" | 11 | # include "debug.h" |
| @@ -58,6 +59,40 @@ static void waiting_buffer_scan_tap(void); | |||
| 58 | static void debug_tapping_key(void); | 59 | static void debug_tapping_key(void); |
| 59 | static void debug_waiting_buffer(void); | 60 | static void debug_waiting_buffer(void); |
| 60 | 61 | ||
| 62 | /* Convert record into usable keycode via the contained event. */ | ||
| 63 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { | ||
| 64 | #ifdef COMBO_ENABLE | ||
| 65 | if (record->keycode) { return record->keycode; } | ||
| 66 | #endif | ||
| 67 | return get_event_keycode(record->event, update_layer_cache); | ||
| 68 | } | ||
| 69 | |||
| 70 | /* Convert event into usable keycode. Checks the layer cache to ensure that it | ||
| 71 | * retains the correct keycode after a layer change, if the key is still pressed. | ||
| 72 | * "update_layer_cache" is to ensure that it only updates the layer cache when | ||
| 73 | * appropriate, otherwise, it will update it and cause layer tap (and other keys) | ||
| 74 | * from triggering properly. | ||
| 75 | */ | ||
| 76 | uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) { | ||
| 77 | const keypos_t key = event.key; | ||
| 78 | |||
| 79 | #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) | ||
| 80 | /* TODO: Use store_or_get_action() or a similar function. */ | ||
| 81 | if (!disable_action_cache) { | ||
| 82 | uint8_t layer; | ||
| 83 | |||
| 84 | if (event.pressed && update_layer_cache) { | ||
| 85 | layer = layer_switch_get_layer(key); | ||
| 86 | update_source_layers_cache(key, layer); | ||
| 87 | } else { | ||
| 88 | layer = read_source_layers_cache(key); | ||
| 89 | } | ||
| 90 | return keymap_key_to_keycode(layer, key); | ||
| 91 | } | ||
| 92 | #endif | ||
| 93 | return keymap_key_to_keycode(layer_switch_get_layer(key), key); | ||
| 94 | } | ||
| 95 | |||
| 61 | /** \brief Action Tapping Process | 96 | /** \brief Action Tapping Process |
| 62 | * | 97 | * |
| 63 | * FIXME: Needs doc | 98 | * FIXME: Needs doc |
