diff --git a/keyboards/system76/launch_1/launch_1.c b/keyboards/system76/launch_1/launch_1.c index c0383dfb6f8..03af2032d11 100644 --- a/keyboards/system76/launch_1/launch_1.c +++ b/keyboards/system76/launch_1/launch_1.c @@ -5,6 +5,8 @@ #include "launch_1.h" enum Command { + // Probe for System76 EC protocol + CMD_PROBE = 1, // Get keyboard map index CMD_KEYMAP_GET = 9, // Set keyboard map index @@ -40,6 +42,14 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { data[1] = 1; switch (data[0]) { + case CMD_PROBE: + // Signature + data[2] = 0x76; + data[3] = 0xEC; + // Version + data[4] = 0x01; + data[1] = 0; + break; case CMD_KEYMAP_GET: { uint16_t value = 0; diff --git a/keyboards/system76/launch_test/launch_test.c b/keyboards/system76/launch_test/launch_test.c index 402d70677c9..4a6d429ed16 100644 --- a/keyboards/system76/launch_test/launch_test.c +++ b/keyboards/system76/launch_test/launch_test.c @@ -5,6 +5,8 @@ #include "launch_test.h" enum Command { + // Probe for System76 EC protocol + CMD_PROBE = 1, // Get keyboard map index CMD_KEYMAP_GET = 9, // Set keyboard map index @@ -40,6 +42,14 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { data[1] = 1; switch (data[0]) { + case CMD_PROBE: + // Signature + data[2] = 0x76; + data[3] = 0xEC; + // Version + data[4] = 0x01; + data[1] = 0; + break; case CMD_KEYMAP_GET: { uint16_t value = 0; @@ -74,7 +84,34 @@ void eeprom_set_valid(bool valid) { eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF); } +void eeprom_reset(void) { + // Set the keyboard specific EEPROM state as invalid. + eeprom_set_valid(false); + // Set the TMK/QMK EEPROM state as invalid. + eeconfig_disable(); +} + +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(DEBOUNCE); + wait_ms(DEBOUNCE); + matrix_scan(); + + // If the Esc (matrix 0,0) is held down on power up, + // reset the EEPROM valid state and jump to bootloader. + if ( matrix_get_row(0) & (1<<0) ) { + eeprom_reset(); + bootloader_jump(); + } +} + void matrix_init_kb(void) { + bootmagic_lite(); if (!eeprom_is_valid()) { dynamic_keymap_reset(); dynamic_keymap_macro_reset();