aboutsummaryrefslogtreecommitdiff
path: root/layouts/community/ortho_4x12/drashna/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/community/ortho_4x12/drashna/keymap.c')
-rw-r--r--layouts/community/ortho_4x12/drashna/keymap.c312
1 files changed, 176 insertions, 136 deletions
diff --git a/layouts/community/ortho_4x12/drashna/keymap.c b/layouts/community/ortho_4x12/drashna/keymap.c
index f82b4e7da..5eef2e023 100644
--- a/layouts/community/ortho_4x12/drashna/keymap.c
+++ b/layouts/community/ortho_4x12/drashna/keymap.c
@@ -34,6 +34,18 @@ enum planck_keycodes {
34 #define BACKLIT OSM(MOD_LSFT) 34 #define BACKLIT OSM(MOD_LSFT)
35#endif 35#endif
36 36
37#ifdef KEYBOARD_planck_ez
38# define PLNK_1 BK_LWER
39# define PLNK_2 SP_LWER
40# define PLNK_3 KC_NO
41# define PLNK_4 ET_RAIS
42#else
43# define PLNK_1 SP_LWER
44# define PLNK_2 BK_LWER
45# define PLNK_3 DL_RAIS
46# define PLNK_4 ET_RAIS
47#endif
48
37#define LAYOUT_ortho_4x12_base( \ 49#define LAYOUT_ortho_4x12_base( \
38 K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ 50 K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
39 K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ 51 K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \
@@ -42,8 +54,8 @@ enum planck_keycodes {
42 LAYOUT_ortho_4x12_wrapper( \ 54 LAYOUT_ortho_4x12_wrapper( \
43 KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_BSPC, \ 55 KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_BSPC, \
44 KC_TAB, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, KC_QUOT, \ 56 KC_TAB, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, KC_QUOT, \
45 KC_MLSF, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, CTL_T(K2A), KC_ENT, \ 57 KC_MLSF, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), KC_ENT, \
46 BACKLIT, OS_LCTL, OS_LALT, OS_LGUI, SP_LWER, BK_LWER, DL_RAIS, ET_RAIS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ 58 BACKLIT, OS_LCTL, OS_LALT, OS_LGUI, PLNK_1, PLNK_2, PLNK_3, PLNK_4, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
47 ) 59 )
48#define LAYOUT_ortho_4x12_base_wrapper(...) LAYOUT_ortho_4x12_base(__VA_ARGS__) 60#define LAYOUT_ortho_4x12_base_wrapper(...) LAYOUT_ortho_4x12_base(__VA_ARGS__)
49 61
@@ -130,128 +142,132 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
130 142
131 143
132bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { 144bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
133 switch (keycode) { 145 switch (keycode) {
134 146 #ifdef BACKLIGHT_ENABLE
135#ifdef BACKLIGHT_ENABLE 147 case BACKLIT:
136 case BACKLIT: 148 if (record->event.pressed) {
137 if (record->event.pressed) { 149 register_code(KC_RSFT);
138 register_code(KC_RSFT); 150 #ifdef BACKLIGHT_ENABLE
139 #ifdef BACKLIGHT_ENABLE 151 backlight_step();
140 backlight_step(); 152 #endif
141 #endif 153 } else {
142 } else { 154 unregister_code(KC_RSFT);
143 unregister_code(KC_RSFT); 155 }
144 } 156 return false;
145 return false; 157 break;
146 break;
147#endif 158#endif
148 } 159 }
149 return true; 160 return true;
150} 161}
151 162
152bool music_mask_user(uint16_t keycode) { 163bool music_mask_user(uint16_t keycode) {
153 switch (keycode) { 164 switch (keycode) {
154 case RAISE: 165 case RAISE:
155 case LOWER: 166 case LOWER:
156 case BK_LWER: 167 case BK_LWER:
157 case SP_LWER: 168 case SP_LWER:
158 case DL_RAIS: 169 case DL_RAIS:
159 case ET_RAIS: 170 case ET_RAIS:
160 return false; 171 return false;
161 default: 172 default:
162 return true; 173 return true;
163 } 174 }
164} 175}
165 176
166#ifdef RGB_MATRIX_ENABLE 177#ifdef RGB_MATRIX_ENABLE
167 178
168void suspend_power_down_keymap(void) { 179void suspend_power_down_keymap(void) {
169 rgb_matrix_set_suspend_state(true); 180 rgb_matrix_set_suspend_state(true);
170 rgb_matrix_config.enable = false;
171} 181}
172 182
173void suspend_wakeup_init_keymap(void) { 183void suspend_wakeup_init_keymap(void) {
174 rgb_matrix_config.enable = true;
175 rgb_matrix_set_suspend_state(false); 184 rgb_matrix_set_suspend_state(false);
176} 185}
177 186
178void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) { 187void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
179 rgb_led led; 188 rgb_led led;
180 for (int i = 0; i < DRIVER_LED_TOTAL; i++) { 189 for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
181 led = g_rgb_leds[i]; 190 led = g_rgb_leds[i];
182 if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) { 191 if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) {
183 rgb_matrix_set_color( i, red, green, blue ); 192 rgb_matrix_set_color( i, red, green, blue );
193 }
184 } 194 }
185 }
186} 195}
187 196
188void rgb_matrix_indicators_user(void) { 197void rgb_matrix_indicators_user(void) {
189 uint8_t this_mod = get_mods(); 198 uint8_t this_mod = get_mods();
190 uint8_t this_led = host_keyboard_leds(); 199 uint8_t this_led = host_keyboard_leds();
191 uint8_t this_osm = get_oneshot_mods(); 200 uint8_t this_osm = get_oneshot_mods();
192 201 bool is_ez;
193 if (!g_suspend_state && userspace_config.rgb_layer_change && 202 #ifdef KEYBOARD_planck_ez
194#if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE) 203 is_ez = true;
195 (!rgblight_config.enable && rgb_matrix_config.enable) 204 #endif
205
206 if ( userspace_config.rgb_layer_change &&
207#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
208 !g_suspend_state &&
209#endif
210#if defined(RGBLIGHT_ENABLE)
211 (!rgblight_config.enable && rgb_matrix_config.enable)
196#else 212#else
197 rgb_matrix_config.enable 213 rgb_matrix_config.enable
198#endif 214#endif
199 ) { 215 ) {
200 switch (biton32(layer_state)) { 216 switch (biton32(layer_state)) {
201 case _RAISE: 217 case _RAISE:
202 rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, false); break; 218 rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
203 case _LOWER: 219 case _LOWER:
204 rgb_matrix_layer_helper(0x00, 0xFF, 0x00, false); break; 220 rgb_matrix_layer_helper(0x00, 0xFF, 0x00); break;
205 case _ADJUST: 221 case _ADJUST:
206 rgb_matrix_layer_helper(0xFF, 0x00, 0x00, false); break; 222 rgb_matrix_layer_helper(0xFF, 0x00, 0x00); break;
207 default: 223 default:
208 switch (biton32(default_layer_state)) { 224 switch (biton32(default_layer_state)) {
209 case _QWERTY: 225 case _QWERTY:
210 rgb_matrix_layer_helper(0x00, 0xFF, 0xFF, true); break; 226 rgb_matrix_layer_helper(0x00, 0xFF, 0xFF); break;
211 case _COLEMAK: 227 case _COLEMAK:
212 rgb_matrix_layer_helper(0xFF, 0x00, 0xFF, true); break; 228 rgb_matrix_layer_helper(0xFF, 0x00, 0xFF); break;
213 case _DVORAK: 229 case _DVORAK:
214 rgb_matrix_layer_helper(0x00, 0xFF, 0x00, true); break; 230 rgb_matrix_layer_helper(0x00, 0xFF, 0x00); break;
215 case _WORKMAN: 231 case _WORKMAN:
216 rgb_matrix_layer_helper(0xD9, 0xA5, 0x21, true); break; 232 rgb_matrix_layer_helper(0xD9, 0xA5, 0x21); break;
217 case _NORMAN: 233 case _NORMAN:
218 rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D, true); break; 234 rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D); break;
219 case _MALTRON: 235 case _MALTRON:
220 rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, true); break; 236 rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
221 case _EUCALYN: 237 case _EUCALYN:
222 rgb_matrix_layer_helper(0xFF, 0x80, 0xBF, true); break; 238 rgb_matrix_layer_helper(0xFF, 0x80, 0xBF); break;
223 case _CARPLAX: 239 case _CARPLAX:
224 rgb_matrix_layer_helper(0x00, 0x00, 0xFF, true); break; 240 rgb_matrix_layer_helper(0x00, 0x00, 0xFF); break;
241 }
225 } 242 }
226 } 243 }
227 } 244
228 245 switch (biton32(default_layer_state)) {
229 switch (biton32(default_layer_state)) { 246 case _QWERTY:
230 case _QWERTY: 247 rgb_matrix_set_color(is_ez ? 41 : 42, 0x00, 0xFF, 0xFF); break;
231 rgb_matrix_set_color(42, 0x00, 0xFF, 0xFF); break; 248 case _COLEMAK:
232 case _COLEMAK: 249 rgb_matrix_set_color(is_ez ? 41 : 42, 0xFF, 0x00, 0xFF); break;
233 rgb_matrix_set_color(42, 0xFF, 0x00, 0xFF); break; 250 case _DVORAK:
234 case _DVORAK: 251 rgb_matrix_set_color(is_ez ? 41 : 42, 0x00, 0xFF, 0x00); break;
235 rgb_matrix_set_color(42, 0x00, 0xFF, 0x00); break; 252 case _WORKMAN:
236 case _WORKMAN: 253 rgb_matrix_set_color(is_ez ? 41 : 42, 0xD9, 0xA5, 0x21); break;
237 rgb_matrix_set_color(42, 0xD9, 0xA5, 0x21); break; 254 }
238 } 255 if ( (this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1<<USB_LED_CAPS_LOCK)) {
239 if ( (this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1<<USB_LED_CAPS_LOCK)) { 256 rgb_matrix_set_color(24, 0x00, 0xFF, 0x00);
240 rgb_matrix_set_color(24, 0x00, 0xFF, 0x00); 257 rgb_matrix_set_color(36, 0x00, 0xFF, 0x00);
241 rgb_matrix_set_color(36, 0x00, 0xFF, 0x00); 258 }
242 } 259 if ( (this_mod | this_osm) & MOD_MASK_CTRL) {
243 if ( (this_mod | this_osm) & MOD_MASK_CTRL) { 260 rgb_matrix_set_color(25, 0xFF, 0x00, 0x00);
244 rgb_matrix_set_color(25, 0xFF, 0x00, 0x00); 261 rgb_matrix_set_color(34, 0xFF, 0x00, 0x00);
245 rgb_matrix_set_color(34, 0xFF, 0x00, 0x00); 262 rgb_matrix_set_color(37, 0xFF, 0x00, 0x00);
246 rgb_matrix_set_color(37, 0xFF, 0x00, 0x00); 263
247 264 }
248 } 265 if ( (this_mod | this_osm) & MOD_MASK_GUI) {
249 if ( (this_mod | this_osm) & MOD_MASK_GUI) { 266 rgb_matrix_set_color(39, 0xFF, 0xD9, 0x00);
250 rgb_matrix_set_color(39, 0xFF, 0xD9, 0x00); 267 }
251 } 268 if ( (this_mod | this_osm) & MOD_MASK_ALT) {
252 if ( (this_mod | this_osm) & MOD_MASK_ALT) { 269 rgb_matrix_set_color(38, 0x00, 0x00, 0xFF);
253 rgb_matrix_set_color(38, 0x00, 0x00, 0xFF); 270 }
254 }
255} 271}
256 272
257void matrix_init_keymap(void) { 273void matrix_init_keymap(void) {
@@ -260,57 +276,81 @@ void matrix_init_keymap(void) {
260#else //RGB_MATRIX_INIT 276#else //RGB_MATRIX_INIT
261 277
262void matrix_init_keymap(void) { 278void matrix_init_keymap(void) {
263 #if !defined(CONVERT_TO_PROTON_C) && !defined(KEYBOARD_planck) 279#if !defined(CONVERT_TO_PROTON_C) && !defined(KEYBOARD_planck)
264 setPinOutput(D5); 280 setPinOutput(D5);
265 writePinHigh(D5); 281 writePinHigh(D5);
266 282
267 setPinOutput(B0); 283 setPinOutput(B0);
268 writePinHigh(B0); 284 writePinHigh(B0);
269 #endif 285#endif
270} 286}
271#endif //RGB_MATRIX_INIT 287#endif //RGB_MATRIX_INIT
272 288
273#ifdef ENCODER_ENABLE 289#ifdef ENCODER_ENABLE
274void encoder_update(bool clockwise) { 290void encoder_update(bool clockwise) {
275 switch (biton32(layer_state)) { 291 switch (biton32(layer_state)) {
276 case _RAISE: 292 case _RAISE:
277 clockwise ? tap_code(KC_VOLD) : tap_code(KC_VOLU); 293 clockwise ? tap_code(KC_VOLD) : tap_code(KC_VOLU);
278 break; 294 break;
279 case _LOWER: 295 case _LOWER:
280 #ifdef RGB_MATRIX_ENABLE 296#ifdef RGB_MATRIX_ENABLE
281 clockwise ? rgb_matrix_step() : rgblight_step_reverse(); 297 clockwise ? rgb_matrix_step() : rgblight_step_reverse();
282 #else 298#else
283 clockwise ? tap_code(KC_PGDN) : tap_code(KC_PGUP); 299 clockwise ? tap_code(KC_PGDN) : tap_code(KC_PGUP);
284 #endif 300#endif
285 case _ADJUST: 301 break;
286 #ifdef AUDIO_CLICKY 302 case _ADJUST:
287 clockwise ? clicky_freq_up() : clicky_freq_down(); 303#ifdef AUDIO_CLICKY
288 #endif 304 clockwise ? clicky_freq_up() : clicky_freq_down();
289 break; 305#endif
290 default: 306 break;
291 clockwise ? tap_code(KC_DOWN) : tap_code(KC_UP); 307 default:
292 } 308 clockwise ? tap_code(KC_DOWN) : tap_code(KC_UP);
293 #ifdef AUDIO_CLICKY 309 }
310#ifdef AUDIO_CLICKY
294 clicky_play(); 311 clicky_play();
295 #endif 312#endif
296} 313}
297#endif // ENCODER_ENABLE 314#endif // ENCODER_ENABLE
298 315
299#ifdef KEYBOARD_planck_rev6 316#ifdef KEYBOARD_planck_rev6
300void dip_update(uint8_t index, bool active) { 317void dip_update(uint8_t index, bool active) {
301 switch (index) { 318 switch (index) {
302 case 0: 319 case 0:
303 if(active) { audio_on(); } else { audio_off(); } 320 if(active) { audio_on(); } else { audio_off(); }
304 break; 321 break;
305 case 1: 322 case 1:
306 if(active) { clicky_on(); } else { clicky_off(); } 323 if(active) { clicky_on(); } else { clicky_off(); }
307 break; 324 break;
308 case 2: 325 case 2:
309 keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = active; 326 keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = active;
310 break; 327 break;
311 case 3: 328 case 3:
312 userspace_config.nuke_switch = active; 329 userspace_config.nuke_switch = active;
313 break; 330 break;
314 } 331 }
315} 332}
316#endif // KEYBOARD_planck_rev6 333#endif // KEYBOARD_planck_rev6
334
335#ifdef KEYBOARD_planck_ez
336uint32_t layer_state_set_keymap(uint32_t state) {
337
338 palClearPad(GPIOB, 8);
339 palClearPad(GPIOB, 9);
340 switch (biton32(state)) {
341 case _LOWER:
342 palSetPad(GPIOB, 9);
343 break;
344 case _RAISE:
345 palSetPad(GPIOB, 8);
346 break;
347 case _ADJUST:
348 palSetPad(GPIOB, 9);
349 palSetPad(GPIOB, 8);
350 break;
351 default:
352 break;
353 }
354 return state;
355}
356#endif