diff options
Diffstat (limited to 'layouts/community/ergodox/drashna/keymap.c')
| -rw-r--r-- | layouts/community/ergodox/drashna/keymap.c | 129 |
1 files changed, 66 insertions, 63 deletions
diff --git a/layouts/community/ergodox/drashna/keymap.c b/layouts/community/ergodox/drashna/keymap.c index 74382f175..763b218f7 100644 --- a/layouts/community/ergodox/drashna/keymap.c +++ b/layouts/community/ergodox/drashna/keymap.c | |||
| @@ -18,21 +18,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 18 | #include "drashna.h" | 18 | #include "drashna.h" |
| 19 | 19 | ||
| 20 | #ifdef UNICODEMAP_ENABLE | 20 | #ifdef UNICODEMAP_ENABLE |
| 21 | #include "drashna_unicode.h" | 21 | # include "drashna_unicode.h" |
| 22 | #endif // UNICODEMAP_ENABLE | 22 | #endif // UNICODEMAP_ENABLE |
| 23 | #ifndef UNICODE_ENABLE | 23 | #ifndef UNICODE_ENABLE |
| 24 | # define UC(x) KC_NO | 24 | # define UC(x) KC_NO |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | extern userspace_config_t userspace_config; | 27 | extern userspace_config_t userspace_config; |
| 28 | 28 | ||
| 29 | enum more_custom_keycodes { | 29 | enum more_custom_keycodes { KC_SWAP_NUM = NEW_SAFE_RANGE }; |
| 30 | KC_SWAP_NUM = NEW_SAFE_RANGE | ||
| 31 | }; | ||
| 32 | 30 | ||
| 33 | //define layer change stuff for underglow indicator | 31 | // define layer change stuff for underglow indicator |
| 34 | bool skip_leds = false; | 32 | bool skip_leds = false; |
| 35 | 33 | ||
| 34 | // clang-format off | ||
| 36 | #define LAYOUT_ergodox_pretty_base( \ | 35 | #define LAYOUT_ergodox_pretty_base( \ |
| 37 | K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ | 36 | K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ |
| 38 | K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ | 37 | K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ |
| @@ -301,9 +300,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 301 | ), | 300 | ), |
| 302 | 301 | ||
| 303 | }; | 302 | }; |
| 303 | // clang-format on | ||
| 304 | 304 | ||
| 305 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | 305 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { |
| 306 | |||
| 307 | switch (keycode) { | 306 | switch (keycode) { |
| 308 | case KC_1: | 307 | case KC_1: |
| 309 | if (IS_LAYER_ON(_GAMEPAD) && userspace_config.swapped_numbers) { | 308 | if (IS_LAYER_ON(_GAMEPAD) && userspace_config.swapped_numbers) { |
| @@ -332,7 +331,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 332 | } | 331 | } |
| 333 | break; | 332 | break; |
| 334 | } | 333 | } |
| 335 | //switch (keycode) { | 334 | // switch (keycode) { |
| 336 | // case KC_P00: | 335 | // case KC_P00: |
| 337 | // if (!record->event.pressed) { | 336 | // if (!record->event.pressed) { |
| 338 | // register_code(KC_KP_0); | 337 | // register_code(KC_KP_0); |
| @@ -347,9 +346,9 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 347 | } | 346 | } |
| 348 | 347 | ||
| 349 | void matrix_scan_keymap(void) { // runs frequently to update info | 348 | void matrix_scan_keymap(void) { // runs frequently to update info |
| 350 | uint8_t modifiers = get_mods(); | 349 | uint8_t modifiers = get_mods(); |
| 351 | uint8_t led_usb_state = host_keyboard_leds(); | 350 | uint8_t led_usb_state = host_keyboard_leds(); |
| 352 | uint8_t one_shot = get_oneshot_mods(); | 351 | uint8_t one_shot = get_oneshot_mods(); |
| 353 | 352 | ||
| 354 | if (!skip_leds) { | 353 | if (!skip_leds) { |
| 355 | ergodox_board_led_off(); | 354 | ergodox_board_led_off(); |
| @@ -360,24 +359,21 @@ void matrix_scan_keymap(void) { // runs frequently to update info | |||
| 360 | // Since we're not using the LEDs here for layer indication anymore, | 359 | // Since we're not using the LEDs here for layer indication anymore, |
| 361 | // then lets use them for modifier indicators. Shame we don't have 4... | 360 | // then lets use them for modifier indicators. Shame we don't have 4... |
| 362 | // Also, no "else", since we want to know each, independently. | 361 | // Also, no "else", since we want to know each, independently. |
| 363 | if ( ( modifiers | one_shot ) & MOD_MASK_SHIFT || led_usb_state & (1<<USB_LED_CAPS_LOCK) ) { | 362 | if ((modifiers | one_shot) & MOD_MASK_SHIFT || led_usb_state & (1 << USB_LED_CAPS_LOCK)) { |
| 364 | ergodox_right_led_2_on(); | 363 | ergodox_right_led_2_on(); |
| 365 | ergodox_right_led_2_set( 50 ); | 364 | ergodox_right_led_2_set(50); |
| 366 | } | 365 | } |
| 367 | if ( ( modifiers | one_shot ) & MOD_MASK_CTRL) { | 366 | if ((modifiers | one_shot) & MOD_MASK_CTRL) { |
| 368 | ergodox_right_led_1_on(); | 367 | ergodox_right_led_1_on(); |
| 369 | ergodox_right_led_1_set( 10 ); | 368 | ergodox_right_led_1_set(10); |
| 370 | } | 369 | } |
| 371 | if ( ( modifiers | one_shot ) & MOD_MASK_ALT) { | 370 | if ((modifiers | one_shot) & MOD_MASK_ALT) { |
| 372 | ergodox_right_led_3_on(); | 371 | ergodox_right_led_3_on(); |
| 373 | ergodox_right_led_3_set( 10 ); | 372 | ergodox_right_led_3_set(10); |
| 374 | } | 373 | } |
| 375 | |||
| 376 | } | 374 | } |
| 377 | |||
| 378 | } | 375 | } |
| 379 | 376 | ||
| 380 | |||
| 381 | bool indicator_is_this_led_used_keyboard(uint8_t index) { | 377 | bool indicator_is_this_led_used_keyboard(uint8_t index) { |
| 382 | switch (index) { | 378 | switch (index) { |
| 383 | case 13 ... 14: | 379 | case 13 ... 14: |
| @@ -388,76 +384,83 @@ bool indicator_is_this_led_used_keyboard(uint8_t index) { | |||
| 388 | } | 384 | } |
| 389 | } | 385 | } |
| 390 | 386 | ||
| 391 | |||
| 392 | #ifdef RGB_MATRIX_ENABLE | 387 | #ifdef RGB_MATRIX_ENABLE |
| 393 | 388 | ||
| 394 | void suspend_power_down_keymap(void) { | 389 | void suspend_power_down_keymap(void) { rgb_matrix_set_suspend_state(true); } |
| 395 | rgb_matrix_set_suspend_state(true); | ||
| 396 | } | ||
| 397 | 390 | ||
| 398 | void suspend_wakeup_init_keymap(void) { | 391 | void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); } |
| 399 | rgb_matrix_set_suspend_state(false); | ||
| 400 | } | ||
| 401 | 392 | ||
| 402 | void rgb_matrix_indicators_user(void) { | 393 | void rgb_matrix_indicators_user(void) { |
| 403 | if ( userspace_config.rgb_layer_change && | 394 | if (userspace_config.rgb_layer_change && |
| 404 | #ifdef RGB_DISABLE_WHEN_USB_SUSPENDED | 395 | # ifdef RGB_DISABLE_WHEN_USB_SUSPENDED |
| 405 | !g_suspend_state && | 396 | !g_suspend_state && |
| 406 | #endif | 397 | # endif |
| 407 | #if defined(RGBLIGHT_ENABLE) | 398 | # if defined(RGBLIGHT_ENABLE) |
| 408 | (!rgblight_config.enable && rgb_matrix_config.enable) | 399 | (!rgblight_config.enable && rgb_matrix_config.enable) |
| 409 | #else | 400 | # else |
| 410 | rgb_matrix_config.enable | 401 | rgb_matrix_config.enable |
| 411 | #endif | 402 | # endif |
| 412 | ) { | 403 | ) { |
| 413 | switch (biton32(layer_state)) { | 404 | switch (biton32(layer_state)) { |
| 414 | case _MODS: | ||
| 415 | rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break; | ||
| 416 | case _GAMEPAD: | 405 | case _GAMEPAD: |
| 417 | rgb_matrix_layer_helper(0xFF, 0x80, 0x00, LED_FLAG_MODIFIER); | 406 | rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 418 | rgb_matrix_set_color(32, 0x00, 0xFF, 0x00); // Q | 407 | rgb_matrix_set_color(32, 0x00, 0xFF, 0x00); // Q |
| 419 | rgb_matrix_set_color(31, 0x00, 0xFF, 0xFF); // W | 408 | rgb_matrix_set_color(31, 0x00, 0xFF, 0xFF); // W |
| 420 | rgb_matrix_set_color(30, 0xFF, 0x00, 0x00); // E | 409 | rgb_matrix_set_color(30, 0xFF, 0x00, 0x00); // E |
| 421 | rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); // R | 410 | rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); // R |
| 422 | rgb_matrix_set_color(37, 0x00, 0xFF, 0xFF); // A | 411 | rgb_matrix_set_color(37, 0x00, 0xFF, 0xFF); // A |
| 423 | rgb_matrix_set_color(36, 0x00, 0xFF, 0xFF); // S | 412 | rgb_matrix_set_color(36, 0x00, 0xFF, 0xFF); // S |
| 424 | rgb_matrix_set_color(35, 0x00, 0xFF, 0xFF); // D | 413 | rgb_matrix_set_color(35, 0x00, 0xFF, 0xFF); // D |
| 425 | rgb_matrix_set_color(34, 0x7A, 0x00, 0xFF); // F | 414 | rgb_matrix_set_color(34, 0x7A, 0x00, 0xFF); // F |
| 426 | 415 | ||
| 427 | rgb_matrix_set_color(userspace_config.swapped_numbers ? 27 : 26, 0xFF, 0xFF, 0xFF); // 1 | 416 | rgb_matrix_set_color(userspace_config.swapped_numbers ? 27 : 26, 0xFF, 0xFF, 0xFF); // 1 |
| 428 | rgb_matrix_set_color(userspace_config.swapped_numbers ? 26 : 27, 0x00, 0xFF, 0x00); // 2 | 417 | rgb_matrix_set_color(userspace_config.swapped_numbers ? 26 : 27, 0x00, 0xFF, 0x00); // 2 |
| 429 | rgb_matrix_set_color(25, 0x7A, 0x00, 0xFF); // 3 | 418 | rgb_matrix_set_color(25, 0x7A, 0x00, 0xFF); // 3 |
| 430 | |||
| 431 | break; | 419 | break; |
| 432 | case _DIABLO: | 420 | case _DIABLO: |
| 433 | rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_MODIFIER); break; | 421 | rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed * 8, LED_FLAG_MODIFIER); |
| 422 | break; | ||
| 434 | case _RAISE: | 423 | case _RAISE: |
| 435 | rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break; | 424 | rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 425 | break; | ||
| 436 | case _LOWER: | 426 | case _LOWER: |
| 437 | rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_MODIFIER); break; | 427 | rgb_matrix_layer_helper(HSV_GREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 428 | break; | ||
| 438 | case _ADJUST: | 429 | case _ADJUST: |
| 439 | rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_MODIFIER); break; | 430 | rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 440 | default: | 431 | break; |
| 432 | default: { | ||
| 433 | bool mods_enabled = IS_LAYER_ON(_MODS); | ||
| 441 | switch (biton32(default_layer_state)) { | 434 | switch (biton32(default_layer_state)) { |
| 442 | case _QWERTY: | 435 | case _QWERTY: |
| 443 | rgb_matrix_layer_helper(0x00, 0xFF, 0xFF, LED_FLAG_MODIFIER); break; | 436 | rgb_matrix_layer_helper(HSV_CYAN, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 437 | break; | ||
| 444 | case _COLEMAK: | 438 | case _COLEMAK: |
| 445 | rgb_matrix_layer_helper(0xFF, 0x00, 0xFF, LED_FLAG_MODIFIER); break; | 439 | rgb_matrix_layer_helper(HSV_MAGENTA, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 440 | break; | ||
| 446 | case _DVORAK: | 441 | case _DVORAK: |
| 447 | rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_MODIFIER); break; | 442 | rgb_matrix_layer_helper(HSV_SPRINGGREEN, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 443 | break; | ||
| 448 | case _WORKMAN: | 444 | case _WORKMAN: |
| 449 | rgb_matrix_layer_helper(0xD9, 0xA5, 0x21, LED_FLAG_MODIFIER); break; | 445 | rgb_matrix_layer_helper(HSV_GOLDENROD, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 446 | break; | ||
| 450 | case _NORMAN: | 447 | case _NORMAN: |
| 451 | rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D, LED_FLAG_MODIFIER); break; | 448 | rgb_matrix_layer_helper(HSV_CORAL, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 449 | break; | ||
| 452 | case _MALTRON: | 450 | case _MALTRON: |
| 453 | rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break; | 451 | rgb_matrix_layer_helper(HSV_YELLOW, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 452 | break; | ||
| 454 | case _EUCALYN: | 453 | case _EUCALYN: |
| 455 | rgb_matrix_layer_helper(0xFF, 0x80, 0xBF, LED_FLAG_MODIFIER); break; | 454 | rgb_matrix_layer_helper(HSV_PINK, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 455 | break; | ||
| 456 | case _CARPLAX: | 456 | case _CARPLAX: |
| 457 | rgb_matrix_layer_helper(0x00, 0x00, 0xFF, LED_FLAG_MODIFIER); break; | 457 | rgb_matrix_layer_helper(HSV_BLUE, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER); |
| 458 | break; | ||
| 458 | } | 459 | } |
| 460 | break; | ||
| 461 | } | ||
| 459 | } | 462 | } |
| 460 | } | 463 | } |
| 461 | } | 464 | } |
| 462 | 465 | ||
| 463 | #endif //RGB_MATRIX_INIT | 466 | #endif // RGB_MATRIX_INIT |
