uint32_t layer_state_set_rgb(uint32_t state) { #ifdef RGBLIGHT_ENABLE if (userspace_config.rgb_layer_change) { switch (biton32(state)) { case _MACROS: rgblight_sethsv_noeeprom_orange(); userspace_config.is_overwatch ? rgblight_effect_snake(RGBLIGHT_MODE_SNAKE + 2) : rgblight_effect_snake(RGBLIGHT_MODE_SNAKE + 3); break; case _MEDIA: rgblight_sethsv_noeeprom_chartreuse(); rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 1); break; case _GAMEPAD: rgblight_sethsv_noeeprom_orange(); rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2); break; case _DIABLO: rgblight_sethsv_noeeprom_red(); rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); break; case _RAISE: rgblight_sethsv_noeeprom_yellow(); rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); break; case _LOWER: rgblight_sethsv_noeeprom_green(); rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); break; case _ADJUST: rgblight_sethsv_noeeprom_red(); rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 2); break; default: // for any other layers, or the default layer switch (biton32(default_layer_state)) { case _COLEMAK: rgblight_sethsv_noeeprom_magenta(); break; case _DVORAK: rgblight_sethsv_noeeprom_springgreen(); break; case _WORKMAN: rgblight_sethsv_noeeprom_goldenrod(); break; case _NORMAN: rgblight_sethsv_noeeprom_coral(); break; case _MALTRON: rgblight_sethsv_noeeprom_yellow(); break; case _EUCALYN: rgblight_sethsv_noeeprom_pink(); break; case _CARPLAX: rgblight_sethsv_noeeprom_blue(); break; default: rgblight_sethsv_noeeprom_cyan(); break; } biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it break; } // layer_state_set_indicator(); // Runs every scan, so need to call this here .... since I can't get it working "right" anyhow } #endif // RGBLIGHT_ENABLE return state; }
void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive bool litup = false; for (uint8_t light_index = 0 ; light_index < RGBLED_NUM ; ++light_index ) { if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) { rgblight_fadeout *light = &lights[light_index]; litup = true; if (light->life) { light->life -= 1; if (biton32(layer_state) == 0) { sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]); } light->timer = timer_read(); } else { if (light->enabled && biton32(layer_state) == 0) { rgblight_sethsv_default_helper(light_index); } litup = light->enabled = false; } } } if (litup && biton32(layer_state) == 0) { rgblight_set(); } }
void matrix_scan_keymap(void) { numlock_led_off(); if ((is_overwatch && biton32(layer_state) == _MACROS) || (biton32(layer_state) == _NUMLOCK)) { numlock_led_on(); } // Run Diablo 3 macro checking code. }
void matrix_scan_keymap(void) { numlock_led_off(); if ((is_overwatch && biton32(layer_state) == _MACROS) || (biton32(layer_state) == _NAV)) { numlock_led_on(); } // Run Diablo 3 macro checking code. #ifdef TAP_DANCE_ENABLE run_diablo_macro_check(); #endif }
uint32_t layer_state_set_user(uint32_t state) { if (state == 0 && edit == true) { mode = rgblight_get_mode(); hue = rgblight_get_hue(); sat = rgblight_get_sat(); val = rgblight_get_val(); edit = false; } switch (biton32(state)) { case 1: rgblight_mode(1); rgblight_setrgb(0xD3, 0x7F, 0xED); break; case 2: rgblight_mode(1); rgblight_setrgb(0xFF, 0x00, 0x00); edit = true; break; default: rgblight_mode(mode); rgblight_sethsv(hue, sat, val); break; } return state; }
void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); switch (layer) { case _QWERTY: set_led_green; break; case _CAPS: set_led_white; break; case _NUMPAD: set_led_blue; break; case _SYMBOLS: set_led_red; break; case _NAV: set_led_magenta; break; case _MACROS: set_led_cyan; break; default: set_led_green; break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { static uint8_t state; ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); //reduce LED on time to 1/6th because LEDs are too strong if (++state < 6) return; state = 0; //bit 1: default layer 1 - QWERTY if (default_layer_state & (1UL << 1)) ergodox_right_led_1_on(); uint8_t layer = biton32(layer_state); //layer 2 : Symbols (& Fs) //if (layer == 2) ergodox_right_led_2_on(); //layer 3 : F-lock if (layer == 3) ergodox_right_led_2_on(); //layer 4 : Num-lock if (layer == 4) ergodox_right_led_3_on(); };
const char *read_layer_state(void) { static char layer_state_str[24]; char layer_name[17]; switch (biton32(layer_state)) { case L_BASE: strcpy(layer_name, default_layer_state == 1UL<<_EDVORAK ? "EDVORAK" : "QWERTY"); break; case _EDVORAKJ1: case _EDVORAKJ2: strcpy(layer_name, "JP_EXT"); break; case _RAISE: strcpy(layer_name, "Raise"); break; case _LOWER: strcpy(layer_name, "Lower"); break; case _ADJUST: strcpy(layer_name, "Adjust"); break; default: snprintf(layer_name, sizeof(layer_name), "Undef-%ld", layer_state); } strcpy(layer_state_str, "Layer: "); strcat(layer_state_str, layer_name); strcat(layer_state_str, "\n"); return layer_state_str; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint8_t layer; layer = biton32(layer_state); // get the current layer //custom layer handling for tri_layer, switch (keycode) { case FNKEY: if (record->event.pressed) { key_timer = timer_read(); singular_key = true; layer_on(_FUNCTION); } else { if (timer_elapsed(key_timer) < LAYER_TOGGLE_DELAY || !singular_key) { layer_off(_FUNCTION); } } update_tri_layer(_FUNCTION, _SHIFTED, _FUNCSHIFT); return false; break; //SHIFT is handled as LSHIFT in the general case case SHIFT: if (record->event.pressed) { key_timer = timer_read(); singular_key = true; layer_on(_SHIFTED); register_code(KC_LSFT); } else { if (timer_elapsed(key_timer) < LAYER_TOGGLE_DELAY || !singular_key) { layer_off(_SHIFTED); unregister_code(KC_LSFT); } } update_tri_layer(_FUNCTION, _SHIFTED, _FUNCSHIFT); return false; break; //If any other key was pressed during the layer mod hold period, //then the layer mod was used momentarily, and should block latching default: singular_key = false; break; } //FUNCSHIFT has been shifted by the SHIFT handling, some keys need to be excluded if (layer == _FUNCSHIFT) { //F1-F12 should be sent as unshifted keycodes, //and ] needs to be unshifted or it is sent as } if ( (keycode >= KC_F1 && keycode <= KC_F12) || keycode == KC_RBRC ) { if (record->event.pressed) { unregister_mods(MOD_LSFT); } else { register_mods(MOD_LSFT); } } } return true; };
void rgb_matrix_indicators_user(void) { #ifdef RGB_MATRIX_ENABLE switch (biton32(layer_state)) { case _RAISE: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, 0x6B, 0x00, 0x80); } else { rgb_matrix_set_color(i, 0x00, 0xFF, 0x00); } } break; case _LOWER: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { rgb_matrix_set_color(i, 0xFF, 0xA5, 0x00); } else { rgb_matrix_set_color(i, 0x00, 0x67, 0xC7); } } break; case _ADJUST: for (int i = 0; i < DRIVER_LED_TOTAL; i++) { rgb_matrix_set_color(i, 0xFF, 0x99, 0x00); } rgb_matrix_set_color(1, 0xFF, 0x00, 0x00); break; default: break; } #endif }
void iota_gfx_task_user(void) { #if DEBUG_TO_SCREEN if (debug_enable) { return; } #endif struct CharacterMatrix matrix; matrix_clear(&matrix); matrix_write_P(&matrix, PSTR("TKC1800")); uint8_t layer = biton32(layer_state); char buf[40]; snprintf(buf,sizeof(buf), "Undef-%d", layer); matrix_write_P(&matrix, PSTR("\nLayer: ")); matrix_write(&matrix, layer_lookup[layer]); // Host Keyboard LED Status char led[40]; snprintf(led, sizeof(led), "\n\n%s %s %s", (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); matrix_write(&matrix, led); matrix_update(&display, &matrix); }
void * matrix_scan_user(void) { uint8_t layer = biton32(layer_state); switch (layer) { case 1: led[15].r = 255; led[15].g = 0; led[15].b = 0; ws2812_setleds(led, 16); break; case 2: led[15].r = 0; led[15].g = 255; led[15].b = 0; ws2812_setleds(led, 16); break; case 3: led[15].r = 0; led[15].g = 0; led[15].b = 255; ws2812_setleds(led, 16); break; default: led[15].r = 0; led[15].g = 0; led[15].b = 0; ws2812_setleds(led, 16); break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { /* leds is a static array holding the current brightness of each of the * three keyboard LEDs. It's 4 long simply to avoid the ugliness of +1s and * -1s in the code below, and because wasting a byte really doesn't matter * that much (no, it *doesn't*, stop whinging!). Note that because it's * static it'll maintain state across invocations of this routine. */ static uint8_t leds[4]; uint8_t led; uint8_t layer = biton32(layer_state); ergodox_board_led_off(); /* Loop over each LED/layer */ for (led = 1; led <= 3; ++led) { /* If the current layer matches the current LED, increment its * brightness by 1 up to a maximum of 255. If the current layer doesn't * match, decrement its brightness by 1 down to a minimum of zero. */ leds[led] += (layer == led) ? (leds[led] < 255 ? 1 : 0): (leds[led] > 0 ? -1 : 0); /* Set LED state according to the new brightness */ if (leds[led]) { ergodox_right_led_on(led); ergodox_right_led_set(led, leds[led]); } else { ergodox_right_led_off(led); } } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { case 1: ergodox_right_led_3_on(); break; case 2: ergodox_right_led_2_on(); break; case 3: ergodox_right_led_1_on(); ergodox_right_led_2_on(); ergodox_right_led_3_on(); break; default: // none break; } // Turn the caps lock led on if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { ergodox_right_led_1_on(); } }
// Runs constantly in the background, in a loop. void * matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { case 1: ergodox_right_led_1_on(); break; case 2: ergodox_right_led_2_on(); break; case 3: ergodox_right_led_3_on(); break; case 4: ergodox_right_led_1_on(); // TODO: Make a fourth layer ergodox_right_led_3_on(); break; default: // none break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { case 1: ergodox_right_led_1_on(); break; case 2: ergodox_right_led_2_on(); break; #ifdef CFQ_USE_EXPEREMENTAL_LAYER case 3: ergodox_right_led_3_on(); break; #endif default: // none break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { case NUMBER: case SYMBOL: case BRACKETS: //case SHELL_LAYER: ergodox_right_led_2_on(); break; case KEY_NAV: case KEY_SEL: ergodox_right_led_3_on(); break; case SHORTCUTS: ergodox_right_led_2_on(); ergodox_right_led_3_on(); break; default: // none break; } return; };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { // TODO: Make this relevant to the ErgoDox EZ. case 1: ergodox_right_led_3_on(); break; case 2: ergodox_right_led_2_on(); break; case 3: ergodox_right_led_2_on(); ergodox_right_led_3_on(); break; default: // none break; } if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // if capslk is on, set led 1 on ergodox_right_led_1_on(); } else { ergodox_right_led_1_off(); } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { case FMU: ergodox_right_led_1_on(); break; case PMQ: ergodox_right_led_2_on(); break; case PMN: ergodox_right_led_3_on(); break; default: if(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) { ergodox_led_all_set(LED_BRIGHTNESS_HI); ergodox_right_led_1_on(); } else { ergodox_board_led_off(); } break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { // TODO: Make this relevant to the ErgoDox EZ. case 1: ergodox_right_led_1_on(); break; case 2: ergodox_right_led_2_on(); break; case 3: ergodox_right_led_3_on(); break; case 4: ergodox_right_led_1_on(); ergodox_right_led_2_on(); break; default: // none break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); // Dim the LEDs as much as possible ergodox_led_all_set(0); // Show the active layer number as binary bits in the LEDs. // Note that LED1 is left-most, so bit1 -> LED3 and bit3 -> LED1 if (layer & 0b001) { ergodox_right_led_3_on(); } else { ergodox_right_led_3_off(); } if (layer & 0b010) { ergodox_right_led_2_on(); } else { ergodox_right_led_2_off(); } // Show caps lock on the left most LED. // (Double-tap left shift to toggle caps lock) if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) { ergodox_right_led_1_on(); } else { ergodox_right_led_1_off(); } }
void matrix_scan_user(void) { #ifdef RGBLIGHT_ENABLE static uint8_t old_layer = 255; uint8_t new_layer = biton32(layer_state); // Color of the Icons. if (old_layer != new_layer) { switch (new_layer) { case _PS: // #31C5F0 rgblight_setrgb(49, 197, 240); break; case _AI: // #FF8011 rgblight_setrgb(255, 128, 17); break; case _PR: // #E788FF rgblight_setrgb(231, 136, 255); break; case _XD: // #FF2BC2 rgblight_setrgb(255, 43, 194); break; } old_layer = new_layer; } #endif }
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); switch (layer) { // TODO: Make this relevant to the ErgoDox EZ. case DVORAK: ergodox_right_led_1_on(); break; case COLEMAK: ergodox_right_led_2_on(); break; case QWERTY: ergodox_right_led_3_on(); break; case FN: ergodox_led_all_on(); break; default: // none break; } };
void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); switch (layer) { case _NAV: if (RGB_INIT) {} else { RGB_current_mode = rgblight_config.mode; RGB_INIT = true; } if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false } else { TOG_STATUS = !TOG_STATUS; rgblight_mode(29); } break; case _LOWER: if (RGB_INIT) {} else { RGB_current_mode = rgblight_config.mode; RGB_INIT = true; } if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false } else { TOG_STATUS = !TOG_STATUS; rgblight_mode(29); } break; case _QWERTY: if (RGB_INIT) {} else { RGB_current_mode = rgblight_config.mode; RGB_INIT = true; } rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change TOG_STATUS = false; break; } };
uint32_t layer_state_set_kb(uint32_t state) { #ifdef RGBLIGHT_ENABLE // Check layer, and apply color if its changed since last check switch (biton32(state)) { case _NAV: rgblight_set_blue; rgblight_mode(1); break; case _MACROS: rgblight_set_orange; is_overwatch ? rgblight_mode(17) : rgblight_mode(18); break; case _DIABLO: rgblight_set_red; rgblight_mode(5); break; case _MEDIA: rgblight_set_green; rgblight_mode(22); break; default: rgblight_set_teal; rgblight_mode(1); break; } #endif return state; }
static void switch_default_layer(uint8_t layer) { print("switch_default_layer: "); print_dec(biton32(default_layer_state)); print(" to "); print_dec(layer); print("\n"); default_layer_set(1UL<<layer); clear_keyboard(); }
uint32_t default_layer_state_set_rgb(uint32_t state) { #ifdef RGBLIGHT_ENABLE if (userspace_config.rgb_layer_change) { rgblight_config_t temp_rgblight_config = rgblight_config; switch (biton32(state)) { case _COLEMAK: temp_rgblight_config.hue = 300; temp_rgblight_config.val = 255; temp_rgblight_config.sat = 255; temp_rgblight_config.mode = 1; break; case _DVORAK: temp_rgblight_config.hue = 150; temp_rgblight_config.val = 255; temp_rgblight_config.sat = 255; temp_rgblight_config.mode = 1; case _WORKMAN: temp_rgblight_config.hue = 43; temp_rgblight_config.val = 218; temp_rgblight_config.sat = 218; temp_rgblight_config.mode = 1; default: temp_rgblight_config.hue = 180; temp_rgblight_config.val = 255; temp_rgblight_config.sat = 255; temp_rgblight_config.mode = 1; } if (temp_rgblight_config.raw != eeconfig_read_rgblight()) { xprintf("rgblight set default layer hsv [EEPROM]: %u,%u,%u,%u\n", temp_rgblight_config.hue, temp_rgblight_config.sat, temp_rgblight_config.val, temp_rgblight_config.mode); eeconfig_update_rgblight(temp_rgblight_config.raw); } } #endif // RGBLIGHT_ENABLE return state; }
void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); ergodox_board_led_on(); ergodox_led_all_on(); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); // _delay_ms(45); switch (layer) { case _SYMBOLS: ergodox_right_led_1_on(); break; case _MOUSE: ergodox_right_led_2_on(); break; case _NUMPAD: ergodox_right_led_3_on(); break; case _NAV: ergodox_right_led_1_on(); ergodox_right_led_2_on(); break; case _MACROS: //layer unused right now break; case _FUNCTION: //layer unused right nowex break; case _APPSWITCH: ergodox_right_led_2_on(); ergodox_right_led_3_on(); break; case _ONESHOT: ergodox_right_led_1_on(); ergodox_right_led_2_on(); ergodox_right_led_3_on(); break; case _TEXTNAV: ergodox_right_led_1_on(); ergodox_right_led_3_on(); break; case _QWERTY_KIDS: ergodox_right_led_1_on(); ergodox_right_led_2_on(); ergodox_right_led_3_on(); break; case _STREET_FIGHTER: ergodox_right_led_2_on(); ergodox_right_led_3_on(); default: break; } };
// Runs constantly in the background, in a loop. void matrix_scan_user(void) { uint8_t layer = biton32(layer_state); };
// 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 (); } } };