// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); if(layer == 1) { ergodox_right_led_2_on(); ergodox_right_led_3_on(); ergodox_right_led_2_set (LED_BRIGHTNESS_HI); ergodox_right_led_3_set (LED_BRIGHTNESS_HI); } if(capsOn) { ergodox_right_led_1_set (LED_BRIGHTNESS_HI); ergodox_right_led_1_on (); } if(keyboard_report->mods & MOD_BIT(KC_LSFT)) { ergodox_right_led_1_set (LED_BRIGHTNESS_HI); ergodox_right_led_1_on (); } else { ergodox_right_led_1_set (LED_BRIGHTNESS_LO); if(!capsOn) { ergodox_right_led_1_off (); } } if(keyboard_report->mods & MOD_BIT(KC_LALT)) { ergodox_right_led_2_set (LED_BRIGHTNESS_HI); ergodox_right_led_2_on (); } else { ergodox_right_led_2_set (LED_BRIGHTNESS_LO); if(layer != 1) { ergodox_right_led_2_off (); } } if(keyboard_report->mods & MOD_BIT(KC_LCTRL)) { ergodox_right_led_3_set (LED_BRIGHTNESS_HI); ergodox_right_led_3_on (); } else { ergodox_right_led_3_set (LED_BRIGHTNESS_LO); if(layer != 1) { ergodox_right_led_3_off (); } } };
void matrix_scan_keymap(void) { // runs frequently to update info uint8_t modifiers = get_mods(); uint8_t led_usb_state = host_keyboard_leds(); uint8_t one_shot = get_oneshot_mods(); if (!skip_leds) { ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); // Since we're not using the LEDs here for layer indication anymore, // then lets use them for modifier indicators. Shame we don't have 4... // Also, no "else", since we want to know each, independently. if ( ( modifiers | one_shot ) & MOD_MASK_SHIFT || led_usb_state & (1<<USB_LED_CAPS_LOCK) ) { ergodox_right_led_2_on(); ergodox_right_led_2_set( 50 ); } if ( ( modifiers | one_shot ) & MOD_MASK_CTRL) { ergodox_right_led_1_on(); ergodox_right_led_1_set( 10 ); } if ( ( modifiers | one_shot ) & MOD_MASK_ALT) { ergodox_right_led_3_on(); ergodox_right_led_3_set( 10 ); } } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_led_all_off(); ergodox_led_all_set(LED_BRIGHTNESS_LO); switch (layer) { case BASE: current_layer = BASE; break; case KEYPAD: current_layer = KEYPAD; break; default: // none break; } // layer leds if (current_layer == KEYPAD) { ergodox_right_led_3_on(); } // capslock if (host_keyboard_leds() & (3<<USB_LED_CAPS_LOCK)) { ergodox_right_led_1_on(); } // Temporary leds // The function layer takes over other layers and we need to reflect that on the leds. // If the current layer is the BASE, we simply turn on the FN led, but if the current // layer is the KEYPAD, than we must turn it off before turning on the FN led. if (layer == FN && !has_oneshot_layer_timed_out()) { ergodox_right_led_3_off(); ergodox_right_led_2_on(); } // if the shifted is pressed I show the case led in a brighter color. This is nice to // differenciate the shift from the capslock. // Notice that I make sure that we're not using the shift on a chord shortcut (pressing // shift togather with other modifiers). if((keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && // is shift pressed and there is no other !(keyboard_report->mods & (~MOD_BIT(KC_LSFT) & ~MOD_BIT(KC_RSFT)))) || // modifier being pressed as well (get_oneshot_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && !has_oneshot_mods_timed_out())) { // or the one shot shift didn't timed out ergodox_right_led_1_set(LED_BRIGHTNESS_HI); ergodox_right_led_1_on(); } };
void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); if (keyboard_report->mods & MOD_BIT(KC_LSFT) || ((get_oneshot_mods() & MOD_BIT(KC_LSFT)) && !has_oneshot_mods_timed_out())) { ergodox_right_led_1_set(LED_BRIGHTNESS_HI); ergodox_right_led_1_on(); } else if (layer == RAISE || layer == AUX) { ergodox_right_led_1_set(LED_BRIGHTNESS_LO); ergodox_right_led_1_on(); } else { ergodox_right_led_1_off(); } if (keyboard_report->mods & MOD_BIT(KC_LCTL) || ((get_oneshot_mods() & MOD_BIT(KC_LCTL)) && !has_oneshot_mods_timed_out())) { ergodox_right_led_2_set(LED_BRIGHTNESS_HI); ergodox_right_led_2_on(); } else if (layer == LOWER || layer == AUX) { ergodox_right_led_2_set(LED_BRIGHTNESS_LO); ergodox_right_led_2_on(); } else { ergodox_right_led_2_off(); } if (keyboard_report->mods & MOD_BIT(KC_LALT) || ((get_oneshot_mods() & MOD_BIT(KC_LALT)) && !has_oneshot_mods_timed_out())) { ergodox_right_led_3_set(LED_BRIGHTNESS_HI); ergodox_right_led_3_on(); } else if (layer == COLE || layer == AUX) { ergodox_right_led_3_set(LED_BRIGHTNESS_LO); ergodox_right_led_3_on(); } else { ergodox_right_led_3_off(); } LEADER_DICTIONARY() { leading = false; leader_end(); SEQ_THREE_KEYS(KC_W, KC_I, KC_N) { os_type = OS_WIN; }; SEQ_THREE_KEYS(KC_O, KC_S, KC_X) { os_type = OS_OSX; }; SEQ_THREE_KEYS(KC_L, KC_I, KC_N) { os_type = OS_LIN; }; SEQ_ONE_KEY(KC_A) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_2); tap(KC_KP_2); tap(KC_KP_8); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); register_code(KC_RSFT); register_code(KC_SCLN); unregister_code(KC_SCLN); unregister_code(KC_RSFT); unregister_code(KC_RALT); tap(KC_A); break; case OS_LIN: tap(KC_RALT); tap(KC_DQT); tap(KC_A); break; } } SEQ_TWO_KEYS(KC_A, KC_A) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_1); tap(KC_KP_9); tap(KC_KP_6); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); register_code(KC_RSFT); register_code(KC_SCLN); unregister_code(KC_SCLN); unregister_code(KC_RSFT); unregister_code(KC_RALT); register_code(KC_LSFT); register_code(KC_A); unregister_code(KC_A); unregister_code(KC_LSFT); break; case OS_LIN: tap(KC_RALT); tap(KC_DQT); register_code(KC_LSFT); register_code(KC_A); unregister_code(KC_A); unregister_code(KC_LSFT); break; } } SEQ_ONE_KEY(KC_O) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_2); tap(KC_KP_4); tap(KC_KP_6); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); register_code(KC_RSFT); register_code(KC_SCLN); unregister_code(KC_SCLN); unregister_code(KC_RSFT); unregister_code(KC_RALT); tap(KC_O); break; case OS_LIN: tap(KC_RALT); tap(KC_DQT); tap(KC_O); break; } } SEQ_TWO_KEYS(KC_O, KC_O) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_2); tap(KC_KP_1); tap(KC_KP_4); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); register_code(KC_RSFT); register_code(KC_SCLN); unregister_code(KC_SCLN); unregister_code(KC_RSFT); unregister_code(KC_RALT); tap(LSFT(KC_O)); break; case OS_LIN: tap(KC_RALT); tap(KC_DQT); register_code(KC_LSFT); register_code(KC_O); unregister_code(KC_O); unregister_code(KC_LSFT); break; } } SEQ_ONE_KEY(KC_U) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_2); tap(KC_KP_5); tap(KC_KP_2); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); register_code(KC_RSFT); register_code(KC_SCLN); unregister_code(KC_SCLN); unregister_code(KC_RSFT); unregister_code(KC_RALT); tap(KC_U); break; case OS_LIN: tap(KC_RALT); tap(KC_DQT); tap(KC_U); break; } } SEQ_TWO_KEYS(KC_U, KC_U) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_2); tap(KC_KP_2); tap(KC_KP_0); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); register_code(KC_RSFT); register_code(KC_SCLN); unregister_code(KC_SCLN); unregister_code(KC_RSFT); unregister_code(KC_RALT); tap(LSFT(KC_U)); break; case OS_LIN: tap(KC_RALT); tap(KC_DQT); register_code(KC_LSFT); register_code(KC_U); unregister_code(KC_U); unregister_code(KC_LSFT); break; } } SEQ_ONE_KEY(KC_S) { switch (os_type) { case OS_WIN: tap(KC_NLCK); register_code(KC_RALT); tap(KC_KP_0); tap(KC_KP_2); tap(KC_KP_2); tap(KC_KP_3); unregister_code(KC_RALT); tap(KC_NLCK); break; case OS_OSX: register_code(KC_RALT); tap(KC_S); unregister_code(KC_RALT); break; case OS_LIN: tap(KC_RALT); tap(KC_S); tap(KC_S); break; } } } }
void led_1_on(void) { ergodox_right_led_1_on(); ergodox_right_led_1_set(max_led_value); }