summaryrefslogtreecommitdiff
path: root/keyboards/kyria/keymaps/pierrec83/encoders.c
blob: 7505925e72f6ec3d94ce5f84f502e9399fbbbcde (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
64
#include QMK_KEYBOARD_H
#include "layers.h"

#ifdef ENCODER_ENABLE

bool encoder_update_user(uint8_t index, bool clockwise) {
    if (index == 0) {
        switch (get_highest_layer(layer_state)) {
            case WORKMAN:
                if (clockwise) {
                    tap_code(KC_VOLU);
                } else {
                    tap_code(KC_VOLD);
                }
                break;
            case SYMBOLS:
            case FN:
                if (clockwise) {
                    tap_code(KC_PGDN);
                } else {
                    tap_code(KC_PGUP);
                }
                break;
            case NAV:
            case RNAV:
            default:
                if (clockwise) {
                    tap_code16(C(A(KC_RIGHT)));
                } else {
                    tap_code16(C(A(KC_LEFT)));
                }
                break;
        }
    } else if (index == 1) {
        switch (get_highest_layer(layer_state)) {
            case WORKMAN:
                if (clockwise) {
                    tap_code(KC_BRIU);
                } else {
                    tap_code(KC_BRID);
                   }
                break;
            case SYMBOLS:
            case FN:
                if (clockwise) {
                    tap_code16(C(KC_RIGHT));
                } else {
                    tap_code16(C(KC_LEFT));
                }
                break;
            case NAV:
            case RNAV:
            default:
                if (clockwise) {
                    tap_code16(C(KC_TAB));
                } else {
                    tap_code16(C(S(KC_TAB)));
                }
                break;
        }
    }
    return true;
}
#endif