summaryrefslogtreecommitdiff
path: root/users/xulkal/process_records.c
blob: 245d4955fbe84ac19afc5b19f74d4d32181d3400 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "process_records.h"
#include "custom_keycodes.h"
#include "timer_utils.h"

#ifdef RGB_ENABLE
#include "custom_rgb.h"
#endif

#ifdef TRILAYER_ENABLED
uint32_t layer_state_set_user(uint32_t state)
{
    return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}
#endif

bool process_record_user(uint16_t keycode, keyrecord_t *record)
{
    static uint16_t reset_timer;

#ifndef TAP_DANCE_ENABLE
    if (!process_custom_tap_dance(keycode, record))
        return false;
#endif

    switch (keycode)
    {
        case RGBRST:
#ifdef RGB_ENABLE
            if (record->event.pressed)
                rgb_reset();
#endif
            return false;
        case RESET:
            {
                if (record->event.pressed)
                    reset_timer = timer_read() + 500;
                else if (timer_expired(reset_timer))
                    reset_keyboard();
            }
            return false;
#ifdef RGB_MATRIX_TOG_LAYERS
        case RGB_TOG:
            if (record->event.pressed) {
              rgb_matrix_decrease_flags();
            }
            return false;
#endif
  }

  return process_record_encoder(keycode, record) && process_record_keymap(keycode, record);
}

__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
{
    return true;
}

__attribute__ ((weak))
bool process_record_encoder(uint16_t keycode, keyrecord_t *record)
{
    return true;
}