aboutsummaryrefslogtreecommitdiff
path: root/layouts/community/ergodox/berfarah/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/community/ergodox/berfarah/keymap.c')
-rw-r--r--layouts/community/ergodox/berfarah/keymap.c280
1 files changed, 280 insertions, 0 deletions
diff --git a/layouts/community/ergodox/berfarah/keymap.c b/layouts/community/ergodox/berfarah/keymap.c
new file mode 100644
index 000000000..bc639b189
--- /dev/null
+++ b/layouts/community/ergodox/berfarah/keymap.c
@@ -0,0 +1,280 @@
1// Netable differences vs. the default firmware for the ErgoDox EZ:
2// 1. The Cmd key is now on the right side, making Cmd+Space easier.
3// 2. The media keys work on OSX (But not on Windows).
4#include QMK_KEYBOARD_H
5#include "action_layer.h"
6
7enum keyboard_layers {
8 QWERTY = 0, // default layer
9 NUMS, // numbers + symbols
10 MOVE, // vim-like movement
11 AFK,
12};
13
14enum custom_keycodes {
15 BF_AFK = SAFE_RANGE,
16 BF_WAKE,
17 BF_NUMS,
18 BF_MOVE,
19};
20
21// Dashes (macOS)
22#define KC_NDSH LALT(KC_MINS)
23#define KC_MDSH S(LALT(KC_MINS))
24
25#define VIM_B LALT(KC_LEFT)
26#define VIM_W LALT(KC_RIGHT)
27
28const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
29 /* Keymap 0: Basic layer
30 *
31 * ,--------------------------------------------------. ,--------------------------------------------------.
32 * | | | | | | | | | Power| | | | | | |
33 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
34 * | Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \ |
35 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
36 * |Ctrl/Esc| A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
37 * |--------+------+------+------+------+------| ( | | ) |------+------+------+------+------+--------|
38 * | LShift | Z | X | C | V | B | | | | N | M | , | . | / | RShift |
39 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
40 * |Hyper | F19 |AltShf| | NUMS | | NUMS | |Ctrl/E| F19 | Meh |
41 * `----------------------------------' `----------------------------------'
42 * ,-------------. ,-------------.
43 * | V- | V+ | | Next |Play/Pau|
44 * ,------|------|------| |------+--------+------.
45 * | | | Vx | | Prev | | |
46 * | Space| LGUI |------| |------| Bsp | Enter|
47 * | | | LAlt | | LAlt | | |
48 * `--------------------' `----------------------'
49 */
50 // If it accepts an argument (i.e, is a function), it doesn't need KC_.
51 // Otherwise, it needs KC_*
52 [QWERTY] = KEYMAP( // layer 0 : default
53 // left hand
54 KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
55 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_LBRC,
56 CTL_T(KC_ESC),KC_A, KC_S, KC_D, KC_F, KC_G,
57 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, S(KC_9),
58 ALL_T(KC_NO), KC_F19,KC_LALT,KC_NO, BF_NUMS,
59 KC_VOLD,KC_VOLU,
60 KC_MUTE,
61 KC_SPC,KC_LGUI,KC_LALT,
62
63 // right hand
64 BF_AFK, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
65 KC_RBRC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
66 KC_H, KC_J, KC_K, KC_L, LT(MOVE, KC_SCLN),KC_QUOT,
67 S(KC_0), KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,
68 BF_NUMS,KC_NO, CTL_T(KC_ESC),KC_F19, MEH_T(KC_NO),
69 KC_MNXT,KC_MPLY,
70 KC_MPRV,
71 KC_LALT,KC_BSPC,KC_ENT
72 ),
73
74 /* Keymap: Number Layer
75 *
76 * ,--------------------------------------------------. ,--------------------------------------------------.
77 * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | |
78 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
79 * | ⌘-` | ` | | | | | | | | | | | - | = | |
80 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
81 * | | 1 | 2 | 3 | 4 | 5 |------| |------| 6 | 7 | 8 | 9 | 0 | |
82 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
83 * | | F11 | F12 | F13 | F14 | F15 | | | | F16 | F17 | F18 | F19 | F20 | |
84 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
85 * | | | | | | | | | | | |
86 * `----------------------------------' `----------------------------------'
87 * ,-------------. ,-------------.
88 * | | | | | |
89 * ,------|------|------| |------+------+------.
90 * | | | | | | | |
91 * | | |------| |------| | |
92 * | | | | | | | |
93 * `--------------------' `--------------------'
94 */
95 [NUMS] = KEYMAP(
96 // left hand
97 KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
98 LGUI(KC_GRV),KC_GRV, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,
99 KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5,
100 KC_TRNS, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_TRNS,
101 KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
102 KC_TRNS,KC_TRNS,
103 KC_TRNS,
104 KC_TRNS,KC_TRNS,KC_TRNS,
105
106 // right hand
107 KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS,
108 KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, KC_MINS, KC_EQL, KC_TRNS,
109 KC_6 , KC_7, KC_8, KC_9, KC_0, KC_TRNS,
110 KC_TRNS, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRNS,
111 KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
112 KC_TRNS, KC_TRNS,
113 KC_TRNS,
114 KC_TRNS, KC_TRNS, KC_TRNS
115 ),
116
117 /* Keymap 2: Movement Layer
118 *
119 * ,--------------------------------------------------. ,--------------------------------------------------.
120 * | | | | | | | | | | | | | | | |
121 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
122 * | | |VIM W | | | | | | | ⌘ ← | ⌥ ← | ⌥ → | ⌘ → | | |
123 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
124 * | | | HOME | PGUP | PGDW | END |------| |------| ← | ↓ | ↑ | → | | |
125 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
126 * | | | | | |VIM B | | | | | | | | | |
127 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
128 * | | | | | | | | | | | |
129 * `----------------------------------' `----------------------------------'
130 * ,-------------. ,-------------.
131 * | | | | | |
132 * ,------|------|------| |------+------+------.
133 * | | | | | | | |
134 * | | |------| |------| | |
135 * | | | | | | | |
136 * `--------------------' `--------------------'
137 */
138 [MOVE] = KEYMAP(
139 // left hand
140 KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
141 KC_TRNS,KC_TRNS,VIM_W, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
142 KC_TRNS,KC_TRNS,KC_HOME,KC_PGUP,KC_PGDOWN,KC_END,
143 KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,VIM_B, KC_TRNS,
144 KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
145 KC_TRNS,KC_TRNS,
146 KC_TRNS,
147 KC_TRNS,KC_TRNS,KC_TRNS,
148
149 // right hand
150 KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,
151 KC_TRNS,LGUI(KC_LEFT),LALT(KC_LEFT),LALT(KC_RIGHT),LGUI(KC_RIGHT),KC_TRNS,KC_TRNS,
152 KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_TRNS,KC_TRNS,
153 KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,
154 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,
155 KC_TRNS,KC_TRNS,
156 KC_TRNS,
157 KC_TRNS,KC_TRNS,KC_TRNS
158 ),
159
160 /* Keymap: AFK Layer
161 * All keys wake
162 */
163 [AFK] = KEYMAP(
164 // left hand
165 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
166 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
167 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
168 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
169 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
170 BF_WAKE,BF_WAKE,
171 BF_WAKE,
172 BF_WAKE,BF_WAKE,BF_WAKE,
173
174 // right hand
175 KC_TRNS,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
176 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
177 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
178 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
179 BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,BF_WAKE,
180 BF_WAKE,BF_WAKE,
181 BF_WAKE,
182 BF_WAKE,BF_WAKE,BF_WAKE
183 ),
184};
185
186/*
187 * Led Configuration
188 */
189extern rgblight_config_t rgblight_config;
190
191typedef struct {
192 uint16_t hue :9;
193 uint8_t sat :8;
194 uint8_t val :8;
195 uint8_t mode :6;
196} bf_rgb_data;
197
198bf_rgb_data bf_rgb_config[] = { // color mode
199 [QWERTY] = { .hue = 274, .sat = 255, .val = 36, .mode = 3 }, // purple breathing
200 [MOVE] = { .hue = 180, .sat = 255, .val = 75, .mode = 1 }, // teal solid
201 [NUMS] = { .hue = 120, .sat = 255, .val = 75, .mode = 1 }, // green solid
202 [AFK] = { .hue = 0, .sat = 255, .val = 150, .mode = 22 }, // red knight
203};
204
205static inline void bf_set_led(uint8_t layer) {
206 bf_rgb_data cfg = bf_rgb_config[layer];
207
208 if (rgblight_config.mode != cfg.mode) {
209 rgblight_mode(cfg.mode);
210 }
211
212 rgblight_sethsv(cfg.hue, cfg.sat, cfg.val);
213}
214
215static inline void mod_layer_with_rgb(keyrecord_t *record, uint8_t layer) {
216 if (record->event.pressed) {
217 layer_on(layer);
218 bf_set_led(layer);
219 } else {
220 layer_off(layer);
221 uint8_t currentLayer = biton32(layer_state);
222 bf_set_led(currentLayer);
223 };
224};
225
226/*
227 * Custom keycodes
228 */
229bool process_record_user(uint16_t keycode, keyrecord_t *record) {
230 switch(keycode) {
231 case BF_AFK:
232 if (record->event.pressed) {
233 layer_on(AFK);
234 SEND_STRING(SS_DOWN(X_LCTRL)SS_DOWN(X_LSHIFT)SS_TAP(X_POWER)SS_UP(X_LSHIFT)SS_UP(X_LCTRL));
235 }
236 return false; break;
237 case BF_WAKE:
238 if (record->event.pressed) {
239 layer_off(AFK);
240 SEND_STRING(" ");
241 }
242 return false; break;
243 case BF_NUMS:
244 mod_layer_with_rgb(record, NUMS);
245 return false; break;
246 case BF_MOVE:
247 mod_layer_with_rgb(record, MOVE);
248 return false; break;
249 }
250
251 return true;
252};
253
254/*
255 * Active Routines
256 */
257void matrix_init_user(void) {
258 bf_set_led(QWERTY);
259};
260
261// Runs constantly in the background, in a loop.
262void matrix_scan_user(void) {
263 uint8_t layer = biton32(layer_state);
264
265 ergodox_right_led_1_off();
266 ergodox_right_led_2_off();
267 ergodox_right_led_3_off();
268
269 switch (layer) {
270 case NUMS:
271 ergodox_right_led_2_on();
272 break;
273 case MOVE:
274 ergodox_right_led_3_on();
275 break;
276 case AFK:
277 ergodox_right_led_1_on();
278 break;
279 }
280};