aboutsummaryrefslogtreecommitdiff
path: root/layouts/community/ergodox/belak
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/community/ergodox/belak')
-rw-r--r--layouts/community/ergodox/belak/LICENSE21
-rw-r--r--layouts/community/ergodox/belak/README.md79
-rw-r--r--layouts/community/ergodox/belak/keymap.c368
-rw-r--r--layouts/community/ergodox/belak/rules.mk4
-rw-r--r--layouts/community/ergodox/belak/visualizer.c49
5 files changed, 521 insertions, 0 deletions
diff --git a/layouts/community/ergodox/belak/LICENSE b/layouts/community/ergodox/belak/LICENSE
new file mode 100644
index 000000000..b462ba30e
--- /dev/null
+++ b/layouts/community/ergodox/belak/LICENSE
@@ -0,0 +1,21 @@
1MIT License
2
3Copyright (c) 2016 Kaleb Elwert
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all
13copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21SOFTWARE.
diff --git a/layouts/community/ergodox/belak/README.md b/layouts/community/ergodox/belak/README.md
new file mode 100644
index 000000000..30484e6e2
--- /dev/null
+++ b/layouts/community/ergodox/belak/README.md
@@ -0,0 +1,79 @@
1# Belak's Ergodox Layout
2
3This has been based off of [emacs\_osx\_dk](https://github.com/jackhumbert/qmk_firmware/tree/master/keyboards/ergodox/keymaps/emacs_osx_dk)
4from the main qmk repo. However, I've taken some of the ideas for the thumbs
5from [dvorak\_emacs](https://github.com/jackhumbert/qmk_firmware/tree/master/keyboards/ergodox/keymaps/dvorak_emacs)
6and tweaked it a bit based on the keycaps I have.
7
8This keyboard is intended for use in emacs (one of the main reasons for easy
9access to modifiers) but it could be useful in other instances as well.
10
11The main repo is used as a testbed, so sometimes the layout may be in a strange
12state. The qmk version should be relatively stable.
13
14## Instructions
15
16This is currently being used on a regular ergodox, but it should work fine on
17the infinity as well. Though, you may have to modify the commands to build and
18flash the firmware to match the separate halves as defined in the infinity
19documentation.
20
21If you are using this keymap in the qmk repo, you should be able to just run
22`make ergodox-belak-teensy`. If you're using this externally (I sometimes make
23changes before syncing them to qmk), use the following instructions:
24
251. Clone the main qmk repo
262. Clone this to `$QMK/keyboards/ergodox/keymaps/belak-external`
273. Run `make ergodox-belak-external-teensy` from the root of the qmk repo.
28
29## Changelog
30
31Fifth Revision
32
33* Change layer keys to tap-dance keys which cycle through additional layers
34* Add a few emoji keys (in preparation for an emoji layer)
35
36Fourth Revision
37
38* Remove media layer
39* Add a layer which swaps control and gui on the thumb keys.
40* Add some basic code to save settings to the eeprom
41* Save the state of the keys swapped in the thumb in the eeprom
42
43Third Revision
44
45* Add numpad layer and remove numpad from symbols layer
46* Disable media layer
47* Add arrow keys on ijkl to the symbols layer
48* Replace ALT on held enter and held delete with GUI (for better OSX
49 compatibility, as there's already an ALT key relatively close)
50* Replace keys above enter and delete with temporary layer switch buttons not
51 matching the other layer switch for that hand.
52* Reindent and space out most of the layer definitions
53
54Second Revision
55
56* Clean up definitions to make differences between layers easier to see
57* Remove old LCD code
58* Add new LCD code based on fredizzimo's branch
59
60First Revision
61
62* Reverse grave and escape
63
64Initial Version
65
66* Copy from emacs\_osx\_dk
67* "Fix" right alt
68* Change thumb keys to match default layout (backspace, delete, enter, space)
69* Add modifiers to thumb keys (ctrl to backspace and space, alt to delete and
70 enter)
71* Replace the RAlt below the brackets with LGui and RGui
72* Remove LCtrl and RCtrl from the keys above shift
73* Add browser forward, and move browser back
74* "Fix" the order of volume keys
75
76## Repository
77
78The original code for this is kept at https://github.com/belak/ergodox-layout and
79is synced to qmk every few main revisions.
diff --git a/layouts/community/ergodox/belak/keymap.c b/layouts/community/ergodox/belak/keymap.c
new file mode 100644
index 000000000..016cf30b4
--- /dev/null
+++ b/layouts/community/ergodox/belak/keymap.c
@@ -0,0 +1,368 @@
1#include QMK_KEYBOARD_H
2#include "debug.h"
3#include "action_layer.h"
4#include "eeconfig.h"
5#include "eeprom.h"
6
7#define LAYER_ON(pos) ((layer_state) & (1<<(pos)))
8#define _______ KC_TRNS
9
10#define EECONFIG_BELAK_MAGIC (uint16_t)0xBE42
11
12// NOTE: This is just a number that's a bit beyond the end of what's already
13// defined. As there is no other define we can base this on, it may need to be
14// changed in the future. The initial value here is used as a placeholder with a
15// magic word, similar to the normal eeconfig. Note that all the storage being
16// used needs to fit inside the 32 bytes of the Ergodox Infinity.
17#define EECONFIG_BELAK (uint16_t *)16
18
19// The correct way to do this would be how the normal eeconfig handles it and
20// use a bitfield. However, the eeprom has a ton of space which isn't being
21// used so I don't really care and have a separate byte for every setting.
22#define EECONFIG_BELAK_SWAP_GUI_CTRL (uint8_t *)18
23
24static uint8_t swap_gui_ctrl = 0;
25static uint8_t td_led_override = 0;
26
27enum belak_keycodes {
28 // Function codes
29 BEL_F0 = SAFE_RANGE,
30 BEL_F1,
31
32 E_SHRUG,
33 E_TFLIP,
34 E_TSET,
35};
36
37inline void tap(uint16_t keycode) {
38 register_code(keycode);
39 unregister_code(keycode);
40};
41
42// TODO: Add LED support to the tap dance by using the advanced macro
43#define LTOGGLE TD(TD_LAYER_TOGGLE)
44
45#define BASE 0 // default layer
46#define SYMB 1 // symbols
47#define NUMP 2 // numpad
48#define SWPH 3 // swap gui/ctrl on the hands
49
50enum belak_td {
51 TD_LAYER_TOGGLE = 0,
52};
53
54void belak_td_each(qk_tap_dance_state_t *state, void *user_data);
55void belak_td_finished(qk_tap_dance_state_t *state, void *user_data);
56void belak_td_reset(qk_tap_dance_state_t *state, void *user_data);
57
58qk_tap_dance_action_t tap_dance_actions[] = {
59 [TD_LAYER_TOGGLE] = ACTION_TAP_DANCE_FN_ADVANCED(belak_td_each, belak_td_finished, belak_td_reset),
60};
61
62const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
63/* Keymap 0: Basic layer
64 *
65 * ,--------------------------------------------------. ,--------------------------------------------------.
66 * | Esc | 1 | 2 | 3 | 4 | 5 | L1 | | L2 | 6 | 7 | 8 | 9 | 0 | = |
67 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
68 * | Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | - |
69 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
70 * | \ | A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
71 * |--------+------+------+------+------+------| LGui | | RGui |------+------+------+------+------+--------|
72 * | LShift | Z | X | C | V | B | | | | N | M | , | . | / | RShift |
73 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
74 * |Layers| LCtrl| Left | Right| LAlt | | RAlt | Up | Down | RCtrl|Layers|
75 * `----------------------------------' `----------------------------------'
76 * ,-------------. ,--------------.
77 * | ~L2 | Ins | | Grv | ~L1 |
78 * ,-------|------|------| |------+-------+-------.
79 * | Back | | Home | | PgUp | | |
80 * | Space | Del |------| |------| Enter | Space |
81 * | | | End | | PgDn | | |
82 * `---------------------' `----------------------'
83 */
84 [BASE] = LAYOUT_ergodox( // layer 0 : default
85 // left hand
86 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, TG(SYMB),
87 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_LBRC,
88 CTL_T(KC_BSLS), KC_A, KC_S, KC_D, KC_F, KC_G,
89 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LGUI,
90 LTOGGLE, KC_LCTRL, KC_LEFT,KC_RGHT,KC_LALT,
91 MO(NUMP),KC_INS,
92 KC_HOME,
93 CTL_T(KC_BSPC),GUI_T(KC_DEL),KC_END,
94 // right hand
95 TG(NUMP), KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL,
96 KC_RBRC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS,
97 KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
98 KC_RGUI, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,
99 KC_RALT,KC_UP, KC_DOWN,KC_RCTRL, LTOGGLE,
100 KC_GRV, MO(SYMB),
101 KC_PGUP,
102 KC_PGDN, GUI_T(KC_ENT), CTL_T(KC_SPC)
103 ),
104/* Keymap 1: Symbol Layer
105 *
106 * ,--------------------------------------------------. ,--------------------------------------------------.
107 * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
108 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
109 * | | ! | @ | { | } | | | | | | Up | | Up | | | F12 |
110 * |--------+------+------+------+------+------| TFLIP| | TSET |------+------+------+------+------+--------|
111 * | | # | $ | ( | ) | ` |------| |------| Down | Left | Down | Rght | | |
112 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
113 * | | % | ^ | [ | ] | ~ | SHRUG| | | & | | | | | |
114 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
115 * |LClear| | | | | | | | | |LClear|
116 * `----------------------------------' `----------------------------------'
117 * ,-------------. ,-------------.
118 * | TOGL | | | | TOGL |
119 * ,------|------|------| |------+------+------.
120 * | | | | | | | |
121 * | | |------| |------| | |
122 * | | | | | | | |
123 * `--------------------' `--------------------'
124 */
125 [SYMB] = LAYOUT_ergodox(
126 // left hand
127 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, E_TFLIP,
128 _______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, E_TSET,
129 _______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV,
130 _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, E_SHRUG,
131 BEL_F1, _______, _______, _______, _______,
132 BEL_F0, _______,
133 _______,
134 _______, _______, _______,
135 // right hand
136 _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
137 _______, KC_UP, _______, KC_UP, _______, _______, KC_F12,
138 KC_DOWN, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______,
139 _______, KC_AMPR, _______, _______, _______, _______, _______,
140 _______, _______, _______, _______, BEL_F1,
141 _______, BEL_F0,
142 _______,
143 _______, _______, _______
144 ),
145/* Keymap 2: Numpad Layer
146 *
147 * ,--------------------------------------------------. ,--------------------------------------------------.
148 * | | | | | | | | | | | | | | | |
149 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
150 * | | | | | | | | | | | 7 | 8 | 9 | * | |
151 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
152 * | | | | | | |------| |------| | 4 | 5 | 6 | + | |
153 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
154 * | | | | | | | | | | | 1 | 2 | 3 | \ | |
155 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
156 * |LClear| | | | | | 0 | 0 | . | = |LClear|
157 * `----------------------------------' `----------------------------------'
158 * ,-------------. ,-------------.
159 * | TOGL | | | | TOGL |
160 * ,------|------|------| |------+------+------.
161 * | | | | | | | |
162 * | | |------| |------| | |
163 * | | | | | | | |
164 * `--------------------' `--------------------'
165 */
166 [NUMP] = LAYOUT_ergodox(
167 // left hand
168 _______, _______, _______, _______, _______, _______, _______,
169 _______, _______, _______, _______, _______, _______, _______,
170 _______, _______, _______, _______, _______, _______,
171 _______, _______, _______, _______, _______, _______, _______,
172 BEL_F1, _______, _______, _______, _______,
173 BEL_F0, _______,
174 _______,
175 _______, _______, _______,
176 // right hand
177 _______, _______, _______, _______, _______, _______, _______,
178 _______, _______, KC_7, KC_8, KC_9, KC_ASTR, _______,
179 _______, KC_4, KC_5, KC_6, KC_PLUS, _______,
180 _______, _______, KC_1, KC_2, KC_3, KC_BSLS, _______,
181 KC_0, KC_0, KC_DOT, KC_EQL, BEL_F1,
182 _______, BEL_F0,
183 _______,
184 _______, _______, _______
185 ),
186/* Keymap 3: Swap control and gui on the thumb */
187 [SWPH] = LAYOUT_ergodox(
188 // left hand
189 _______, _______, _______, _______, _______, _______, _______,
190 _______, _______, _______, _______, _______, _______, _______,
191 _______, _______, _______, _______, _______, _______,
192 _______, _______, _______, _______, _______, _______, _______,
193 _______, _______, _______, _______, _______,
194 _______, _______,
195 _______,
196 GUI_T(KC_BSPC), CTL_T(KC_DEL), _______,
197 // right hand
198 _______, _______, _______, _______, _______, _______, _______,
199 _______, _______, _______, _______, _______, _______, _______,
200 _______, _______, _______, _______, _______, _______,
201 _______, _______, _______, _______, _______, _______, _______,
202 _______, _______, _______, _______, _______,
203 _______, _______,
204 _______,
205 _______, CTL_T(KC_ENT), GUI_T(KC_SPC)
206 ),
207};
208
209// Runs just one time when the keyboard initializes.
210void matrix_init_user(void) {
211 // If our magic word wasn't set properly, we need to zero out the settings.
212 if (eeprom_read_word(EECONFIG_BELAK) != EECONFIG_BELAK_MAGIC) {
213 eeprom_update_word(EECONFIG_BELAK, EECONFIG_BELAK_MAGIC);
214 eeprom_update_byte(EECONFIG_BELAK_SWAP_GUI_CTRL, 0);
215 }
216
217 if (eeprom_read_byte(EECONFIG_BELAK_SWAP_GUI_CTRL)) {
218 layer_on(SWPH);
219 swap_gui_ctrl = 1;
220 }
221};
222
223// Runs constantly in the background, in a loop.
224void matrix_scan_user(void) {
225 ergodox_board_led_off();
226 ergodox_right_led_1_off();
227 ergodox_right_led_2_off();
228 ergodox_right_led_3_off();
229
230 switch (td_led_override) {
231 case 1:
232 ergodox_right_led_1_on();
233 break;
234 case 2:
235 ergodox_right_led_2_on();
236 break;
237 default:
238 // Layer 1 and 2 are both overlay layers, so they could both be on. This
239 // means we can't use the lazy check of checking for the first significant
240 // bit.
241 if (LAYER_ON(SYMB)) {
242 ergodox_right_led_1_on();
243 }
244 if (LAYER_ON(NUMP)) {
245 ergodox_right_led_2_on();
246 }
247 }
248};
249
250bool process_record_user(uint16_t keycode, keyrecord_t *record) {
251 switch (keycode) {
252 case BEL_F0:
253 if(record->event.pressed){
254 swap_gui_ctrl = !swap_gui_ctrl;
255 eeprom_update_byte(EECONFIG_BELAK_SWAP_GUI_CTRL, swap_gui_ctrl);
256
257 if (swap_gui_ctrl) {
258 layer_on(SWPH);
259 } else {
260 layer_off(SWPH);
261 }
262
263 return false;
264 }
265 break;
266 case BEL_F1:
267 if(record->event.pressed){
268 layer_off(SYMB);
269 layer_off(NUMP);
270
271 return false;
272 }
273 break;
274 case E_SHRUG: // ¯\_(ツ)_/¯
275 if (record->event.pressed) {
276 process_unicode((0x00AF|QK_UNICODE), record); // Hand
277 tap(KC_BSLS); // Arm
278 register_code(KC_RSFT);
279 tap(KC_UNDS); // Arm
280 tap(KC_LPRN); // Head
281 unregister_code(KC_RSFT);
282 process_unicode((0x30C4|QK_UNICODE), record); // Face
283 register_code(KC_RSFT);
284 tap(KC_RPRN); // Head
285 tap(KC_UNDS); // Arm
286 unregister_code(KC_RSFT);
287 tap(KC_SLSH); // Arm
288 process_unicode((0x00AF|QK_UNICODE), record); // Hand
289 }
290 return false;
291 break;
292 case E_TFLIP: // (╯°□°)╯ ︵ ┻━┻
293 if (record->event.pressed) {
294 register_code(KC_RSFT);
295 tap(KC_9);
296 unregister_code(KC_RSFT);
297 process_unicode((0x256F|QK_UNICODE), record); // Arm
298 process_unicode((0x00B0|QK_UNICODE), record); // Eye
299 process_unicode((0x25A1|QK_UNICODE), record); // Mouth
300 process_unicode((0x00B0|QK_UNICODE), record); // Eye
301 register_code(KC_RSFT);
302 tap(KC_0);
303 unregister_code(KC_RSFT);
304 process_unicode((0x256F|QK_UNICODE), record); // Arm
305 tap(KC_SPC);
306 process_unicode((0x0361|QK_UNICODE), record); // Flippy
307 tap(KC_SPC);
308 process_unicode((0x253B|QK_UNICODE), record); // Table
309 process_unicode((0x2501|QK_UNICODE), record); // Table
310 process_unicode((0x253B|QK_UNICODE), record); // Table
311 }
312 return false;
313 break;
314 case E_TSET: // ┬──┬ ノ( ゜-゜ノ)
315 if (record->event.pressed) {
316 process_unicode((0x252C|QK_UNICODE), record); // Table
317 process_unicode((0x2500|QK_UNICODE), record); // Table
318 process_unicode((0x2500|QK_UNICODE), record); // Table
319 process_unicode((0x252C|QK_UNICODE), record); // Table
320 tap(KC_SPC);
321 process_unicode((0x30CE|QK_UNICODE), record); // Arm
322 register_code(KC_RSFT);
323 tap(KC_9);
324 unregister_code(KC_RSFT);
325 tap(KC_SPC);
326 process_unicode((0x309C|QK_UNICODE), record); // Eye
327 tap(KC_MINS);
328 process_unicode((0x309C|QK_UNICODE), record); // Eye
329 process_unicode((0x30CE|QK_UNICODE), record); // Arm
330 register_code(KC_RSFT);
331 tap(KC_0);
332 unregister_code(KC_RSFT);
333 }
334 return false;
335 break;
336 }
337
338 return true;
339}
340
341void belak_td_each(qk_tap_dance_state_t *state, void *user_data) {
342 switch (state->count) {
343 case 1:
344 td_led_override = 1;
345 break;
346 case 2:
347 td_led_override = 2;
348 break;
349 default:
350 reset_tap_dance(state);
351 }
352}
353
354void belak_td_finished(qk_tap_dance_state_t *state, void *user_data) {
355 switch (state->count) {
356 case 1:
357 layer_on(SYMB);
358 break;
359 case 2:
360 layer_on(NUMP);
361 break;
362 }
363 td_led_override = 0;
364}
365
366void belak_td_reset(qk_tap_dance_state_t *state, void *user_data) {
367 td_led_override = 0;
368}
diff --git a/layouts/community/ergodox/belak/rules.mk b/layouts/community/ergodox/belak/rules.mk
new file mode 100644
index 000000000..cd8fdec64
--- /dev/null
+++ b/layouts/community/ergodox/belak/rules.mk
@@ -0,0 +1,4 @@
1TAP_DANCE_ENABLE=yes
2UNICODE_ENABLE=yes
3
4
diff --git a/layouts/community/ergodox/belak/visualizer.c b/layouts/community/ergodox/belak/visualizer.c
new file mode 100644
index 000000000..b92890a66
--- /dev/null
+++ b/layouts/community/ergodox/belak/visualizer.c
@@ -0,0 +1,49 @@
1/*
2Copyright 2017 Fred Sundvik
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18// Currently we are assuming that both the backlight and LCD are enabled
19// But it's entirely possible to write a custom visualizer that use only
20// one of them
21#ifndef LCD_BACKLIGHT_ENABLE
22#error This visualizer needs that LCD backlight is enabled
23#endif
24
25#ifndef LCD_ENABLE
26#error This visualizer needs that LCD is enabled
27#endif
28
29#include "simple_visualizer.h"
30
31static void get_visualizer_layer_and_color(visualizer_state_t* state) {
32 uint8_t saturation = 60;
33 if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
34 saturation = 255;
35 }
36
37 if (state->status.layer & 0x4) {
38 state->target_lcd_color = LCD_COLOR(0, saturation, 0xFF);
39 state->layer_text = "Media";
40 }
41 else if (state->status.layer & 0x2) {
42 state->target_lcd_color = LCD_COLOR(168, saturation, 0xFF);
43 state->layer_text = "Symbols";
44 }
45 else {
46 state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
47 state->layer_text = "Base";
48 }
49}