Skip to content

Commit

Permalink
Port changes to other launch boards
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Oct 30, 2020
1 parent 6419d44 commit a04a161
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 171 deletions.
3 changes: 3 additions & 0 deletions keyboards/system76/launch_alpha_1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
84 changes: 0 additions & 84 deletions keyboards/system76/launch_alpha_1/launch_alpha_1.c
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
6 changes: 5 additions & 1 deletion keyboards/system76/launch_alpha_1/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions keyboards/system76/launch_alpha_2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
84 changes: 0 additions & 84 deletions keyboards/system76/launch_alpha_2/launch_alpha_2.c
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
6 changes: 5 additions & 1 deletion keyboards/system76/launch_alpha_2/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion keyboards/system76/launch_beta_1/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.

0 comments on commit a04a161

Please sign in to comment.