/* translates keycode to action */ static action_t keycode_to_action(uint8_t keycode) { action_t action = {}; switch (keycode) { case KC_A ... KC_EXSEL: case KC_LCTRL ... KC_RGUI: action.code = ACTION_KEY(keycode); break; case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: action.code = ACTION_MOUSEKEY(keycode); break; case KC_TRNS: action.code = ACTION_TRANSPARENT; break; case KC_BOOTLOADER: clear_keyboard(); wait_ms(50); bootloader_jump(); // not return break; default: action.code = ACTION_NO; break; } return action; }
void bootmagic_lite(void) { // The lite version of TMK's bootmagic. // 100% less potential for accidentally making the // keyboard do stupid things. // We need multiple scans because debouncing can't be turned off. matrix_scan(); wait_ms(DEBOUNCING_DELAY); matrix_scan(); // If the Esc and space bar are held down on power up, // reset the EEPROM valid state and jump to bootloader. // Assumes Esc is at [0,0] and spacebar is at [4,7]. // This isn't very generalized, but we need something that doesn't // rely on user's keymaps in firmware or EEPROM. if ( ( matrix_get_row(0) & (1<<0) ) && ( matrix_get_row(4) & (1<<7) ) ) { // Set the Zeal60 specific EEPROM state as invalid. eeprom_set_valid(false); // Set the TMK/QMK EEPROM state as invalid. eeconfig_disable(); // Jump to bootloader. bootloader_jump(); } }
void bootmagic_lite(void) { // The lite version of TMK's bootmagic based on Wilba. // 100% less potential for accidentally making the // keyboard do stupid things. // We need multiple scans because debouncing can't be turned off. matrix_scan(); #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 wait_ms(DEBOUNCING_DELAY * 2); #elif defined(DEBOUNCE) && DEBOUNCE > 0 wait_ms(DEBOUNCE * 2); #else wait_ms(30); #endif matrix_scan(); // If the Esc and space bar are held down on power up, // reset the EEPROM valid state and jump to bootloader. // Assumes Esc is at [0,0]. // This isn't very generalized, but we need something that doesn't // rely on user's keymaps in firmware or EEPROM. if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { eeconfig_disable(); // Jump to bootloader. bootloader_jump(); } }
void reset_keyboard(void) { clear_keyboard(); #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) process_midi_all_notes_off(); #endif #ifdef AUDIO_ENABLE #ifndef NO_MUSIC_MODE music_all_notes_off(); #endif uint16_t timer_start = timer_read(); PLAY_SONG(goodbye_song); shutdown_user(); while(timer_elapsed(timer_start) < 250) wait_ms(1); stop_all_notes(); #else shutdown_user(); wait_ms(250); #endif // this is also done later in bootloader.c - not sure if it's neccesary here #ifdef BOOTLOADER_CATERINA *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); }
static bool command_common(uint8_t code) { static host_driver_t *host_driver = 0; switch (code) { #ifdef SLEEP_LED_ENABLE case KC_Z: // test breathing sleep LED print("Sleep LED test\n"); sleep_led_toggle(); led_set(host_keyboard_leds()); break; #endif #ifdef BOOTMAGIC_ENABLE case KC_E: print("eeconfig:\n"); print_eeconfig(); break; #endif #ifdef KEYBOARD_LOCK_ENABLE case KC_CAPSLOCK: if (host_get_driver()) { host_driver = host_get_driver(); clear_keyboard(); host_set_driver(0); print("Locked.\n"); } else { host_set_driver(host_driver); print("Unlocked.\n"); } break; #endif case KC_H: case KC_SLASH: /* ? */ command_common_help(); break; case KC_C: debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; command_console_help(); print("C> "); command_state = CONSOLE; break; case KC_PAUSE: clear_keyboard(); print("\n\nbootloader... "); _delay_ms(1000); bootloader_jump(); // not return break; case KC_D: if (debug_enable) { <<<<<<< HEAD print("\ndebug: off\n"); ======= print("\ndebug: on\n"); >>>>>>> upstream/master
void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) { if (id == TEENSY_KEY) { clear_keyboard(); print("\n\nJump to bootloader... "); _delay_ms(250); bootloader_jump(); // should not return print("not supported.\n"); } }
void reset_keyboard(void) { clear_keyboard(); #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) music_all_notes_off(); shutdown_user(); #endif wait_ms(250); #ifdef CATERINA_BOOTLOADER *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); }
void reset_keyboard(void) { clear_keyboard(); #ifdef AUDIO_ENABLE stop_all_notes(); shutdown_user(); #endif wait_ms(250); #ifdef CATERINA_BOOTLOADER *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); }
/* * main - Bootstrap main entry function * * INPUT * - argc: (not used) * - argv: (not used) * OUTPUT * 0 when complete */ int main(int argc, char* argv[]) { (void)argc; (void)argv; /* Main loop for bootloader to transition to next step */ cm_disable_interrupts(); set_vector_table_bootloader(); bootloader_jump(); bootstrap_halt(); return(0); /* Should never get here */ }
int main(void) { DEBUG_LED_CONFIG; DEBUG_LED_OFF; // set for 16 MHz clock CPU_PRESCALE(0); // Initialize the USB, and then wait for the host to set configuration. // If the Teensy is powered without a PC connected to the USB port, // this will wait forever. usb_init(); while (!usb_configured()) /* wait */ ; keyboard_init(); matrix_scan(); if (matrix_key_count() >= 3) { #ifdef DEBUG_LED for (int i = 0; i < 6; i++) { DEBUG_LED_CONFIG; DEBUG_LED_ON; _delay_ms(500); DEBUG_LED_OFF; _delay_ms(500); } #else _delay_ms(5000); #endif print_enable = true; debug_enable = true; debug_matrix = true; debug_keyboard = true; debug_mouse = true; print("debug enabled.\n"); } if (matrix_key_count() >= 4) { print("jump to bootloader...\n"); _delay_ms(1000); bootloader_jump(); // not return } host_set_driver(pjrc_driver()); while (1) { keyboard_proc(); } }
int main (void){ //Do setup here DDRB = _BV(PORTB5); uint8_t c = 0; //Main program loop while (1){ PORTB ^= _BV(PORTB5); _delay_ms(500); c++; if (c > 10){ bootloader_jump(); } } }
void reset_keyboard(void) { clear_keyboard(); #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC)) music_all_notes_off(); uint16_t timer_start = timer_read(); PLAY_SONG(goodbye_song); shutdown_user(); while(timer_elapsed(timer_start) < 250) wait_ms(1); stop_all_notes(); #else wait_ms(250); #endif #ifdef CATERINA_BOOTLOADER *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); }
static bool command_common(uint8_t code) { static host_driver_t *host_driver = 0; switch (code) { #ifdef SLEEP_LED_ENABLE case KC_Z: // test breathing sleep LED print("Sleep LED test\n"); sleep_led_toggle(); led_set(host_keyboard_leds()); break; #endif #ifdef BOOTMAGIC_ENABLE case KC_E: print("eeconfig:\n"); print_eeconfig(); break; #endif case KC_CAPSLOCK: if (host_get_driver()) { host_driver = host_get_driver(); host_set_driver(0); print("Locked.\n"); } else { host_set_driver(host_driver); print("Unlocked.\n"); } break; case KC_H: case KC_SLASH: /* ? */ command_common_help(); break; case KC_C: debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; command_console_help(); print("\nEnter Console Mode\n"); print("C> "); state = CONSOLE; break; case KC_PAUSE: clear_keyboard(); print("\n\nJump to bootloader... "); _delay_ms(1000); bootloader_jump(); // not return print("not supported.\n"); break; case KC_D: if (debug_enable) { print("\nDEBUG: disabled.\n"); debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; } else { print("\nDEBUG: enabled.\n"); debug_enable = true; } break; case KC_X: // debug matrix toggle debug_matrix = !debug_matrix; if (debug_matrix) { print("\nDEBUG: matrix enabled.\n"); debug_enable = true; } else { print("\nDEBUG: matrix disabled.\n"); } break; case KC_K: // debug keyboard toggle debug_keyboard = !debug_keyboard; if (debug_keyboard) { print("\nDEBUG: keyboard enabled.\n"); debug_enable = true; } else { print("\nDEBUG: keyboard disabled.\n"); } break; case KC_M: // debug mouse toggle debug_mouse = !debug_mouse; if (debug_mouse) { print("\nDEBUG: mouse enabled.\n"); debug_enable = true; } else { print("\nDEBUG: mouse disabled.\n"); } break; case KC_V: // print version & information print("\n\n----- Version -----\n"); print("DESC: " STR(DESCRIPTION) "\n"); print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " "VER: " STR(DEVICE_VER) "\n"); print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n"); /* build options */ print("OPTIONS:" #ifdef PROTOCOL_PJRC " PJRC" #endif #ifdef PROTOCOL_LUFA " LUFA" #endif #ifdef PROTOCOL_VUSB " VUSB" #endif #ifdef BOOTMAGIC_ENABLE " BOOTMAGIC" #endif #ifdef MOUSEKEY_ENABLE " MOUSEKEY" #endif #ifdef EXTRAKEY_ENABLE " EXTRAKEY" #endif #ifdef CONSOLE_ENABLE " CONSOLE" #endif #ifdef COMMAND_ENABLE " COMMAND" #endif #ifdef NKRO_ENABLE " NKRO" #endif #ifdef KEYMAP_SECTION_ENABLE " KEYMAP_SECTION" #endif " " STR(BOOTLOADER_SIZE) "\n"); print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n"); break; case KC_T: // print timer print_val_hex32(timer_count); break; case KC_S: print("\n\n----- Status -----\n"); print_val_hex8(host_keyboard_leds()); #ifdef PROTOCOL_PJRC print_val_hex8(UDCON); print_val_hex8(UDIEN); print_val_hex8(UDINT); print_val_hex8(usb_keyboard_leds); print_val_hex8(usb_keyboard_protocol); print_val_hex8(usb_keyboard_idle_config); print_val_hex8(usb_keyboard_idle_count); #endif #ifdef PROTOCOL_PJRC # if USB_COUNT_SOF print_val_hex8(usbSofCount); # endif #endif break; #ifdef NKRO_ENABLE case KC_N: clear_keyboard(); //Prevents stuck keys. keyboard_nkro = !keyboard_nkro; if (keyboard_nkro) print("NKRO: enabled\n"); else print("NKRO: disabled\n"); break; #endif #ifdef EXTRAKEY_ENABLE case KC_PSCREEN: // TODO: Power key should take this feature? otherwise any key during suspend. #ifdef PROTOCOL_PJRC if (suspend && remote_wakeup) { usb_remote_wakeup(); } else { host_system_send(SYSTEM_POWER_DOWN); host_system_send(0); _delay_ms(500); } #else host_system_send(SYSTEM_POWER_DOWN); _delay_ms(100); host_system_send(0); _delay_ms(500); #endif break; #endif case KC_ESC: case KC_GRV: case KC_0: switch_default_layer(0); break; case KC_1 ... KC_9: switch_default_layer((code - KC_1) + 1); break; case KC_F1 ... KC_F12: switch_default_layer((code - KC_F1) + 1); break; default: print("?"); return false; } return true; }
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { if (record->event.pressed) dprint("P"); else dprint("R"); if (record->tap.interrupted) dprint("i"); # define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)) static uint8_t shift_mod; # define MODS_MASK_1 (MOD_BIT(KC_LALT)) # define MODS_MASK_2 (MOD_BIT(KC_RALT)) static uint8_t lalt_ralt_mods; switch (id) { // Shift + Scroll Lock -> Num Pad Layer On case SHIFT_NUM: shift_mod = get_mods()&MODS_SHIFT_MASK; if (record->event.pressed) { if (shift_mod) { layer_invert(1); // toggle number pad layer DDR_NUMLAYER ^= (1<<BIT_NUMLAYER); // turn on layer LED } else { del_mods(shift_mod); // remove shift add_key(KC_SLCK); send_keyboard_report(); // send Scroll Lock add_mods(shift_mod); // return shift but not sent } } else { if (shift_mod) { } else { del_key(KC_SLCK); send_keyboard_report(); } } break; // Shift + Num Lock -> Num Pad Layer Off case SHIFT_NUM1: shift_mod = get_mods()&MODS_SHIFT_MASK; if (record->event.pressed) { if (shift_mod) { layer_invert(1); // toggle number pad layer DDR_NUMLAYER ^= (1<<BIT_NUMLAYER); // turn off layer LED } else { del_mods(shift_mod); // remove shift add_key(KC_NLCK); send_keyboard_report(); // send Num Lock add_mods(shift_mod); // return shift but not sent } } else { if (shift_mod) { } else { del_key(KC_NLCK); send_keyboard_report(); } } break; // Left ALT + Right ALT + Pause = DFU case PAUS_BOOT: lalt_ralt_mods = get_mods()&MODS_MASK_1 && get_mods()&MODS_MASK_2; if (record->event.pressed) { if (lalt_ralt_mods) { del_mods(lalt_ralt_mods); send_keyboard_report(); clear_keyboard(); bootloader_jump(); } else { del_mods(lalt_ralt_mods); // remove shift add_key(KC_PAUS); send_keyboard_report(); // send Scroll Lock add_mods(lalt_ralt_mods); // return shift but not sent } } else { if (lalt_ralt_mods) { } else { del_key(KC_PAUS); send_keyboard_report(); } } break; } };
static bool command_common(uint8_t code) { #ifdef KEYBOARD_LOCK_ENABLE static host_driver_t *host_driver = 0; #endif switch (code) { #ifdef SLEEP_LED_ENABLE // test breathing sleep LED case MAGIC_KC(MAGIC_KEY_SLEEP_LED): print("Sleep LED Test\n"); sleep_led_toggle(); led_set(host_keyboard_leds()); break; #endif #ifdef BOOTMAGIC_ENABLE // print stored eeprom config case MAGIC_KC(MAGIC_KEY_EEPROM): print("eeconfig:\n"); print_eeconfig(); break; #endif #ifdef KEYBOARD_LOCK_ENABLE // lock/unlock keyboard case MAGIC_KC(MAGIC_KEY_LOCK): if (host_get_driver()) { host_driver = host_get_driver(); clear_keyboard(); host_set_driver(0); print("Locked.\n"); } else { host_set_driver(host_driver); print("Unlocked.\n"); } break; #endif // print help case MAGIC_KC(MAGIC_KEY_HELP1): case MAGIC_KC(MAGIC_KEY_HELP2): command_common_help(); break; // activate console case MAGIC_KC(MAGIC_KEY_CONSOLE): debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; command_console_help(); print("C> "); command_state = CONSOLE; break; // jump to bootloader case MAGIC_KC(MAGIC_KEY_BOOTLOADER): clear_keyboard(); // clear to prevent stuck keys print("\n\nJumping to bootloader... "); #ifdef AUDIO_ENABLE stop_all_notes(); shutdown_user(); #else wait_ms(1000); #endif bootloader_jump(); // not return break; // debug toggle case MAGIC_KC(MAGIC_KEY_DEBUG): debug_enable = !debug_enable; if (debug_enable) { print("\ndebug: on\n"); debug_matrix = true; debug_keyboard = true; debug_mouse = true; } else { print("\ndebug: off\n"); } break; // debug matrix toggle case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX): debug_matrix = !debug_matrix; if (debug_matrix) { print("\nmatrix: on\n"); debug_enable = true; } else { print("\nmatrix: off\n"); } break; // debug keyboard toggle case MAGIC_KC(MAGIC_KEY_DEBUG_KBD): debug_keyboard = !debug_keyboard; if (debug_keyboard) { print("\nkeyboard: on\n"); debug_enable = true; } else { print("\nkeyboard: off\n"); } break; // debug mouse toggle case MAGIC_KC(MAGIC_KEY_DEBUG_MOUSE): debug_mouse = !debug_mouse; if (debug_mouse) { print("\nmouse: on\n"); debug_enable = true; } else { print("\nmouse: off\n"); } break; // print version case MAGIC_KC(MAGIC_KEY_VERSION): print_version(); break; // print status case MAGIC_KC(MAGIC_KEY_STATUS): print_status(); break; #ifdef NKRO_ENABLE // NKRO toggle case MAGIC_KC(MAGIC_KEY_NKRO): clear_keyboard(); // clear to prevent stuck keys keymap_config.nkro = !keymap_config.nkro; if (keymap_config.nkro) { print("NKRO: on\n"); } else { print("NKRO: off\n"); } break; #endif // switch layers case MAGIC_KC(MAGIC_KEY_LAYER0_ALT1): case MAGIC_KC(MAGIC_KEY_LAYER0_ALT2): switch_default_layer(0); break; #if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM case MAGIC_KC(MAGIC_KEY_LAYER0): switch_default_layer(0); break; case MAGIC_KC(MAGIC_KEY_LAYER1): switch_default_layer(1); break; case MAGIC_KC(MAGIC_KEY_LAYER2): switch_default_layer(2); break; case MAGIC_KC(MAGIC_KEY_LAYER3): switch_default_layer(3); break; case MAGIC_KC(MAGIC_KEY_LAYER4): switch_default_layer(4); break; case MAGIC_KC(MAGIC_KEY_LAYER5): switch_default_layer(5); break; case MAGIC_KC(MAGIC_KEY_LAYER6): switch_default_layer(6); break; case MAGIC_KC(MAGIC_KEY_LAYER7): switch_default_layer(7); break; case MAGIC_KC(MAGIC_KEY_LAYER8): switch_default_layer(8); break; case MAGIC_KC(MAGIC_KEY_LAYER9): switch_default_layer(9); break; #endif #if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS case KC_F1 ... KC_F9: switch_default_layer((code - KC_F1) + 1); break; case KC_F10: switch_default_layer(0); break; #endif #if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS case KC_1 ... KC_9: switch_default_layer((code - KC_1) + 1); break; case KC_0: switch_default_layer(0); break; #endif default: print("?"); return false; } return true; }
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 persistant_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 persistant_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 persistant_default_layer_set(1UL<<_DVORAK); } 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 BACKLIT: if (record->event.pressed) { register_code(KC_RSFT); #ifdef BACKLIGHT_ENABLE backlight_step(); #endif } else { unregister_code(KC_RSFT); } return false; break; 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); } return false; break; case EXT_PLV: if (record->event.pressed) { #ifdef AUDIO_ENABLE PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); #endif layer_off(_PLOVER); } return false; break; case DFU: if (record->event.pressed) { clear_keyboard(); #if defined(MIDI_ENABLE) && defined(MIDI_BASIC) process_midi_all_notes_off(); #endif #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) music_all_notes_off(); uint16_t timer_start = timer_read(); PLAY_NOTE_ARRAY(tone_goodbye, false, 0); shutdown_user(); while(timer_elapsed(timer_start) < 250) wait_ms(1); stop_all_notes(); #else wait_ms(250); #endif // this is also done later in bootloader.c - not sure if it's neccesary here #ifdef BOOTLOADER_CATERINA *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); } return false; break; } return true; }
static bool command_common(uint8_t code) { #ifdef KEYBOARD_LOCK_ENABLE static host_driver_t *host_driver = 0; #endif #ifdef SLEEP_LED_ENABLE static bool sleep_led_test = false; #endif switch (code) { #ifdef SLEEP_LED_ENABLE case KC_Z: // test breathing sleep LED print("Sleep LED test\n"); if (sleep_led_test) { sleep_led_disable(); led_set(host_keyboard_leds()); } else { sleep_led_enable(); } sleep_led_test = !sleep_led_test; break; #endif #ifdef BOOTMAGIC_ENABLE case KC_E: print("eeconfig:\n"); print_eeconfig(); break; #endif #ifdef KEYBOARD_LOCK_ENABLE case KC_CAPSLOCK: if (host_get_driver()) { host_driver = host_get_driver(); clear_keyboard(); host_set_driver(0); print("Locked.\n"); } else { host_set_driver(host_driver); print("Unlocked.\n"); } break; #endif case KC_H: case KC_SLASH: /* ? */ command_common_help(); break; case KC_C: debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; command_console_help(); print("C> "); command_state = CONSOLE; break; case KC_PAUSE: clear_keyboard(); print("\n\nbootloader... "); wait_ms(1000); bootloader_jump(); // not return break; case KC_D: if (debug_enable) { print("\ndebug: off\n"); debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; } else { print("\ndebug: on\n"); debug_enable = true; } break; case KC_X: // debug matrix toggle debug_matrix = !debug_matrix; if (debug_matrix) { print("\nmatrix: on\n"); debug_enable = true; } else { print("\nmatrix: off\n"); } break; case KC_K: // debug keyboard toggle debug_keyboard = !debug_keyboard; if (debug_keyboard) { print("\nkeyboard: on\n"); debug_enable = true; } else { print("\nkeyboard: off\n"); } break; case KC_M: // debug mouse toggle debug_mouse = !debug_mouse; if (debug_mouse) { print("\nmouse: on\n"); debug_enable = true; } else { print("\nmouse: off\n"); } break; case KC_V: // print version & information print("\n\t- Version -\n"); print("DESC: " STR(DESCRIPTION) "\n"); print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " "VER: " STR(DEVICE_VER) "\n"); print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n"); /* build options */ print("OPTIONS:" #ifdef PROTOCOL_PJRC " PJRC" #endif #ifdef PROTOCOL_LUFA " LUFA" #endif #ifdef PROTOCOL_VUSB " VUSB" #endif #ifdef PROTOCOL_CHIBIOS " CHIBIOS" #endif #ifdef BOOTMAGIC_ENABLE " BOOTMAGIC" #endif #ifdef MOUSEKEY_ENABLE " MOUSEKEY" #endif #ifdef EXTRAKEY_ENABLE " EXTRAKEY" #endif #ifdef CONSOLE_ENABLE " CONSOLE" #endif #ifdef COMMAND_ENABLE " COMMAND" #endif #ifdef NKRO_ENABLE " NKRO" #endif #ifdef KEYMAP_SECTION_ENABLE " KEYMAP_SECTION" #endif " " STR(BOOTLOADER_SIZE) "\n"); print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) #if defined(__AVR__) " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n"); #elif defined(__arm__) // TODO ); #endif break; case KC_S: print("\n\t- Status -\n"); print_val_hex8(host_keyboard_leds()); print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_idle); #ifdef NKRO_ENABLE print_val_hex8(keyboard_nkro); #endif print_val_hex32(timer_read32()); #ifdef PROTOCOL_PJRC print_val_hex8(UDCON); print_val_hex8(UDIEN); print_val_hex8(UDINT); print_val_hex8(usb_keyboard_leds); print_val_hex8(usb_keyboard_idle_count); #endif #ifdef PROTOCOL_PJRC # if USB_COUNT_SOF print_val_hex8(usbSofCount); # endif #endif break; #ifdef NKRO_ENABLE case KC_N: clear_keyboard(); //Prevents stuck keys. keyboard_nkro = !keyboard_nkro; if (keyboard_nkro) { print("NKRO: on\n"); } else { print("NKRO: off\n"); } break; #endif case KC_ESC: case KC_GRV: case KC_0: case KC_F10: switch_default_layer(0); break; case KC_1 ... KC_9: switch_default_layer((code - KC_1) + 1); break; case KC_F1 ... KC_F9: switch_default_layer((code - KC_F1) + 1); break; default: print("?"); return false; }
void bootmagic(void) { /* check signature */ if (!eeconfig_is_enabled()) { eeconfig_init(); } /* do scans in case of bounce */ print("bootmagic scan: ... "); uint8_t scan = 100; while (scan--) { matrix_scan(); wait_ms(10); } print("done.\n"); /* bootmagic skip */ if (bootmagic_scan_key(BOOTMAGIC_KEY_SKIP)) { return; } /* eeconfig clear */ if (bootmagic_scan_key(BOOTMAGIC_KEY_EEPROM_CLEAR)) { eeconfig_init(); #ifdef KEYMAP_IN_EEPROM_ENABLE write_keymap_to_eeprom(); #endif #ifdef LEDMAP_IN_EEPROM_ENABLE write_ledmap_to_eeprom(); #endif } /* bootloader */ if (bootmagic_scan_key(BOOTMAGIC_KEY_BOOTLOADER)) { bootloader_jump(); } /* user-defined checks */ hook_bootmagic(); /* debug enable */ debug_config.raw = eeconfig_read_debug(); if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_ENABLE)) { if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_MATRIX)) { debug_config.matrix = !debug_config.matrix; } else if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { debug_config.keyboard = !debug_config.keyboard; } else if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_MOUSE)) { debug_config.mouse = !debug_config.mouse; } else { debug_config.enable = !debug_config.enable; } } eeconfig_write_debug(debug_config.raw); /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; } if (bootmagic_scan_key(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { keymap_config.capslock_to_control = !keymap_config.capslock_to_control; } if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; } if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; } if (bootmagic_scan_key(BOOTMAGIC_KEY_NO_GUI)) { keymap_config.no_gui = !keymap_config.no_gui; } if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { keymap_config.swap_grave_esc = !keymap_config.swap_grave_esc; } if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; } if (bootmagic_scan_key(BOOTMAGIC_HOST_NKRO)) { keymap_config.nkro = !keymap_config.nkro; } eeconfig_write_keymap(keymap_config.raw); #ifdef NKRO_ENABLE keyboard_nkro = keymap_config.nkro; #endif /* default layer */ uint8_t default_layer = 0; if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { default_layer |= (1<<1); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { default_layer |= (1<<2); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { default_layer |= (1<<3); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { default_layer |= (1<<4); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { default_layer |= (1<<5); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); } if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } if (default_layer) { eeconfig_write_default_layer(default_layer); default_layer_set((uint32_t)default_layer); } else { default_layer = eeconfig_read_default_layer(); default_layer_set((uint32_t)default_layer); } }
static bool command_common(uint8_t code) { static host_driver_t *host_driver = 0; switch (code) { case KC_CAPSLOCK: if (host_get_driver()) { host_driver = host_get_driver(); host_set_driver(0); print("Locked.\n"); } else { host_set_driver(host_driver); print("Unlocked.\n"); } break; case KC_H: case KC_SLASH: /* ? */ command_common_help(); break; case KC_C: print_enable = true; debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; command_console_help(); print("\nEnter Console Mode\n"); print("C> "); state = CONSOLE; break; case KC_PAUSE: clear_keyboard(); print("\n\nJump to bootloader... "); _delay_ms(1000); bootloader_jump(); // not return print("not supported.\n"); break; case KC_D: if (debug_enable) { print("\nDEBUG: disabled.\n"); debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; } else { print("\nDEBUG: enabled.\n"); debug_enable = true; } break; case KC_X: // debug matrix toggle debug_matrix = !debug_matrix; if (debug_matrix) { print("\nDEBUG: matrix enabled.\n"); debug_enable = true; } else { print("\nDEBUG: matrix disabled.\n"); } break; case KC_K: // debug keyboard toggle debug_keyboard = !debug_keyboard; if (debug_keyboard) { print("\nDEBUG: keyboard enabled.\n"); debug_enable = true; } else { print("\nDEBUG: keyboard disabled.\n"); } break; case KC_M: // debug mouse toggle debug_mouse = !debug_mouse; if (debug_mouse) { print("\nDEBUG: mouse enabled.\n"); debug_enable = true; } else { print("\nDEBUG: mouse disabled.\n"); } break; case KC_V: // print version & information print("\n\n----- Version -----\n"); print(STR(DESCRIPTION) "\n"); print(STR(MANUFACTURER) "(" STR(VENDOR_ID) ")/"); print(STR(PRODUCT) "(" STR(PRODUCT_ID) ") "); print("VERSION: " STR(DEVICE_VER) "\n"); break; case KC_T: // print timer print_val_hex32(timer_count); break; case KC_P: // print toggle if (print_enable) { print("print disabled.\n"); print_enable = false; } else { print_enable = true; print("print enabled.\n"); } break; case KC_S: print("\n\n----- Status -----\n"); print_val_hex8(host_keyboard_leds()); #ifdef HOST_PJRC print_val_hex8(UDCON); print_val_hex8(UDIEN); print_val_hex8(UDINT); print_val_hex8(usb_keyboard_leds); print_val_hex8(usb_keyboard_protocol); print_val_hex8(usb_keyboard_idle_config); print_val_hex8(usb_keyboard_idle_count); #endif #ifdef HOST_VUSB # if USB_COUNT_SOF print_val_hex8(usbSofCount); # endif #endif break; #ifdef NKRO_ENABLE case KC_N: clear_keyboard(); //Prevents stuck keys. keyboard_nkro = !keyboard_nkro; if (keyboard_nkro) print("NKRO: enabled\n"); else print("NKRO: disabled\n"); break; #endif #ifdef EXTRAKEY_ENABLE case KC_PSCREEN: // TODO: Power key should take this feature? otherwise any key during suspend. #ifdef HOST_PJRC if (suspend && remote_wakeup) { usb_remote_wakeup(); } else { host_system_send(SYSTEM_POWER_DOWN); host_system_send(0); _delay_ms(500); } #else host_system_send(SYSTEM_POWER_DOWN); _delay_ms(100); host_system_send(0); _delay_ms(500); #endif break; #endif case KC_0: case KC_F10: switch_layer(0); break; case KC_1: case KC_F1: switch_layer(1); break; case KC_2: case KC_F2: switch_layer(2); break; case KC_3: case KC_F3: switch_layer(3); break; case KC_4: case KC_F4: switch_layer(4); break; case KC_5: case KC_F5: switch_layer(5); break; case KC_6: case KC_F6: switch_layer(6); break; default: print("?"); return false; } 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) 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 keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); #endif // 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 true)) { return false; } // Shift / paren setup switch(keycode) { case RESET: if (record->event.pressed) { clear_keyboard(); #ifdef AUDIO_ENABLE stop_all_notes(); shutdown_user(); #endif wait_ms(250); #ifdef CATERINA_BOOTLOADER *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); return false; } break; case DEBUG: if (record->event.pressed) { print("\nDEBUG: enabled.\n"); debug_enable = true; return false; } break; 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 { 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 { 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); }