3 #include "action_layer.h"
6 #define LAYER_ON(pos) ((layer_state) & (1<<(pos)))
7 #define _______ KC_TRNS
9 #define EECONFIG_BELAK_MAGIC (uint16_t)0xBE42
11 // NOTE: This is just a number that's a bit beyond the end of what's already
12 // defined. As there is no other define we can base this on, it may need to be
13 // changed in the future. The initial value here is used as a placeholder with a
14 // magic word, similar to the normal eeconfig. Note that all the storage being
15 // used needs to fit inside the 32 bytes of the Ergodox Infinity.
16 #define EECONFIG_BELAK (uint16_t *)16
18 // The correct way to do this would be how the normal eeconfig handles it and
19 // use a bitfield. However, the eeprom has a ton of space which isn't being
20 // used so I don't really care and have a separate byte for every setting.
21 #define EECONFIG_BELAK_SWAP_GUI_CTRL (uint8_t *)18
23 static uint8_t swap_gui_ctrl = 0;
24 static uint8_t td_led_override = 0;
36 inline void tap(uint16_t keycode) {
37 register_code(keycode);
38 unregister_code(keycode);
41 // TODO: Add LED support to the tap dance by using the advanced macro
42 #define LTOGGLE TD(TD_LAYER_TOGGLE)
44 #define BASE 0 // default layer
45 #define SYMB 1 // symbols
46 #define NUMP 2 // numpad
47 #define SWPH 3 // swap gui/ctrl on the hands
53 void belak_td_each(qk_tap_dance_state_t *state, void *user_data);
54 void belak_td_finished(qk_tap_dance_state_t *state, void *user_data);
55 void belak_td_reset(qk_tap_dance_state_t *state, void *user_data);
57 qk_tap_dance_action_t tap_dance_actions[] = {
58 [TD_LAYER_TOGGLE] = ACTION_TAP_DANCE_FN_ADVANCED(belak_td_each, belak_td_finished, belak_td_reset),
61 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
62 /* Keymap 0: Basic layer
64 * ,--------------------------------------------------. ,--------------------------------------------------.
65 * | Esc | 1 | 2 | 3 | 4 | 5 | L1 | | L2 | 6 | 7 | 8 | 9 | 0 | = |
66 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
67 * | Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | - |
68 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
69 * | \ | A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
70 * |--------+------+------+------+------+------| LGui | | RGui |------+------+------+------+------+--------|
71 * | LShift | Z | X | C | V | B | | | | N | M | , | . | / | RShift |
72 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
73 * |Layers| LCtrl| Left | Right| LAlt | | RAlt | Up | Down | RCtrl|Layers|
74 * `----------------------------------' `----------------------------------'
75 * ,-------------. ,--------------.
76 * | ~L2 | Ins | | Grv | ~L1 |
77 * ,-------|------|------| |------+-------+-------.
78 * | Back | | Home | | PgUp | | |
79 * | Space | Del |------| |------| Enter | Space |
80 * | | | End | | PgDn | | |
81 * `---------------------' `----------------------'
83 [BASE] = KEYMAP( // layer 0 : default
85 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, TG(SYMB),
86 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_LBRC,
87 CTL_T(KC_BSLS), KC_A, KC_S, KC_D, KC_F, KC_G,
88 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LGUI,
89 LTOGGLE, KC_LCTRL, KC_LEFT,KC_RGHT,KC_LALT,
92 CTL_T(KC_BSPC),GUI_T(KC_DEL),KC_END,
94 TG(NUMP), KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL,
95 KC_RBRC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS,
96 KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
97 KC_RGUI, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,
98 KC_RALT,KC_UP, KC_DOWN,KC_RCTRL, LTOGGLE,
101 KC_PGDN, GUI_T(KC_ENT), CTL_T(KC_SPC)
103 /* Keymap 1: Symbol Layer
105 * ,--------------------------------------------------. ,--------------------------------------------------.
106 * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
107 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
108 * | | ! | @ | { | } | | | | | | Up | | Up | | | F12 |
109 * |--------+------+------+------+------+------| TFLIP| | TSET |------+------+------+------+------+--------|
110 * | | # | $ | ( | ) | ` |------| |------| Down | Left | Down | Rght | | |
111 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
112 * | | % | ^ | [ | ] | ~ | SHRUG| | | & | | | | | |
113 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
114 * |LClear| | | | | | | | | |LClear|
115 * `----------------------------------' `----------------------------------'
116 * ,-------------. ,-------------.
117 * | TOGL | | | | TOGL |
118 * ,------|------|------| |------+------+------.
120 * | | |------| |------| | |
122 * `--------------------' `--------------------'
126 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, E_TFLIP,
127 _______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, E_TSET,
128 _______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV,
129 _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, E_SHRUG,
130 BEL_F1, _______, _______, _______, _______,
133 _______, _______, _______,
135 _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
136 _______, KC_UP, _______, KC_UP, _______, _______, KC_F12,
137 KC_DOWN, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______,
138 _______, KC_AMPR, _______, _______, _______, _______, _______,
139 _______, _______, _______, _______, BEL_F1,
142 _______, _______, _______
144 /* Keymap 2: Numpad Layer
146 * ,--------------------------------------------------. ,--------------------------------------------------.
147 * | | | | | | | | | | | | | | | |
148 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
149 * | | | | | | | | | | | 7 | 8 | 9 | * | |
150 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
151 * | | | | | | |------| |------| | 4 | 5 | 6 | + | |
152 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
153 * | | | | | | | | | | | 1 | 2 | 3 | \ | |
154 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
155 * |LClear| | | | | | 0 | 0 | . | = |LClear|
156 * `----------------------------------' `----------------------------------'
157 * ,-------------. ,-------------.
158 * | TOGL | | | | TOGL |
159 * ,------|------|------| |------+------+------.
161 * | | |------| |------| | |
163 * `--------------------' `--------------------'
167 _______, _______, _______, _______, _______, _______, _______,
168 _______, _______, _______, _______, _______, _______, _______,
169 _______, _______, _______, _______, _______, _______,
170 _______, _______, _______, _______, _______, _______, _______,
171 BEL_F1, _______, _______, _______, _______,
174 _______, _______, _______,
176 _______, _______, _______, _______, _______, _______, _______,
177 _______, _______, KC_7, KC_8, KC_9, KC_ASTR, _______,
178 _______, KC_4, KC_5, KC_6, KC_PLUS, _______,
179 _______, _______, KC_1, KC_2, KC_3, KC_BSLS, _______,
180 KC_0, KC_0, KC_DOT, KC_EQL, BEL_F1,
183 _______, _______, _______
185 /* Keymap 3: Swap control and gui on the thumb */
188 _______, _______, _______, _______, _______, _______, _______,
189 _______, _______, _______, _______, _______, _______, _______,
190 _______, _______, _______, _______, _______, _______,
191 _______, _______, _______, _______, _______, _______, _______,
192 _______, _______, _______, _______, _______,
195 GUI_T(KC_BSPC), CTL_T(KC_DEL), _______,
197 _______, _______, _______, _______, _______, _______, _______,
198 _______, _______, _______, _______, _______, _______, _______,
199 _______, _______, _______, _______, _______, _______,
200 _______, _______, _______, _______, _______, _______, _______,
201 _______, _______, _______, _______, _______,
204 _______, CTL_T(KC_ENT), GUI_T(KC_SPC)
208 // Runs just one time when the keyboard initializes.
209 void matrix_init_user(void) {
210 // If our magic word wasn't set properly, we need to zero out the settings.
211 if (eeprom_read_word(EECONFIG_BELAK) != EECONFIG_BELAK_MAGIC) {
212 eeprom_update_word(EECONFIG_BELAK, EECONFIG_BELAK_MAGIC);
213 eeprom_update_byte(EECONFIG_BELAK_SWAP_GUI_CTRL, 0);
216 if (eeprom_read_byte(EECONFIG_BELAK_SWAP_GUI_CTRL)) {
222 // Runs constantly in the background, in a loop.
223 void matrix_scan_user(void) {
224 ergodox_board_led_off();
225 ergodox_right_led_1_off();
226 ergodox_right_led_2_off();
227 ergodox_right_led_3_off();
229 switch (td_led_override) {
231 ergodox_right_led_1_on();
234 ergodox_right_led_2_on();
237 // Layer 1 and 2 are both overlay layers, so they could both be on. This
238 // means we can't use the lazy check of checking for the first significant
240 if (LAYER_ON(SYMB)) {
241 ergodox_right_led_1_on();
243 if (LAYER_ON(NUMP)) {
244 ergodox_right_led_2_on();
249 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
252 if(record->event.pressed){
253 swap_gui_ctrl = !swap_gui_ctrl;
254 eeprom_update_byte(EECONFIG_BELAK_SWAP_GUI_CTRL, swap_gui_ctrl);
266 if(record->event.pressed){
273 case E_SHRUG: // ¯\_(ツ)_/¯
274 if (record->event.pressed) {
275 process_unicode((0x00AF|QK_UNICODE), record); // Hand
277 register_code(KC_RSFT);
279 tap(KC_LPRN); // Head
280 unregister_code(KC_RSFT);
281 process_unicode((0x30C4|QK_UNICODE), record); // Face
282 register_code(KC_RSFT);
283 tap(KC_RPRN); // Head
285 unregister_code(KC_RSFT);
287 process_unicode((0x00AF|QK_UNICODE), record); // Hand
291 case E_TFLIP: // (╯°□°)╯ ︵ ┻━┻
292 if (record->event.pressed) {
293 register_code(KC_RSFT);
295 unregister_code(KC_RSFT);
296 process_unicode((0x256F|QK_UNICODE), record); // Arm
297 process_unicode((0x00B0|QK_UNICODE), record); // Eye
298 process_unicode((0x25A1|QK_UNICODE), record); // Mouth
299 process_unicode((0x00B0|QK_UNICODE), record); // Eye
300 register_code(KC_RSFT);
302 unregister_code(KC_RSFT);
303 process_unicode((0x256F|QK_UNICODE), record); // Arm
305 process_unicode((0x0361|QK_UNICODE), record); // Flippy
307 process_unicode((0x253B|QK_UNICODE), record); // Table
308 process_unicode((0x2501|QK_UNICODE), record); // Table
309 process_unicode((0x253B|QK_UNICODE), record); // Table
313 case E_TSET: // ┬──┬ ノ( ゜-゜ノ)
314 if (record->event.pressed) {
315 process_unicode((0x252C|QK_UNICODE), record); // Table
316 process_unicode((0x2500|QK_UNICODE), record); // Table
317 process_unicode((0x2500|QK_UNICODE), record); // Table
318 process_unicode((0x252C|QK_UNICODE), record); // Table
320 process_unicode((0x30CE|QK_UNICODE), record); // Arm
321 register_code(KC_RSFT);
323 unregister_code(KC_RSFT);
325 process_unicode((0x309C|QK_UNICODE), record); // Eye
327 process_unicode((0x309C|QK_UNICODE), record); // Eye
328 process_unicode((0x30CE|QK_UNICODE), record); // Arm
329 register_code(KC_RSFT);
331 unregister_code(KC_RSFT);
340 void belak_td_each(qk_tap_dance_state_t *state, void *user_data) {
341 switch (state->count) {
349 reset_tap_dance(state);
353 void belak_td_finished(qk_tap_dance_state_t *state, void *user_data) {
354 switch (state->count) {
365 void belak_td_reset(qk_tap_dance_state_t *state, void *user_data) {