aboutsummaryrefslogtreecommitdiff
path: root/quantum/action_tapping.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/action_tapping.c')
-rw-r--r--quantum/action_tapping.c35
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);
58static void debug_tapping_key(void); 59static void debug_tapping_key(void);
59static void debug_waiting_buffer(void); 60static void debug_waiting_buffer(void);
60 61
62/* Convert record into usable keycode via the contained event. */
63uint16_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 */
76uint16_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