bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { set_keylog(keycode, record); // set_timelog(); } switch (keycode) { case RGB_MOD: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { rgblight_mode_noeeprom(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } #endif return false; break; case RGBRST: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { eeconfig_update_rgblight_default(); rgblight_enable(); RGB_current_mode = rgblight_config.mode; } #endif break; } return true; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { #ifdef SSD1306OLED set_keylog(keycode, record); #endif // set_timelog(); } switch (keycode) { case LOWER: if (record->event.pressed) { layer_on(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { layer_off(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case RAISE: if (record->event.pressed) { layer_on(_RAISE); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { layer_off(_RAISE); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case ADJUST: if (record->event.pressed) { layer_on(_ADJUST); } else { layer_off(_ADJUST); } return false; break; case RGB_MOD: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { rgblight_mode(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } #endif return false; break; case RGBRST: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { eeconfig_update_rgblight_default(); rgblight_enable(); RGB_current_mode = rgblight_config.mode; } #endif break; } return true; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { persistent_default_layer_set(1UL<<_QWERTY); } return false; break; case LOWER: if (record->event.pressed) { layer_on(_LOWER); } else { layer_off(_LOWER); } return false; break; case RAISE: if (record->event.pressed) { layer_on(_RAISE); } else { layer_off(_RAISE); } return false; break; case ADJUST: if (record->event.pressed) { layer_on(_ADJUST); } else { layer_off(_ADJUST); } return false; break; case RGB_MOD: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { rgblight_mode(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } #endif return false; break; case RGBRST: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { eeconfig_update_rgblight_default(); rgblight_enable(); RGB_current_mode = rgblight_config.mode; } #endif break; } return true; }
// Macros const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { // MACRODOWN only works in this function switch(id) { case 0: if (record->event.pressed) { register_code(KC_RSFT); rgblight_step(); } else { unregister_code(KC_RSFT); } break; } return MACRO_NONE; };
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { switch (id) { case RGBLED_TOGGLE: //led operations if (record->event.pressed) { rgblight_toggle(); } break; case RGBLED_INCREASE_HUE: if (record->event.pressed) { rgblight_increase_hue(); } break; case RGBLED_DECREASE_HUE: if (record->event.pressed) { rgblight_decrease_hue(); } break; case RGBLED_INCREASE_SAT: if (record->event.pressed) { rgblight_increase_sat(); } break; case RGBLED_DECREASE_SAT: if (record->event.pressed) { rgblight_decrease_sat(); } break; case RGBLED_INCREASE_VAL: if (record->event.pressed) { rgblight_increase_val(); } break; case RGBLED_DECREASE_VAL: if (record->event.pressed) { rgblight_decrease_val(); } break; case RGBLED_STEP_MODE: if (record->event.pressed) { rgblight_step(); } break; } }
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { switch (id) { case F_PASTE: if (record->event.pressed) { register_code(KC_LCTL); register_code(KC_V); unregister_code(KC_V); unregister_code(KC_LCTL); } break; case RGB_ANI: if (record->event.pressed) { rgb_timer = timer_read(); } else { if (timer_elapsed(rgb_timer) > 300) { rgblight_mode(1); } else { rgblight_step(); } } case CF_EPRM: if (record->event.pressed) { eeconfig_init(); } return false; break; case CF_VERS: if (record->event.pressed) { SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); } return false; break; } return MACRO_NONE; };
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case ADJUST: if (record->event.pressed) { 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(25); } layer_on(_ADJUST); } else { rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change TOG_STATUS = false; layer_off(_ADJUST); } return false; break; case GAMEXTRA: if (record->event.pressed) { layer_on(_GAMEXTRA); } else { layer_off(_GAMEXTRA); } return false; break; case RGB_MOD: //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released if (record->event.pressed) { rgblight_mode(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } return false; break; } return true; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch(keycode) { case RGB_RST: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { eeconfig_update_rgblight_default(); rgblight_enable(); } #endif break; case RGB_MOD: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { enableLEDTypeAnime = false; rgblight_step(); } #endif return false; case RGB_TYPE: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { rgblight_enable_noeeprom(); rgblight_mode_noeeprom(1); enableLEDTypeAnime = !enableLEDTypeAnime; } #endif return false; default: break; } #ifdef RGBLIGHT_ENABLE if(enableLEDTypeAnime) { rgblight_mode_noeeprom(1); uint16_t hue = (rgblight_config.hue + 5) % 360; rgblight_sethsv_noeeprom(hue, rgblight_config.sat, rgblight_config.val); } #endif return true; }
void dance_toggle (qk_tap_dance_state_t *state, void *user_data) { if (state->count >= 2) { println("Double tapped, switching layers"); if (layer_state_is(LED)) { layer_off(LED); } else { layer_on(LED); } } else { print("Single tapped: "); if (layer_state_is(LED)) { #ifdef RGBLIGHT_ENABLE if (!rgblight_config.enable) { rgblight_enable(); } rgblight_step(); #endif } else { println("Base layer, sending string"); SEND_STRING("This thing is BIG!!\n"); } } }
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { switch (id) { case RGBLED_TOGGLE: //led operations if (record->event.pressed) { rgblight_toggle(); } break; case RGBLED_INCREASE_HUE: if (record->event.pressed) { rgblight_increase_hue(); } break; case RGBLED_DECREASE_HUE: if (record->event.pressed) { rgblight_decrease_hue(); } break; case RGBLED_INCREASE_SAT: if (record->event.pressed) { rgblight_increase_sat(); } break; case RGBLED_DECREASE_SAT: if (record->event.pressed) { rgblight_decrease_sat(); } break; case RGBLED_INCREASE_VAL: if (record->event.pressed) { rgblight_increase_val(); } break; case RGBLED_DECREASE_VAL: if (record->event.pressed) { rgblight_decrease_val(); } break; case RGBLED_STEP_MODE: if (record->event.pressed) { rgblight_step(); } break; static uint8_t shift_esc_shift_mask; // Shift + ESC = ~ case SHIFT_ESC: shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK; if (record->event.pressed) { if (shift_esc_shift_mask) { add_key(KC_GRV); send_keyboard_report(); } else { add_key(KC_ESC); send_keyboard_report(); } } else { if (shift_esc_shift_mask) { del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } break; } };
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_qwerty); #endif persistant_default_layer_set(1UL<<_QWERTY); } return false; break; case LOWER: if (record->event.pressed) { //not sure how to have keyboard check mode and set it to a variable, so my work around //uses another variable that would be set to true after the first time a reactive key is pressed. 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(16); } layer_on(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change TOG_STATUS = false; layer_off(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case RAISE: if (record->event.pressed) { //not sure how to have keyboard check mode and set it to a variable, so my work around //uses another variable that would be set to true after the first time a reactive key is pressed. 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(15); } layer_on(_RAISE); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change layer_off(_RAISE); TOG_STATUS = false; update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case BACKLIT: if (record->event.pressed) { register_code(KC_RSFT); #ifdef BACKLIGHT_ENABLE backlight_step(); #endif } else { unregister_code(KC_RSFT); } return false; break; //my attempt for RGB layer lock indication via changing the mode, still have to figure out how to not have other keypress not override this mode case TG_NUMLAY: if (record->event.pressed) { if (RGB_INIT) {} else { RGB_current_mode = rgblight_config.mode; RGB_INIT = true; } NUMLAY_STATUS = !NUMLAY_STATUS; if (NUMLAY_STATUS) { rgblight_mode(4); layer_on(_NUMLAY); } else { rgblight_mode(RGB_current_mode); layer_off(_NUMLAY); } } return false; break; case RGB_MOD: //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released if (record->event.pressed) { rgblight_mode(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } return false; break; } return true; }
bool process_record_quantum(keyrecord_t *record) { /* This gets the keycode from the key pressed */ keypos_t key = record->event.key; uint16_t keycode; #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) /* TODO: Use store_or_get_action() or a similar function. */ if (!disable_action_cache) { uint8_t layer; if (record->event.pressed) { layer = layer_switch_get_layer(key); update_source_layers_cache(key, layer); } else { layer = read_source_layers_cache(key); } keycode = keymap_key_to_keycode(layer, key); } else #endif keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); // This is how you use actions here // if (keycode == KC_LEAD) { // action_t action; // action.code = ACTION_DEFAULT_LAYER_SET(0); // process_action(record, action); // return false; // } #ifdef TAP_DANCE_ENABLE preprocess_tap_dance(keycode, record); #endif if (!( #if defined(KEY_LOCK_ENABLE) // Must run first to be able to mask key_up events. process_key_lock(&keycode, record) && #endif #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) process_clicky(keycode, record) && #endif //AUDIO_CLICKY process_record_kb(keycode, record) && #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) process_rgb_matrix(keycode, record) && #endif #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) process_midi(keycode, record) && #endif #ifdef AUDIO_ENABLE process_audio(keycode, record) && #endif #ifdef STENO_ENABLE process_steno(keycode, record) && #endif #if ( defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif #ifdef LEADER_ENABLE process_leader(keycode, record) && #endif #ifdef COMBO_ENABLE process_combo(keycode, record) && #endif #ifdef UNICODE_ENABLE process_unicode(keycode, record) && #endif #ifdef UCIS_ENABLE process_ucis(keycode, record) && #endif #ifdef PRINTING_ENABLE process_printer(keycode, record) && #endif #ifdef AUTO_SHIFT_ENABLE process_auto_shift(keycode, record) && #endif #ifdef UNICODEMAP_ENABLE process_unicode_map(keycode, record) && #endif #ifdef TERMINAL_ENABLE process_terminal(keycode, record) && #endif true)) { return false; } // Shift / paren setup switch(keycode) { case RESET: if (record->event.pressed) { reset_keyboard(); } return false; case DEBUG: if (record->event.pressed) { debug_enable = true; print("DEBUG: enabled.\n"); } return false; #ifdef FAUXCLICKY_ENABLE case FC_TOG: if (record->event.pressed) { FAUXCLICKY_TOGGLE; } return false; case FC_ON: if (record->event.pressed) { FAUXCLICKY_ON; } return false; case FC_OFF: if (record->event.pressed) { FAUXCLICKY_OFF; } return false; #endif #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) case RGB_TOG: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_toggle(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_MODE_FORWARD: if (record->event.pressed) { uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)); if(shifted) { rgblight_step_reverse(); } else { rgblight_step(); } #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_MODE_REVERSE: if (record->event.pressed) { uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)); if(shifted) { rgblight_step(); } else { rgblight_step_reverse(); } #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_HUI: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_increase_hue(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_HUD: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_decrease_hue(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_SAI: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_increase_sat(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_SAD: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_decrease_sat(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_VAI: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_increase_val(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_VAD: // Split keyboards need to trigger on key-up for edge-case issue #ifndef SPLIT_KEYBOARD if (record->event.pressed) { #else if (!record->event.pressed) { #endif rgblight_decrease_val(); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_SPI: if (record->event.pressed) { rgblight_increase_speed(); } return false; case RGB_SPD: if (record->event.pressed) { rgblight_decrease_speed(); } return false; case RGB_MODE_PLAIN: if (record->event.pressed) { rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_MODE_BREATHE: #ifdef RGBLIGHT_EFFECT_BREATHING if (record->event.pressed) { if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) { rgblight_step(); } else { rgblight_mode(RGBLIGHT_MODE_BREATHING); } } #endif return false; case RGB_MODE_RAINBOW: #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD if (record->event.pressed) { if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) { rgblight_step(); } else { rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD); } } #endif return false; case RGB_MODE_SWIRL: #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL if (record->event.pressed) { if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) { rgblight_step(); } else { rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); } } #endif return false; case RGB_MODE_SNAKE: #ifdef RGBLIGHT_EFFECT_SNAKE if (record->event.pressed) { if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) { rgblight_step(); } else { rgblight_mode(RGBLIGHT_MODE_SNAKE); } } #endif return false; case RGB_MODE_KNIGHT: #ifdef RGBLIGHT_EFFECT_KNIGHT if (record->event.pressed) { if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) { rgblight_step(); } else { rgblight_mode(RGBLIGHT_MODE_KNIGHT); } } #endif return false; case RGB_MODE_XMAS: #ifdef RGBLIGHT_EFFECT_CHRISTMAS if (record->event.pressed) { rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); } #endif return false; case RGB_MODE_GRADIENT: #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT if (record->event.pressed) { if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) { rgblight_step(); } else { rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT); } } #endif return false; case RGB_MODE_RGBTEST: #ifdef RGBLIGHT_EFFECT_RGB_TEST if (record->event.pressed) { rgblight_mode(RGBLIGHT_MODE_RGB_TEST); } #endif return false; #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) #ifdef PROTOCOL_LUFA case OUT_AUTO: if (record->event.pressed) { set_output(OUTPUT_AUTO); } return false; case OUT_USB: if (record->event.pressed) { set_output(OUTPUT_USB); } return false; #ifdef BLUETOOTH_ENABLE case OUT_BT: if (record->event.pressed) { set_output(OUTPUT_BLUETOOTH); } return false; #endif #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); } /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); switch (keycode) { case MAGIC_SWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = true; break; case MAGIC_CAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = true; break; case MAGIC_SWAP_LALT_LGUI: keymap_config.swap_lalt_lgui = true; break; case MAGIC_SWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = true; break; case MAGIC_NO_GUI: keymap_config.no_gui = true; break; case MAGIC_SWAP_GRAVE_ESC: keymap_config.swap_grave_esc = true; break; case MAGIC_SWAP_BACKSLASH_BACKSPACE: keymap_config.swap_backslash_backspace = true; break; case MAGIC_HOST_NKRO: keymap_config.nkro = true; break; case MAGIC_SWAP_ALT_GUI: keymap_config.swap_lalt_lgui = true; keymap_config.swap_ralt_rgui = true; #ifdef AUDIO_ENABLE PLAY_SONG(ag_swap_song); #endif break; case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; break; case MAGIC_UNCAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = false; break; case MAGIC_UNSWAP_LALT_LGUI: keymap_config.swap_lalt_lgui = false; break; case MAGIC_UNSWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = false; break; case MAGIC_UNNO_GUI: keymap_config.no_gui = false; break; case MAGIC_UNSWAP_GRAVE_ESC: keymap_config.swap_grave_esc = false; break; case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: keymap_config.swap_backslash_backspace = false; break; case MAGIC_UNHOST_NKRO: keymap_config.nkro = false; break; case MAGIC_UNSWAP_ALT_GUI: keymap_config.swap_lalt_lgui = false; keymap_config.swap_ralt_rgui = false; #ifdef AUDIO_ENABLE PLAY_SONG(ag_norm_song); #endif break; case MAGIC_TOGGLE_ALT_GUI: keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; #ifdef AUDIO_ENABLE if (keymap_config.swap_ralt_rgui) { PLAY_SONG(ag_swap_song); } else { PLAY_SONG(ag_norm_song); } #endif break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; break; default: break; } eeconfig_update_keymap(keymap_config.raw); clear_keyboard(); // clear to prevent stuck keys return false; } break; case KC_LSPO: { if (record->event.pressed) { shift_interrupted[0] = false; scs_timer[0] = timer_read (); register_mods(MOD_BIT(KC_LSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_RSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { register_code(LSPO_KEY); unregister_code(LSPO_KEY); } unregister_mods(MOD_BIT(KC_LSFT)); } return false; } case KC_RSPC: { if (record->event.pressed) { shift_interrupted[1] = false; scs_timer[1] = timer_read (); register_mods(MOD_BIT(KC_RSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_LSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { register_code(RSPC_KEY); unregister_code(RSPC_KEY); } unregister_mods(MOD_BIT(KC_RSFT)); } return false; } case KC_SFTENT: { if (record->event.pressed) { shift_interrupted[1] = false; scs_timer[1] = timer_read (); register_mods(MOD_BIT(KC_RSFT)); } else if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { unregister_mods(MOD_BIT(KC_RSFT)); register_code(SFTENT_KEY); unregister_code(SFTENT_KEY); } else { unregister_mods(MOD_BIT(KC_RSFT)); } return false; } case GRAVE_ESC: { uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); #ifdef GRAVE_ESC_ALT_OVERRIDE // if ALT is pressed, ESC is always sent // this is handy for the cmd+opt+esc shortcut on macOS, among other things. if (get_mods() & (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT))) { shifted = 0; } #endif #ifdef GRAVE_ESC_CTRL_OVERRIDE // if CTRL is pressed, ESC is always sent // this is handy for the ctrl+shift+esc shortcut on windows, among other things. if (get_mods() & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL))) { shifted = 0; } #endif #ifdef GRAVE_ESC_GUI_OVERRIDE // if GUI is pressed, ESC is always sent if (get_mods() & (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))) { shifted = 0; } #endif #ifdef GRAVE_ESC_SHIFT_OVERRIDE // if SHIFT is pressed, ESC is always sent if (get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) { shifted = 0; } #endif if (record->event.pressed) { grave_esc_was_shifted = shifted; add_key(shifted ? KC_GRAVE : KC_ESCAPE); } else { del_key(grave_esc_was_shifted ? KC_GRAVE : KC_ESCAPE); } send_keyboard_report(); return false; } #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING) case BL_BRTG: { if (record->event.pressed) breathing_toggle(); return false; } #endif default: { shift_interrupted[0] = true; shift_interrupted[1] = true; break; } } return process_action_kb(record); } __attribute__ ((weak)) const bool ascii_to_shift_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 }; __attribute__ ((weak)) const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = { 0, 0, 0, 0, 0, 0, 0, 0, KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KC_ESC, 0, 0, 0, 0, KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT, KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH, KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS, KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O, KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL }; void send_string(const char *str) { send_string_with_delay(str, 0); } void send_string_P(const char *str) { send_string_with_delay_P(str, 0); } void send_string_with_delay(const char *str, uint8_t interval) { while (1) { char ascii_code = *str; if (!ascii_code) break; if (ascii_code == 1) { // tap uint8_t keycode = *(++str); register_code(keycode); unregister_code(keycode); } else if (ascii_code == 2) { // down uint8_t keycode = *(++str); register_code(keycode); } else if (ascii_code == 3) { // up uint8_t keycode = *(++str); unregister_code(keycode); } else { send_char(ascii_code); } ++str; // interval { uint8_t ms = interval; while (ms--) wait_ms(1); } } } void send_string_with_delay_P(const char *str, uint8_t interval) { while (1) { char ascii_code = pgm_read_byte(str); if (!ascii_code) break; if (ascii_code == 1) { // tap uint8_t keycode = pgm_read_byte(++str); register_code(keycode); unregister_code(keycode); } else if (ascii_code == 2) { // down uint8_t keycode = pgm_read_byte(++str); register_code(keycode); } else if (ascii_code == 3) { // up uint8_t keycode = pgm_read_byte(++str); unregister_code(keycode); } else { send_char(ascii_code); } ++str; // interval { uint8_t ms = interval; while (ms--) wait_ms(1); } } } void send_char(char ascii_code) { uint8_t keycode; keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) { register_code(KC_LSFT); register_code(keycode); unregister_code(keycode); unregister_code(KC_LSFT); } else { register_code(keycode); unregister_code(keycode); } } void set_single_persistent_default_layer(uint8_t default_layer) { #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) PLAY_SONG(default_layer_songs[default_layer]); #endif eeconfig_update_default_layer(1U<<default_layer); default_layer_set(1U<<default_layer); } uint32_t update_tri_layer_state(uint32_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) { uint32_t mask12 = (1UL << layer1) | (1UL << layer2); uint32_t mask3 = 1UL << layer3; return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); } void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } void tap_random_base64(void) { #if defined(__AVR_ATmega32U4__) uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64; #else uint8_t key = rand() % 64; #endif switch (key) { case 0 ... 25: register_code(KC_LSFT); register_code(key + KC_A); unregister_code(key + KC_A); unregister_code(KC_LSFT); break; case 26 ... 51: register_code(key - 26 + KC_A); unregister_code(key - 26 + KC_A); break; case 52: register_code(KC_0); unregister_code(KC_0); break; case 53 ... 61: register_code(key - 53 + KC_1); unregister_code(key - 53 + KC_1); break; case 62: register_code(KC_LSFT); register_code(KC_EQL); unregister_code(KC_EQL); unregister_code(KC_LSFT); break; case 63: register_code(KC_SLSH); unregister_code(KC_SLSH); break; } }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_qwerty, false, 0); #endif persistent_default_layer_set(1UL<<_QWERTY); } break; return false; case COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_colemak, false, 0); #endif persistent_default_layer_set(1UL<<_COLEMAK); } break; return false; case DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_dvorak, false, 0); #endif persistent_default_layer_set(1UL<<_DVORAK); } break; return false; case LOWER: if (record->event.pressed) { layer_on(_LOWER); #ifdef BACKLIGHT_ENABLE breathing_speed_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); } else { layer_off(_LOWER); update_tri_layer(_LOWER, _RAISE, _ADJUST); } break; return false; case RAISE: if (record->event.pressed) { layer_on(_RAISE); #ifdef BACKLIGHT_ENABLE breathing_speed_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); } else { layer_off(_RAISE); update_tri_layer(_LOWER, _RAISE, _ADJUST); } break; return false; case BACKLIT: if (record->event.pressed) { register_code(KC_RSFT); #ifdef BACKLIGHT_ENABLE backlight_step(); #endif } else { unregister_code(KC_RSFT); } break; return false; case PLOVER: if (record->event.pressed) { #ifdef AUDIO_ENABLE stop_all_notes(); PLAY_NOTE_ARRAY(tone_plover, false, 0); #endif layer_off(_RAISE); layer_off(_LOWER); layer_off(_ADJUST); layer_on(_PLOVER); if (!eeconfig_is_enabled()) { eeconfig_init(); } keymap_config.raw = eeconfig_read_keymap(); keymap_config.nkro = 1; eeconfig_update_keymap(keymap_config.raw); } break; return false; case EXT_PLV: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); #endif layer_off(_PLOVER); } break; return false; case RGBLED_TOGGLE: //led operations if (record->event.pressed) { rgblight_toggle(); } return false; break; case RGBLED_INCREASE_HUE: if (record->event.pressed) { rgblight_increase_hue(); } return false; break; case RGBLED_DECREASE_HUE: if (record->event.pressed) { rgblight_decrease_hue(); } return false; break; case RGBLED_INCREASE_SAT: if (record->event.pressed) { rgblight_increase_sat(); } return false; break; case RGBLED_DECREASE_SAT: if (record->event.pressed) { rgblight_decrease_sat(); } return false; break; case RGBLED_INCREASE_VAL: if (record->event.pressed) { rgblight_increase_val(); } return false; break; case RGBLED_DECREASE_VAL: if (record->event.pressed) { rgblight_decrease_val(); } return false; break; case RGBLED_STEP_MODE: if (record->event.pressed) { rgblight_step(); } return false; break; } return true; };
bool process_record_quantum(keyrecord_t *record) { /* This gets the keycode from the key pressed */ keypos_t key = record->event.key; uint16_t keycode; #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) /* TODO: Use store_or_get_action() or a similar function. */ if (!disable_action_cache) { uint8_t layer; if (record->event.pressed) { layer = layer_switch_get_layer(key); update_source_layers_cache(key, layer); } else { layer = read_source_layers_cache(key); } keycode = keymap_key_to_keycode(layer, key); } else #endif keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); // This is how you use actions here // if (keycode == KC_LEAD) { // action_t action; // action.code = ACTION_DEFAULT_LAYER_SET(0); // process_action(record, action); // return false; // } if (!( #if defined(KEY_LOCK_ENABLE) // Must run first to be able to mask key_up events. process_key_lock(&keycode, record) && #endif process_record_kb(keycode, record) && #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) process_midi(keycode, record) && #endif #ifdef AUDIO_ENABLE process_audio(keycode, record) && #endif #ifdef STENO_ENABLE process_steno(keycode, record) && #endif #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif #ifndef DISABLE_LEADER process_leader(keycode, record) && #endif #ifndef DISABLE_CHORDING process_chording(keycode, record) && #endif #ifdef COMBO_ENABLE process_combo(keycode, record) && #endif #ifdef UNICODE_ENABLE process_unicode(keycode, record) && #endif #ifdef UCIS_ENABLE process_ucis(keycode, record) && #endif #ifdef PRINTING_ENABLE process_printer(keycode, record) && #endif #ifdef AUTO_SHIFT_ENABLE process_auto_shift(keycode, record) && #endif #ifdef UNICODEMAP_ENABLE process_unicode_map(keycode, record) && #endif #ifdef TERMINAL_ENABLE process_terminal(keycode, record) && #endif true)) { return false; } // Shift / paren setup switch(keycode) { case RESET: if (record->event.pressed) { reset_keyboard(); } return false; case DEBUG: if (record->event.pressed) { debug_enable = true; print("DEBUG: enabled.\n"); } return false; #ifdef FAUXCLICKY_ENABLE case FC_TOG: if (record->event.pressed) { FAUXCLICKY_TOGGLE; } return false; case FC_ON: if (record->event.pressed) { FAUXCLICKY_ON; } return false; case FC_OFF: if (record->event.pressed) { FAUXCLICKY_OFF; } return false; #endif #ifdef RGBLIGHT_ENABLE case RGB_TOG: if (record->event.pressed) { rgblight_toggle(); } return false; case RGB_MOD: if (record->event.pressed) { rgblight_step(); } return false; case RGB_SMOD: // same as RBG_MOD, but if shift is pressed, it will use the reverese direction instead. if (record->event.pressed) { uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)); if(shifted) { rgblight_step_reverse(); } else { rgblight_step(); } } return false; case RGB_HUI: if (record->event.pressed) { rgblight_increase_hue(); } return false; case RGB_HUD: if (record->event.pressed) { rgblight_decrease_hue(); } return false; case RGB_SAI: if (record->event.pressed) { rgblight_increase_sat(); } return false; case RGB_SAD: if (record->event.pressed) { rgblight_decrease_sat(); } return false; case RGB_VAI: if (record->event.pressed) { rgblight_increase_val(); } return false; case RGB_VAD: if (record->event.pressed) { rgblight_decrease_val(); } return false; case RGB_MODE_PLAIN: if (record->event.pressed) { rgblight_mode(1); } return false; case RGB_MODE_BREATHE: if (record->event.pressed) { if ((2 <= rgblight_get_mode()) && (rgblight_get_mode() < 5)) { rgblight_step(); } else { rgblight_mode(2); } } return false; case RGB_MODE_RAINBOW: if (record->event.pressed) { if ((6 <= rgblight_get_mode()) && (rgblight_get_mode() < 8)) { rgblight_step(); } else { rgblight_mode(6); } } return false; case RGB_MODE_SWIRL: if (record->event.pressed) { if ((9 <= rgblight_get_mode()) && (rgblight_get_mode() < 14)) { rgblight_step(); } else { rgblight_mode(9); } } return false; case RGB_MODE_SNAKE: if (record->event.pressed) { if ((15 <= rgblight_get_mode()) && (rgblight_get_mode() < 20)) { rgblight_step(); } else { rgblight_mode(15); } } return false; case RGB_MODE_KNIGHT: if (record->event.pressed) { if ((21 <= rgblight_get_mode()) && (rgblight_get_mode() < 23)) { rgblight_step(); } else { rgblight_mode(21); } } return false; case RGB_MODE_XMAS: if (record->event.pressed) { rgblight_mode(24); } return false; case RGB_MODE_GRADIENT: if (record->event.pressed) { if ((25 <= rgblight_get_mode()) && (rgblight_get_mode() < 34)) { rgblight_step(); } else { rgblight_mode(25); } } return false; #endif #ifdef PROTOCOL_LUFA case OUT_AUTO: if (record->event.pressed) { set_output(OUTPUT_AUTO); } return false; case OUT_USB: if (record->event.pressed) { set_output(OUTPUT_USB); } return false; #ifdef BLUETOOTH_ENABLE case OUT_BT: if (record->event.pressed) { set_output(OUTPUT_BLUETOOTH); } return false; #endif #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); } /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); switch (keycode) { case MAGIC_SWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = true; break; case MAGIC_CAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = true; break; case MAGIC_SWAP_LALT_LGUI: keymap_config.swap_lalt_lgui = true; break; case MAGIC_SWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = true; break; case MAGIC_NO_GUI: keymap_config.no_gui = true; break; case MAGIC_SWAP_GRAVE_ESC: keymap_config.swap_grave_esc = true; break; case MAGIC_SWAP_BACKSLASH_BACKSPACE: keymap_config.swap_backslash_backspace = true; break; case MAGIC_HOST_NKRO: keymap_config.nkro = true; break; case MAGIC_SWAP_ALT_GUI: keymap_config.swap_lalt_lgui = true; keymap_config.swap_ralt_rgui = true; #ifdef AUDIO_ENABLE PLAY_SONG(ag_swap_song); #endif break; case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; break; case MAGIC_UNCAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = false; break; case MAGIC_UNSWAP_LALT_LGUI: keymap_config.swap_lalt_lgui = false; break; case MAGIC_UNSWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = false; break; case MAGIC_UNNO_GUI: keymap_config.no_gui = false; break; case MAGIC_UNSWAP_GRAVE_ESC: keymap_config.swap_grave_esc = false; break; case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: keymap_config.swap_backslash_backspace = false; break; case MAGIC_UNHOST_NKRO: keymap_config.nkro = false; break; case MAGIC_UNSWAP_ALT_GUI: keymap_config.swap_lalt_lgui = false; keymap_config.swap_ralt_rgui = false; #ifdef AUDIO_ENABLE PLAY_SONG(ag_norm_song); #endif break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; break; default: break; } eeconfig_update_keymap(keymap_config.raw); clear_keyboard(); // clear to prevent stuck keys return false; } break; case KC_LSPO: { if (record->event.pressed) { shift_interrupted[0] = false; scs_timer[0] = timer_read (); register_mods(MOD_BIT(KC_LSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_RSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { register_code(LSPO_KEY); unregister_code(LSPO_KEY); } unregister_mods(MOD_BIT(KC_LSFT)); } return false; } case KC_RSPC: { if (record->event.pressed) { shift_interrupted[1] = false; scs_timer[1] = timer_read (); register_mods(MOD_BIT(KC_RSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_LSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { register_code(RSPC_KEY); unregister_code(RSPC_KEY); } unregister_mods(MOD_BIT(KC_RSFT)); } return false; } case GRAVE_ESC: { uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); #ifdef GRAVE_ESC_ALT_OVERRIDE // if ALT is pressed, ESC is always sent // this is handy for the cmd+opt+esc shortcut on macOS, among other things. if (get_mods() & (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT))) { shifted = 0; } #endif #ifdef GRAVE_ESC_CTRL_OVERRIDE // if CTRL is pressed, ESC is always sent // this is handy for the ctrl+shift+esc shortcut on windows, among other things. if (get_mods() & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL))) { shifted = 0; } #endif #ifdef GRAVE_ESC_GUI_OVERRIDE // if GUI is pressed, ESC is always sent if (get_mods() & (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))) { shifted = 0; } #endif #ifdef GRAVE_ESC_SHIFT_OVERRIDE // if SHIFT is pressed, ESC is always sent if (get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) { shifted = 0; } #endif if (record->event.pressed) { grave_esc_was_shifted = shifted; add_key(shifted ? KC_GRAVE : KC_ESCAPE); } else { del_key(grave_esc_was_shifted ? KC_GRAVE : KC_ESCAPE); } send_keyboard_report(); } default: { shift_interrupted[0] = true; shift_interrupted[1] = true; break; } } return process_action_kb(record); }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_qwerty, false, 0); #endif // persistent_default_layer_set(1UL<<_QWERTY); } return false; break; case COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_colemak, false, 0); #endif // persistent_default_layer_set(1UL<<_COLEMAK); } return false; break; case DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_dvorak, false, 0); #endif // persistent_default_layer_set(1UL<<_DVORAK); } return false; break; case LOWER: if (record->event.pressed) { //not sure how to have keyboard check mode and set it to a variable, so my work around //uses another variable that would be set to true after the first time a reactive key is pressed. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false } else { TOG_STATUS = !TOG_STATUS; #ifdef RGBLIGHT_ENABLE rgblight_mode(16); #endif } layer_on(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { #ifdef RGBLIGHT_ENABLE rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change #endif TOG_STATUS = false; layer_off(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case RAISE: if (record->event.pressed) { //not sure how to have keyboard check mode and set it to a variable, so my work around //uses another variable that would be set to true after the first time a reactive key is pressed. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false } else { TOG_STATUS = !TOG_STATUS; #ifdef RGBLIGHT_ENABLE rgblight_mode(15); #endif } layer_on(_RAISE); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { #ifdef RGBLIGHT_ENABLE rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change #endif layer_off(_RAISE); TOG_STATUS = false; update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case ADJUST: // FIXME add RGB feedback if (record->event.pressed) { layer_on(_ADJUST); } else { layer_off(_ADJUST); } return false; break; case BL_TOGG: #ifdef ISSI_ENABLE if (record->event.pressed) { print("Enabling backlight\n"); issi_init(); } #endif return false; break; case BL_STEP: if (record->event.pressed) { print("Stepping backlight\n"); #ifdef BACKLIGHT_ENABLE print("Really stepping backlight\n"); backlight_step(); #endif } return false; break; //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released #ifdef RGBLIGHT_ENABLE case RGB_MOD: if (record->event.pressed) { rgblight_mode(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } return false; break; #endif // case BL_INC: // meira_inc_backlight_level(); // return false; // break; } return true; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_qwerty); #endif persistent_default_layer_set(1UL<<_QWERTY); } return false; break; case COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_colemak); #endif persistent_default_layer_set(1UL<<_COLEMAK); } return false; break; case DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_dvorak); #endif persistent_default_layer_set(1UL<<_DVORAK); } return false; break; case LOWER: if (record->event.pressed) { //not sure how to have keyboard check mode and set it to a variable, so my work around //uses another variable that would be set to true after the first time a reactive key is pressed. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false } else { TOG_STATUS = !TOG_STATUS; #ifdef RGBLIGHT_ENABLE //rgblight_mode(16); #endif } layer_on(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { #ifdef RGBLIGHT_ENABLE //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change #endif TOG_STATUS = false; layer_off(_LOWER); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case RAISE: if (record->event.pressed) { //not sure how to have keyboard check mode and set it to a variable, so my work around //uses another variable that would be set to true after the first time a reactive key is pressed. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false } else { TOG_STATUS = !TOG_STATUS; #ifdef RGBLIGHT_ENABLE //rgblight_mode(15); #endif } layer_on(_RAISE); update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } else { #ifdef RGBLIGHT_ENABLE //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change #endif layer_off(_RAISE); TOG_STATUS = false; update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); } return false; break; case ADJUST: if (record->event.pressed) { layer_on(_ADJUST); } else { layer_off(_ADJUST); } return false; break; //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released case RGB_MOD: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { rgblight_mode(RGB_current_mode); rgblight_step(); RGB_current_mode = rgblight_config.mode; } #endif return false; break; case EISU: if (record->event.pressed) { if(keymap_config.swap_lalt_lgui==false){ register_code(KC_LANG2); }else{ SEND_STRING(SS_LALT("`")); } } else { unregister_code(KC_LANG2); } return false; break; case KANA: if (record->event.pressed) { if(keymap_config.swap_lalt_lgui==false){ register_code(KC_LANG1); }else{ SEND_STRING(SS_LALT("`")); } } else { unregister_code(KC_LANG1); } return false; break; case RGBRST: #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { eeconfig_update_rgblight_default(); rgblight_enable(); RGB_current_mode = rgblight_config.mode; } #endif break; } return true; }
bool process_record_quantum(keyrecord_t *record) { /* This gets the keycode from the key pressed */ keypos_t key = record->event.key; uint16_t keycode; #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) /* TODO: Use store_or_get_action() or a similar function. */ if (!disable_action_cache) { uint8_t layer; if (record->event.pressed) { layer = layer_switch_get_layer(key); update_source_layers_cache(key, layer); } else { layer = read_source_layers_cache(key); } keycode = keymap_key_to_keycode(layer, key); } else #endif keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); // This is how you use actions here // if (keycode == KC_LEAD) { // action_t action; // action.code = ACTION_DEFAULT_LAYER_SET(0); // process_action(record, action); // return false; // } if (!( process_record_kb(keycode, record) && #ifdef MIDI_ENABLE process_midi(keycode, record) && #endif #ifdef AUDIO_ENABLE process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif #ifndef DISABLE_LEADER process_leader(keycode, record) && #endif #ifndef DISABLE_CHORDING process_chording(keycode, record) && #endif #ifdef UNICODE_ENABLE process_unicode(keycode, record) && #endif #ifdef UCIS_ENABLE process_ucis(keycode, record) && #endif true)) { return false; } // Shift / paren setup switch(keycode) { case RESET: if (record->event.pressed) { reset_keyboard(); } return false; break; case DEBUG: if (record->event.pressed) { print("\nDEBUG: enabled.\n"); debug_enable = true; } return false; break; #ifdef RGBLIGHT_ENABLE case RGB_TOG: if (record->event.pressed) { rgblight_toggle(); } return false; break; case RGB_MOD: if (record->event.pressed) { rgblight_step(); } return false; break; case RGB_HUI: if (record->event.pressed) { rgblight_increase_hue(); } return false; break; case RGB_HUD: if (record->event.pressed) { rgblight_decrease_hue(); } return false; break; case RGB_SAI: if (record->event.pressed) { rgblight_increase_sat(); } return false; break; case RGB_SAD: if (record->event.pressed) { rgblight_decrease_sat(); } return false; break; case RGB_VAI: if (record->event.pressed) { rgblight_increase_val(); } return false; break; case RGB_VAD: if (record->event.pressed) { rgblight_decrease_val(); } return false; break; #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); } /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) { keymap_config.swap_control_capslock = 1; } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) { keymap_config.capslock_to_control = 1; } else if (keycode == MAGIC_SWAP_LALT_LGUI) { keymap_config.swap_lalt_lgui = 1; } else if (keycode == MAGIC_SWAP_RALT_RGUI) { keymap_config.swap_ralt_rgui = 1; } else if (keycode == MAGIC_NO_GUI) { keymap_config.no_gui = 1; } else if (keycode == MAGIC_SWAP_GRAVE_ESC) { keymap_config.swap_grave_esc = 1; } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) { keymap_config.swap_backslash_backspace = 1; } else if (keycode == MAGIC_HOST_NKRO) { keymap_config.nkro = 1; } else if (keycode == MAGIC_SWAP_ALT_GUI) { keymap_config.swap_lalt_lgui = 1; keymap_config.swap_ralt_rgui = 1; } /* UNs */ else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) { keymap_config.swap_control_capslock = 0; } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) { keymap_config.capslock_to_control = 0; } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) { keymap_config.swap_lalt_lgui = 0; } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) { keymap_config.swap_ralt_rgui = 0; } else if (keycode == MAGIC_UNNO_GUI) { keymap_config.no_gui = 0; } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) { keymap_config.swap_grave_esc = 0; } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) { keymap_config.swap_backslash_backspace = 0; } else if (keycode == MAGIC_UNHOST_NKRO) { keymap_config.nkro = 0; } else if (keycode == MAGIC_UNSWAP_ALT_GUI) { keymap_config.swap_lalt_lgui = 0; keymap_config.swap_ralt_rgui = 0; } eeconfig_update_keymap(keymap_config.raw); return false; } break; case KC_LSPO: { if (record->event.pressed) { shift_interrupted[0] = false; register_mods(MOD_BIT(KC_LSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_RSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[0]) { register_code(LSPO_KEY); unregister_code(LSPO_KEY); } unregister_mods(MOD_BIT(KC_LSFT)); } return false; break; } case KC_RSPC: { if (record->event.pressed) { shift_interrupted[1] = false; register_mods(MOD_BIT(KC_RSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_LSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[1]) { register_code(RSPC_KEY); unregister_code(RSPC_KEY); } unregister_mods(MOD_BIT(KC_RSFT)); } return false; break; } default: { shift_interrupted[0] = true; shift_interrupted[1] = true; break; } } return process_action_kb(record); }
bool process_record_quantum(keyrecord_t *record) { /* This gets the keycode from the key pressed */ keypos_t key = record->event.key; uint16_t keycode; #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) /* TODO: Use store_or_get_action() or a similar function. */ if (!disable_action_cache) { uint8_t layer; if (record->event.pressed) { layer = layer_switch_get_layer(key); update_source_layers_cache(key, layer); } else { layer = read_source_layers_cache(key); } keycode = keymap_key_to_keycode(layer, key); } else #endif keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); // This is how you use actions here // if (keycode == KC_LEAD) { // action_t action; // action.code = ACTION_DEFAULT_LAYER_SET(0); // process_action(record, action); // return false; // } if (!( process_record_kb(keycode, record) && #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED) process_midi(keycode, record) && #endif #ifdef AUDIO_ENABLE process_audio(keycode, record) && #endif #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif #ifndef DISABLE_LEADER process_leader(keycode, record) && #endif #ifndef DISABLE_CHORDING process_chording(keycode, record) && #endif #ifdef COMBO_ENABLE process_combo(keycode, record) && #endif #ifdef UNICODE_ENABLE process_unicode(keycode, record) && #endif #ifdef UCIS_ENABLE process_ucis(keycode, record) && #endif #ifdef PRINTING_ENABLE process_printer(keycode, record) && #endif #ifdef UNICODEMAP_ENABLE process_unicode_map(keycode, record) && #endif true)) { return false; } // Shift / paren setup switch(keycode) { case RESET: if (record->event.pressed) { reset_keyboard(); } return false; break; case DEBUG: if (record->event.pressed) { print("\nDEBUG: enabled.\n"); debug_enable = true; } return false; break; #ifdef FAUXCLICKY_ENABLE case FC_TOG: if (record->event.pressed) { FAUXCLICKY_TOGGLE; } return false; break; case FC_ON: if (record->event.pressed) { FAUXCLICKY_ON; } return false; break; case FC_OFF: if (record->event.pressed) { FAUXCLICKY_OFF; } return false; break; #endif #ifdef RGBLIGHT_ENABLE case RGB_TOG: if (record->event.pressed) { rgblight_toggle(); } return false; break; case RGB_MOD: if (record->event.pressed) { rgblight_step(); } return false; break; case RGB_HUI: if (record->event.pressed) { rgblight_increase_hue(); } return false; break; case RGB_HUD: if (record->event.pressed) { rgblight_decrease_hue(); } return false; break; case RGB_SAI: if (record->event.pressed) { rgblight_increase_sat(); } return false; break; case RGB_SAD: if (record->event.pressed) { rgblight_decrease_sat(); } return false; break; case RGB_VAI: if (record->event.pressed) { rgblight_increase_val(); } return false; break; case RGB_VAD: if (record->event.pressed) { rgblight_decrease_val(); } return false; break; #endif #ifdef PROTOCOL_LUFA case OUT_AUTO: if (record->event.pressed) { set_output(OUTPUT_AUTO); } return false; break; case OUT_USB: if (record->event.pressed) { set_output(OUTPUT_USB); } return false; break; #ifdef BLUETOOTH_ENABLE case OUT_BT: if (record->event.pressed) { set_output(OUTPUT_BLUETOOTH); } return false; break; #endif #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); } /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); switch (keycode) { case MAGIC_SWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = true; break; case MAGIC_CAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = true; break; case MAGIC_SWAP_LALT_LGUI: keymap_config.swap_lalt_lgui = true; break; case MAGIC_SWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = true; break; case MAGIC_NO_GUI: keymap_config.no_gui = true; break; case MAGIC_SWAP_GRAVE_ESC: keymap_config.swap_grave_esc = true; break; case MAGIC_SWAP_BACKSLASH_BACKSPACE: keymap_config.swap_backslash_backspace = true; break; case MAGIC_HOST_NKRO: keymap_config.nkro = true; break; case MAGIC_SWAP_ALT_GUI: keymap_config.swap_lalt_lgui = true; keymap_config.swap_ralt_rgui = true; break; case MAGIC_UNSWAP_CONTROL_CAPSLOCK: keymap_config.swap_control_capslock = false; break; case MAGIC_UNCAPSLOCK_TO_CONTROL: keymap_config.capslock_to_control = false; break; case MAGIC_UNSWAP_LALT_LGUI: keymap_config.swap_lalt_lgui = false; break; case MAGIC_UNSWAP_RALT_RGUI: keymap_config.swap_ralt_rgui = false; break; case MAGIC_UNNO_GUI: keymap_config.no_gui = false; break; case MAGIC_UNSWAP_GRAVE_ESC: keymap_config.swap_grave_esc = false; break; case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: keymap_config.swap_backslash_backspace = false; break; case MAGIC_UNHOST_NKRO: keymap_config.nkro = false; break; case MAGIC_UNSWAP_ALT_GUI: keymap_config.swap_lalt_lgui = false; keymap_config.swap_ralt_rgui = false; break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; break; default: break; } eeconfig_update_keymap(keymap_config.raw); clear_keyboard(); // clear to prevent stuck keys return false; } break; case KC_LSPO: { if (record->event.pressed) { shift_interrupted[0] = false; scs_timer[0] = timer_read (); register_mods(MOD_BIT(KC_LSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_RSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { register_code(LSPO_KEY); unregister_code(LSPO_KEY); } unregister_mods(MOD_BIT(KC_LSFT)); } return false; // break; } case KC_RSPC: { if (record->event.pressed) { shift_interrupted[1] = false; scs_timer[1] = timer_read (); register_mods(MOD_BIT(KC_RSFT)); } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER if (get_mods() & MOD_BIT(KC_LSFT)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { register_code(RSPC_KEY); unregister_code(RSPC_KEY); } unregister_mods(MOD_BIT(KC_RSFT)); } return false; // break; } case GRAVE_ESC: { void (*method)(uint8_t) = (record->event.pressed) ? &add_key : &del_key; uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); method(shifted ? KC_GRAVE : KC_ESCAPE); send_keyboard_report(); } default: { shift_interrupted[0] = true; shift_interrupted[1] = true; break; } } return process_action_kb(record); }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { rgblight_step(); } return true; }