summaryrefslogtreecommitdiff
path: root/keyboards/dz60/keymaps/_bonfire/keymap-parts/functions.c
blob: fd4d168227b42a659c2b3f871637255ef6afe110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * Custom Keycodes
 * https://beta.docs.qmk.fm/detailed-guides/custom_quantum_functions#custom-keycodes
 * 
 */

// Called on every keyup and keydown
bool process_record_user(uint16_t keycode, keyrecord_t *record)
{
    switch (keycode) {
        case HLD_ESC:
            if(record->event.pressed) {
                is_esc_held = true;
                held_esc_timer = timer_read(); 
            } else {
                is_esc_held = false;
                unregister_code(KC_ESC);
            }
            return true;
            break;

        default:
            return true;
            break;
    }
}

// checking the held escape timer
void matrix_scan_user(void)
{
    if(is_esc_held && timer_elapsed(held_esc_timer) > held_esc_threshold) {
        register_code(KC_ESC);
    }
}