void reset_keyboard_kb(){ #ifdef WATCHDOG_ENABLE MCUSR = 0; wdt_disable(); wdt_reset(); #endif xprintf("programming!\n"); reset_keyboard(); }
void Abstract::doGuardFinalize() { if (pArea && pArea->background == gfx->glfond) pArea->background = 0; doFinalize(); reset_keyboard(); clear_keybuf(); reset_mouse(); }
void RST_finished (qk_tap_dance_state_t *state, void *user_data) { RSTtap_state.state = cur_dance(state); switch (RSTtap_state.state) { case SINGLE_TAP: register_code(KC_LCTL); break; case SINGLE_HOLD: register_code(KC_LCTL); break; case DOUBLE_TAP: reset_keyboard(); break; case DOUBLE_SINGLE_TAP: register_code(KC_LCTL); unregister_code(KC_LCTL); register_code(KC_LCTL); break; } }
// on the fourth tap, set the keyboard on flash state // and set the underglow to red, because red == bad void dance_flsh_finished(qk_tap_dance_state_t *state, void *user_data) { if (state->count >= 4) { rgblight_enable(); rgblight_mode(1); rgblight_setrgb(0xff,0x00,0x00); reset_keyboard(); reset_tap_dance(state); } }
void reset_keyboard_kb(){ #ifdef WATCHDOG_ENABLE MCUSR = 0; wdt_disable(); wdt_reset(); #endif OCR1A = 0x0000; // B5 - Red OCR1B = 0x0FFF; // B6 - Green OCR1C = 0x0FFF; // B7 - Blue reset_keyboard(); }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case DFU: if (record->event.pressed) { clear_keyboard(); reset_keyboard(); } return false; break; } return process_record_keymap(keycode, record) && process_record_secrets(keycode, record); }
bool Abstract::doGuardInitialize() { pMouseX = -1; pMouseY = -1; pMouseZ = -1; pMouseB = -1; cursor_type = CURSOR_DEFAULT; reset_keyboard(); reset_mouse(); clear_keybuf(); bool r = doInitialize(); return r; }
void CAD_finished (qk_tap_dance_state_t *state, void *user_data) { CADtap_state.state = cur_dance(state); switch (CADtap_state.state) { case SINGLE_TAP: //register_code(KC_SPC); SEND_STRING(SS_LGUI("l")); #ifdef BACKLIGHT_ENABLE backlight_level(3); #endif break; case SINGLE_HOLD: //register_code(KC_NO); //take a screenshot of a single window, open Paint and paste SEND_STRING(SS_LALT(SS_TAP(X_PSCREEN)) SS_LGUI("r")); _delay_ms(500); SEND_STRING("mspaint" SS_TAP(X_ENTER)); _delay_ms(700); SEND_STRING(SS_LCTRL("v")); break; //register this keycode when button is held case DOUBLE_TAP: //register_code(KC_ENT); SEND_STRING(SS_LCTRL(SS_LALT(SS_TAP(X_DELETE)))); #ifdef BACKLIGHT_ENABLE backlight_level(0); #endif break; //case DOUBLE_HOLD: register_code(KC_NO); break; //register this keycode when button is tapped and then held case DOUBLE_HOLD: reset_keyboard(); break; //register this keycode when button is tapped and then held case TRIPLE_TAP: SEND_STRING("*****@*****.**"); break; case TRIPLE_HOLD: set_single_persistent_default_layer(1); #ifdef AUDIO_ENABLE stop_all_notes(); PLAY_SONG(lyrup_song); #endif break; } }
void BSW_finished (qk_tap_dance_state_t *state, void *user_data) { BSWtap_state.state = cur_dance(state); switch (BSWtap_state.state) { case SINGLE_TAP: register_code(KC_ENTER); break; case SINGLE_HOLD: set_single_persistent_default_layer(0); #ifdef AUDIO_ENABLE stop_all_notes(); PLAY_SONG(lyrdown_song); #endif break; case DOUBLE_TAP: register_code(KC_LCTRL); register_code(KC_C); break; case DOUBLE_HOLD: reset_keyboard(); break; //register this keycode when button is tapped and then held } }
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_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_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_user(uint16_t keycode, keyrecord_t *record) { static uint32_t key_timer; switch (keycode) { case L_BRI: if (record->event.pressed) { if (LED_GCR_STEP > LED_GCR_MAX - gcr_desired) gcr_desired = LED_GCR_MAX; else gcr_desired += LED_GCR_STEP; if (led_animation_breathing) gcr_breathe = gcr_desired; } return false; case L_BRD: if (record->event.pressed) { if (LED_GCR_STEP > gcr_desired) gcr_desired = 0; else gcr_desired -= LED_GCR_STEP; if (led_animation_breathing) gcr_breathe = gcr_desired; } return false; case L_PTN: if (record->event.pressed) { if (led_animation_id == led_setups_count - 1) led_animation_id = 0; else led_animation_id++; } return false; case L_PTP: if (record->event.pressed) { if (led_animation_id == 0) led_animation_id = led_setups_count - 1; else led_animation_id--; } return false; case L_PSI: if (record->event.pressed) { led_animation_speed += ANIMATION_SPEED_STEP; } return false; case L_PSD: if (record->event.pressed) { led_animation_speed -= ANIMATION_SPEED_STEP; if (led_animation_speed < 0) led_animation_speed = 0; } return false; case L_T_MD: if (record->event.pressed) { led_lighting_mode++; if (led_lighting_mode > LED_MODE_MAX_INDEX) led_lighting_mode = LED_MODE_NORMAL; } return false; case L_T_ONF: if (record->event.pressed) { led_enabled = !led_enabled; I2C3733_Control_Set(led_enabled); } return false; case L_ON: if (record->event.pressed) { led_enabled = 1; I2C3733_Control_Set(led_enabled); } return false; case L_OFF: if (record->event.pressed) { led_enabled = 0; I2C3733_Control_Set(led_enabled); } return false; case L_T_BR: if (record->event.pressed) { led_animation_breathing = !led_animation_breathing; if (led_animation_breathing) { gcr_breathe = gcr_desired; led_animation_breathe_cur = BREATHE_MIN_STEP; breathe_dir = 1; } } return false; case L_T_PTD: if (record->event.pressed) { led_animation_direction = !led_animation_direction; } return false; case U_T_AGCR: if (record->event.pressed && MODS_SHIFT && MODS_CTRL) { TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode"); } return false; case DBG_TOG: if (record->event.pressed) { TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode"); } return false; case DBG_MTRX: if (record->event.pressed) { TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix"); } return false; case DBG_KBD: if (record->event.pressed) { TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard"); } return false; case DBG_MOU: if (record->event.pressed) { TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse"); } return false; case MD_BOOT: if (record->event.pressed) { key_timer = timer_read32(); } else { if (timer_elapsed32(key_timer) >= 500) { reset_keyboard(); } } return false; default: return true; //Process all other keycodes normally } }
void flash_dance_finished(qk_tap_dance_state_t *state, void *user_data) { if (state->count >= 4) { reset_keyboard(); reset_tap_dance(state); } }
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); }
// Defines actions tor my global custom keycodes. Defined in drashna.h file // Then runs the _keymap's recod handier if not processed here bool process_record_user(uint16_t keycode, keyrecord_t *record) { #ifdef CONSOLE_ENABLE xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); #endif #ifdef AUDIO_ENABLE if (faux_click_enabled) { if (record->event.pressed) { PLAY_SONG(fauxclicky_pressed); } else { stop_note(NOTE_A6); PLAY_SONG(fauxclicky_released); } } #endif switch (keycode) { case KC_QWERTY: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_qwerty); #endif persistent_default_layer_set(1UL << _QWERTY); } return false; break; case KC_COLEMAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_colemak); #endif persistent_default_layer_set(1UL << _COLEMAK); } return false; break; case KC_DVORAK: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_dvorak); #endif persistent_default_layer_set(1UL << _DVORAK); } return false; break; case KC_WORKMAN: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_SONG(tone_workman); #endif persistent_default_layer_set(1UL << _WORKMAN); } return false; break; case LOWER: if (record->event.pressed) { layer_on(_LOWER); update_tri_layer(_LOWER, _RAISE, _ADJUST); } else { layer_off(_LOWER); update_tri_layer(_LOWER, _RAISE, _ADJUST); } return false; break; case RAISE: if (record->event.pressed) { layer_on(_RAISE); update_tri_layer(_LOWER, _RAISE, _ADJUST); } else { layer_off(_RAISE); update_tri_layer(_LOWER, _RAISE, _ADJUST); } return false; break; case ADJUST: if (record->event.pressed) { layer_on(_ADJUST); } else { layer_off(_ADJUST); } return false; break; #if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez)) case KC_OVERWATCH: if (record->event.pressed) { is_overwatch = !is_overwatch; } #ifdef RGBLIGHT_ENABLE is_overwatch ? rgblight_mode(17) : rgblight_mode(18); #endif return false; break; case KC_SALT: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("Salt, salt, salt..."); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_MORESALT: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("Please sir, can I have some more salt?!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_SALTHARD: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("Your salt only makes me harder, and even more aggressive!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_GOODGAME: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("Good game, everyone!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_GLHF: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("Good luck, have fun!!!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_SYMM: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("Left click to win!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_JUSTGAME: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("It may be a game, but if you don't want to actually try, please go play AI, so that people that actually want to take the game seriously and \"get good\" have a place to do so without trolls like you throwing games."); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_TORB: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("That was positively riveting!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_AIM: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("That aim is absolutely amazing. It's almost like you're a machine!" SS_TAP(X_ENTER)); wait_ms(3000); register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); SEND_STRING("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!" SS_TAP(X_ENTER)); } return false; break; case KC_C9: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("OMG!!! C9!!!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; case KC_GGEZ: if (!record->event.pressed) { register_code(is_overwatch ? KC_BSPC : KC_ENTER); unregister_code(is_overwatch ? KC_BSPC : KC_ENTER); wait_ms(50); SEND_STRING("That was a fantastic game, though it was a bit easy. Try harder next time!"); register_code(KC_ENTER); unregister_code(KC_ENTER); } return false; break; #endif #ifdef TAP_DANCE_ENABLE case KC_DIABLO_CLEAR: // reset all Diable timers, disabling them if (record->event.pressed) { uint8_t dtime; for (dtime = 0; dtime < 4; dtime++) { diablo_key_time[dtime] = diablo_times[0]; } } return false; break; #endif case KC_MAKE: if (!record->event.pressed) { SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU)) ":dfu" #elif defined(BOOTLOADER_HALFKAY) ":teensy" //#elif defined(BOOTLOADER_CATERINA) // ":avrdude" #endif SS_TAP(X_ENTER)); } return false; break; case KC_RESET: if (!record->event.pressed) { #ifdef RGBLIGHT_ENABLE rgblight_enable(); rgblight_mode(1); rgblight_setrgb(0xff, 0x00, 0x00); #endif reset_keyboard(); } return false; break; case EPRM: if (record->event.pressed) { eeconfig_init(); } return false; break; case VRSN: if (record->event.pressed) { SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); } return false; break; case KC_SECRET_1 ... KC_SECRET_5: if (!record->event.pressed) { send_string_P(secret[keycode - KC_SECRET_1]); } return false; break; case KC_FXCL: if (!record->event.pressed) { faux_click_enabled = !faux_click_enabled; } return false; break; case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication #ifdef RGBLIGHT_ENABLE if (record->event.pressed) { rgb_layer_change = !rgb_layer_change; } #endif return false; break; #ifdef RGBLIGHT_ENABLE case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions if (record->event.pressed) { //This disrables layer indication, as it's assumed that if you're changing this ... you want that disabled rgb_layer_change = false; } return true; break; #endif } return process_record_keymap(keycode, record); }