aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index e60378afe..00426c397 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -51,63 +51,6 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
51# endif 51# endif
52#endif 52#endif
53 53
54#ifdef AUTO_SHIFT_ENABLE
55# include "process_auto_shift.h"
56#endif
57
58uint8_t extract_mod_bits(uint16_t code) {
59 switch (code) {
60 case QK_MODS ... QK_MODS_MAX:
61 break;
62 default:
63 return 0;
64 }
65
66 uint8_t mods_to_send = 0;
67
68 if (code & QK_RMODS_MIN) { // Right mod flag is set
69 if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
70 if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
71 if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
72 if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
73 } else {
74 if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
75 if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
76 if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
77 if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
78 }
79
80 return mods_to_send;
81}
82
83static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
84
85void register_code16(uint16_t code) {
86 if (IS_MOD(code) || code == KC_NO) {
87 do_code16(code, register_mods);
88 } else {
89 do_code16(code, register_weak_mods);
90 }
91 register_code(code);
92}
93
94void unregister_code16(uint16_t code) {
95 unregister_code(code);
96 if (IS_MOD(code) || code == KC_NO) {
97 do_code16(code, unregister_mods);
98 } else {
99 do_code16(code, unregister_weak_mods);
100 }
101}
102
103void tap_code16(uint16_t code) {
104 register_code16(code);
105#if TAP_CODE_DELAY > 0
106 wait_ms(TAP_CODE_DELAY);
107#endif
108 unregister_code16(code);
109}
110
111__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; } 54__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; }
112 55
113__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); } 56__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); }
@@ -142,39 +85,6 @@ void reset_keyboard(void) {
142 bootloader_jump(); 85 bootloader_jump();
143} 86}
144 87
145/* Convert record into usable keycode via the contained event. */
146uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
147#ifdef COMBO_ENABLE
148 if (record->keycode) { return record->keycode; }
149#endif
150 return get_event_keycode(record->event, update_layer_cache);
151}
152
153
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.
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.
159 */
160uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
161#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
162 /* TODO: Use store_or_get_action() or a similar function. */
163 if (!disable_action_cache) {
164 uint8_t layer;
165
166 if (event.pressed && update_layer_cache) {
167 layer = layer_switch_get_layer(event.key);
168 update_source_layers_cache(event.key, layer);
169 } else {
170 layer = read_source_layers_cache(event.key);
171 }
172 return keymap_key_to_keycode(layer, event.key);
173 } else
174#endif
175 return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
176}
177
178/* Get keycode, and then process pre tapping functionality */ 88/* Get keycode, and then process pre tapping functionality */
179bool pre_process_record_quantum(keyrecord_t *record) { 89bool pre_process_record_quantum(keyrecord_t *record) {
180 if (!( 90 if (!(