aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-04-05 12:47:25 -0700
committerJack Humbert <jack.humb@gmail.com>2019-04-05 15:47:25 -0400
commit5701b75e3c10728d424ec058d26ef2e354aba0c0 (patch)
tree979b01e8226d5fb33789bd1c41853c8412bfa669 /quantum/quantum.c
parent4c1760883e2e0ed710348f02bc791786ed0c1b04 (diff)
downloadqmk_firmware-5701b75e3c10728d424ec058d26ef2e354aba0c0.tar.gz
qmk_firmware-5701b75e3c10728d424ec058d26ef2e354aba0c0.zip
Custom Tapping Term per key (#5009)
* Add customizable tapping terms * Add Documentation * Fix function * Fixes * It's not a pointer * Add debugging output * Update documentation to be at least vaguely accurate * Use `get_tapping_term(tapping_key.event)` instead `e` doesn't include column and row information, properly. It registers as 255, regardless of the actual keypress. However `tapping_key.event` actually gives the correct column and row information. It appears be the correct structure to use. In fact, it looks like the issue is that `e` is actually the "TICK" structure, as defined in keyboard.h * Use variable tapping term value rather than define * Silly drashna - tapping_key.event, not event * add get_event_keycode() function * Fix typo Co-Authored-By: drashna <drashna@live.com> * Remove post_process_record_quantum since it's the wrong PR * Update quantum/quantum.c Co-Authored-By: drashna <drashna@live.com> * Better handle ifdef statement for permissive hold Since we can't be sure that tapping term is actually 500 * Update quantum.c comments based on feedback * Clean up get_tapping_term function Clean up function so that users don't need to call the event function, and instead only check the keycode * Add ability to run functionality on and off * Make ifdef's more compact
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 8c928441c..48c338fc8 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -225,27 +225,39 @@ static uint16_t scs_timer[2] = {0, 0};
225 */ 225 */
226static bool grave_esc_was_shifted = false; 226static bool grave_esc_was_shifted = false;
227 227
228bool process_record_quantum(keyrecord_t *record) { 228/* Convert record into usable keycode via the contained event. */
229uint16_t get_record_keycode(keyrecord_t *record) {
230 return get_event_keycode(record->event);
231}
229 232
230 /* This gets the keycode from the key pressed */ 233
231 keypos_t key = record->event.key; 234/* Convert event into usable keycode. Checks the layer cache to ensure that it
232 uint16_t keycode; 235 * retains the correct keycode after a layer change, if the key is still pressed.
236 */
237uint16_t get_event_keycode(keyevent_t event) {
233 238
234 #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) 239 #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
235 /* TODO: Use store_or_get_action() or a similar function. */ 240 /* TODO: Use store_or_get_action() or a similar function. */
236 if (!disable_action_cache) { 241 if (!disable_action_cache) {
237 uint8_t layer; 242 uint8_t layer;
238 243
239 if (record->event.pressed) { 244 if (event.pressed) {
240 layer = layer_switch_get_layer(key); 245 layer = layer_switch_get_layer(event.key);
241 update_source_layers_cache(key, layer); 246 update_source_layers_cache(event.key, layer);
242 } else { 247 } else {
243 layer = read_source_layers_cache(key); 248 layer = read_source_layers_cache(event.key);
244 } 249 }
245 keycode = keymap_key_to_keycode(layer, key); 250 return keymap_key_to_keycode(layer, event.key);
246 } else 251 } else
247 #endif 252 #endif
248 keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); 253 return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
254}
255
256/* Main keycode processing function. Hands off handling to other functions,
257 * then processes internal Quantum keycodes, then processes ACTIONs.
258 */
259bool process_record_quantum(keyrecord_t *record) {
260 uint16_t keycode = get_record_keycode(record);
249 261
250 // This is how you use actions here 262 // This is how you use actions here
251 // if (keycode == KC_LEAD) { 263 // if (keycode == KC_LEAD) {