aboutsummaryrefslogtreecommitdiffstats
path: root/users/miles2go/milestogo.c
blob: f1da2f4d7ab415243f93b4f235c06276bfd9eee1 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// based on drashna's but I think at this point it's a new axe

#include QMK_KEYBOARD_H
#include "milestogo.h"
#include <print.h>

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

bool move_is_on = false;  // track if we are in _MOV layer
bool sym_is_on  = false;  // track if we are in _SYM layer

// Defines actions for global custom keycodes
// Then runs the _keymap's record handier if not processed here
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    // static uint16_t spcmov_timer; // timer for spcmov key

#ifdef USE_BABBLEPASTE
    if (keycode > BABBLE_START && keycode < BABBLE_END_RANGE) {
        if (record->event.pressed) {  // is there a case where this isn't desired?
            babblePaste(keycode);
        } else {
            return true;
        }
    }
#endif

    switch (keycode) {
        case _QWERTY:
            if (record->event.pressed) {
                set_single_persistent_default_layer(_QWERTY);
            }
            break;

        case _CDH:
            if (record->event.pressed) {
                set_single_persistent_default_layer(_CDH);
            }
            break;

        case TMUX:  // ctl-B
            if (record->event.pressed) {
                tap_code16(C(KC_B));
            }
            break;

            /* Colemak mod-dh moves the D key to the qwerty V position
                        This hack makes apple-V_position do what I mean */
        case DHPASTE:
            if (get_mods() & MOD_BIT(KC_LGUI)) {
                if (record->event.pressed) {
                    clear_keyboard_but_mods();
                    register_code(KC_V);
                } else {
                    unregister_code(KC_V);
                }
            } else {
                if (record->event.pressed) {
                    register_code(KC_D);
                } else {
                    unregister_code(KC_D);
                }
            }
            return false;
            break;

        default:
            return true;
    }

    // normal keycode
    return process_record_keymap(keycode, record);
}

void babble_led_user(void) {
#ifdef USE_BABLPASTE
    extern uint8_t babble_mode;

#    ifdef BABL_WINDOWS
    if (babble_mode == BABL_WINDOWS_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_MS, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_MS);
        }
    }
#    endif
#    ifdef BABL_READMUX
    if (babble_mode == BABL_READMUX_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_READMUX, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_READMUX);
        }
    }
#    endif
#    ifdef BABL_MAC
    if (babble_mode == BABL_MAC_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_MAC, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_MAC);
        }
    }
#    endif
#    ifdef BABL_VI
    if (babble_mode == BABL_VI_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_VI, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_VI);
        }
    }
#    endif
#    ifdef BABL_EMACS
    if (babble_mode == BABL_EMACS_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_EMACS, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_EMACS);
        }
    }
#    endif
#    ifdef BABL_CHROMEOS
    if (babble_mode == BABL_CHROMEOS_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_CHROMEOS, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_CHROMEOS);
        }
    }
#    endif
#    ifdef BABL_LINUX
    if (babble_mode == BABL_LINUX_MODE) {
        if (BABL_LED_INDEX > 0) {
            rgblight_setrgb_at(RGBLIGHT_COLOR_LINUX, BABL_LED_INDEX);
        } else {
            rgblight_setrgb(RGBLIGHT_COLOR_LINUX);
        }
    }
#    endif
#endif  // bablepaste
}