summaryrefslogtreecommitdiffstats
path: root/users/miles2go/milestogo.c
blob: 1c7f174e4a4cb97f01219d310732d2250c2335db (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
143
144
145
146
147
148
149
150
151
152
153
// 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) { 
            babblePaste(keycode, 1);
        } else {
            babblePaste(keycode, 0);
        }
    }
#endif

    switch (keycode) {
        case KC_QWERTY:
            if (record->event.pressed) {
                layer_off(_CDH);
                default_layer_set(_QWERTY);
            }
            break;

        case KC_CDH:
            if (record->event.pressed) {
                layer_on(_CDH);
                default_layer_set(_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_modeswitch_user(uint8_t mode) {
#ifdef USE_BABLPASTE
    extern uint8_t babble_mode; // still using global. why?

#    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
}


// we always return true here, so that each keyboard can use it's own
// led_update_kb() function
bool led_update_user(led_t led_state ) {
    return true;
}