From a04a16160aa1cc0b6e99372cc2fb914a0475a702 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 30 Oct 2020 09:35:16 -0600 Subject: [PATCH] Port changes to other launch boards --- keyboards/system76/launch_alpha_1/config.h | 3 + .../system76/launch_alpha_1/launch_alpha_1.c | 84 ------------------- keyboards/system76/launch_alpha_1/rules.mk | 6 +- keyboards/system76/launch_alpha_2/config.h | 3 + .../system76/launch_alpha_2/launch_alpha_2.c | 84 ------------------- keyboards/system76/launch_alpha_2/rules.mk | 6 +- keyboards/system76/launch_beta_1/rules.mk | 2 +- .../{launch_beta_1 => }/system76_ec.c | 0 8 files changed, 17 insertions(+), 171 deletions(-) rename keyboards/system76/{launch_beta_1 => }/system76_ec.c (100%) diff --git a/keyboards/system76/launch_alpha_1/config.h b/keyboards/system76/launch_alpha_1/config.h index 7271bd2a58e..9b62c19a093 100644 --- a/keyboards/system76/launch_alpha_1/config.h +++ b/keyboards/system76/launch_alpha_1/config.h @@ -26,6 +26,9 @@ /* Set 0 if debouncing isn't needed */ #define DEBOUNCE 5 +// NKRO must be used +#define FORCE_NKRO + /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/system76/launch_alpha_1/launch_alpha_1.c b/keyboards/system76/launch_alpha_1/launch_alpha_1.c index 0d464a24eaf..2f55f3772eb 100644 --- a/keyboards/system76/launch_alpha_1/launch_alpha_1.c +++ b/keyboards/system76/launch_alpha_1/launch_alpha_1.c @@ -1,92 +1,8 @@ #include "dynamic_keymap.h" -#include "raw_hid.h" #include "tmk_core/common/eeprom.h" -#include "version.h" #include "launch_alpha_1.h" -enum Command { - // Probe for System76 EC protocol - CMD_PROBE = 1, - // Read board string - CMD_BOARD = 2, - // Read version string - CMD_VERSION = 3, - // Get keyboard map index - CMD_KEYMAP_GET = 9, - // Set keyboard map index - CMD_KEYMAP_SET = 10, -}; - -static bool keymap_get(uint8_t layer, uint8_t output, uint8_t input, uint16_t *value) { - if (layer < dynamic_keymap_get_layer_count()) { - if (output < MATRIX_ROWS) { - if (input < MATRIX_COLS) { - *value = dynamic_keymap_get_keycode(layer, output, input); - return true; - } - } - } - return false; -} - -static bool keymap_set(uint8_t layer, uint8_t output, uint8_t input, uint16_t value) { - if (layer < dynamic_keymap_get_layer_count()) { - if (output < MATRIX_ROWS) { - if (input < MATRIX_COLS) { - dynamic_keymap_set_keycode(layer, output, input, value); - return true; - } - } - } - return false; -} - -void raw_hid_receive(uint8_t *data, uint8_t length) { - // Error response by default, set to success by commands - 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_BOARD: - strncpy((char *)&data[2], QMK_KEYBOARD, length - 2); - data[1] = 0; - break; - case CMD_VERSION: - strncpy((char *)&data[2], QMK_VERSION, length - 2); - data[1] = 0; - break; - case CMD_KEYMAP_GET: - { - uint16_t value = 0; - if (keymap_get(data[2], data[3], data[4], &value)) { - data[5] = (uint8_t)value; - data[6] = (uint8_t)(value >> 8); - data[1] = 0; - } - } - break; - case CMD_KEYMAP_SET: - { - uint16_t value = - ((uint16_t)data[5]) | - (((uint16_t)data[6]) << 8); - if (keymap_set(data[2], data[3], data[4], value)) { - data[1] = 0; - } - } - } - - raw_hid_send(data, length); -} - bool eeprom_is_valid(void) { return (eeprom_read_word(((void*)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC && eeprom_read_byte(((void*)EEPROM_VERSION_ADDR)) == EEPROM_VERSION); diff --git a/keyboards/system76/launch_alpha_1/rules.mk b/keyboards/system76/launch_alpha_1/rules.mk index 268f8279272..c2229278477 100644 --- a/keyboards/system76/launch_alpha_1/rules.mk +++ b/keyboards/system76/launch_alpha_1/rules.mk @@ -16,9 +16,13 @@ BOOTLOADER = caterina # BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = no # Console for debug(+400) COMMAND_ENABLE = no # Commands for debug and configuration DYNAMIC_KEYMAP_ENABLE = yes # Reconfigurable keyboard without flashing firmware NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work RAW_ENABLE = yes # Enable RAW HID commands (used by keyboard configurator) +USB_6KRO_ENABLE = no # 6key Rollover + +# Add System76 EC command interface +SRC+=../system76_ec.c diff --git a/keyboards/system76/launch_alpha_2/config.h b/keyboards/system76/launch_alpha_2/config.h index 92a0b0aac70..63177dd6af3 100644 --- a/keyboards/system76/launch_alpha_2/config.h +++ b/keyboards/system76/launch_alpha_2/config.h @@ -26,6 +26,9 @@ /* Set 0 if debouncing isn't needed */ #define DEBOUNCE 5 +// NKRO must be used +#define FORCE_NKRO + /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboards/system76/launch_alpha_2/launch_alpha_2.c b/keyboards/system76/launch_alpha_2/launch_alpha_2.c index a134ac94e6d..84d851fc48f 100644 --- a/keyboards/system76/launch_alpha_2/launch_alpha_2.c +++ b/keyboards/system76/launch_alpha_2/launch_alpha_2.c @@ -1,92 +1,8 @@ #include "dynamic_keymap.h" -#include "raw_hid.h" #include "tmk_core/common/eeprom.h" -#include "version.h" #include "launch_alpha_2.h" -enum Command { - // Probe for System76 EC protocol - CMD_PROBE = 1, - // Read board string - CMD_BOARD = 2, - // Read version string - CMD_VERSION = 3, - // Get keyboard map index - CMD_KEYMAP_GET = 9, - // Set keyboard map index - CMD_KEYMAP_SET = 10, -}; - -static bool keymap_get(uint8_t layer, uint8_t output, uint8_t input, uint16_t *value) { - if (layer < dynamic_keymap_get_layer_count()) { - if (output < MATRIX_ROWS) { - if (input < MATRIX_COLS) { - *value = dynamic_keymap_get_keycode(layer, output, input); - return true; - } - } - } - return false; -} - -static bool keymap_set(uint8_t layer, uint8_t output, uint8_t input, uint16_t value) { - if (layer < dynamic_keymap_get_layer_count()) { - if (output < MATRIX_ROWS) { - if (input < MATRIX_COLS) { - dynamic_keymap_set_keycode(layer, output, input, value); - return true; - } - } - } - return false; -} - -void raw_hid_receive(uint8_t *data, uint8_t length) { - // Error response by default, set to success by commands - 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_BOARD: - strncpy((char *)&data[2], QMK_KEYBOARD, length - 2); - data[1] = 0; - break; - case CMD_VERSION: - strncpy((char *)&data[2], QMK_VERSION, length - 2); - data[1] = 0; - break; - case CMD_KEYMAP_GET: - { - uint16_t value = 0; - if (keymap_get(data[2], data[3], data[4], &value)) { - data[5] = (uint8_t)value; - data[6] = (uint8_t)(value >> 8); - data[1] = 0; - } - } - break; - case CMD_KEYMAP_SET: - { - uint16_t value = - ((uint16_t)data[5]) | - (((uint16_t)data[6]) << 8); - if (keymap_set(data[2], data[3], data[4], value)) { - data[1] = 0; - } - } - } - - raw_hid_send(data, length); -} - bool eeprom_is_valid(void) { return (eeprom_read_word(((void*)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC && eeprom_read_byte(((void*)EEPROM_VERSION_ADDR)) == EEPROM_VERSION); diff --git a/keyboards/system76/launch_alpha_2/rules.mk b/keyboards/system76/launch_alpha_2/rules.mk index 268f8279272..c2229278477 100644 --- a/keyboards/system76/launch_alpha_2/rules.mk +++ b/keyboards/system76/launch_alpha_2/rules.mk @@ -16,9 +16,13 @@ BOOTLOADER = caterina # BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = no # Console for debug(+400) COMMAND_ENABLE = no # Commands for debug and configuration DYNAMIC_KEYMAP_ENABLE = yes # Reconfigurable keyboard without flashing firmware NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work RAW_ENABLE = yes # Enable RAW HID commands (used by keyboard configurator) +USB_6KRO_ENABLE = no # 6key Rollover + +# Add System76 EC command interface +SRC+=../system76_ec.c diff --git a/keyboards/system76/launch_beta_1/rules.mk b/keyboards/system76/launch_beta_1/rules.mk index aeac87eee06..bc8d6fe734a 100644 --- a/keyboards/system76/launch_beta_1/rules.mk +++ b/keyboards/system76/launch_beta_1/rules.mk @@ -33,7 +33,7 @@ RGB_MATRIX_ENABLE = WS2812 # Support for RGB matrix USB_6KRO_ENABLE = no # 6key Rollover # Add System76 EC command interface -SRC+=system76_ec.c +SRC+=../system76_ec.c # Add I2C driver SRC+=i2c.c diff --git a/keyboards/system76/launch_beta_1/system76_ec.c b/keyboards/system76/system76_ec.c similarity index 100% rename from keyboards/system76/launch_beta_1/system76_ec.c rename to keyboards/system76/system76_ec.c