Run clang-format manually to fix recently changed files (#7934)
* Run clang-format manually to fix recently changed files * Run clang-format manually to fix recently changed files - revert template files * Run clang-format manually to fix recently changed files - format off for ascii_to_keycode_lut
This commit is contained in:
parent
f5209aa4e9
commit
667045b492
13 changed files with 170 additions and 218 deletions
|
@ -217,7 +217,7 @@ void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||||
|
|
||||||
// If any of the transactions fail we risk writing dirty PG0,
|
// If any of the transactions fail we risk writing dirty PG0,
|
||||||
// refresh page 0 just in case.
|
// refresh page 0 just in case.
|
||||||
if (!IS31FL3733_write_pwm_buffer(addr, g_pwm_buffer[index])){
|
if (!IS31FL3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
|
||||||
g_led_control_registers_update_required[index] = true;
|
g_led_control_registers_update_required[index] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,9 @@ RGB hsv_to_rgb(HSV hsv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RGBW
|
#ifdef RGBW
|
||||||
#ifndef MIN
|
# ifndef MIN
|
||||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
#endif
|
# endif
|
||||||
void convert_rgb_to_rgbw(LED_TYPE *led) {
|
void convert_rgb_to_rgbw(LED_TYPE *led) {
|
||||||
// Determine lowest value in all three colors, put that into
|
// Determine lowest value in all three colors, put that into
|
||||||
// the white channel and then shift all colors by that amount
|
// the white channel and then shift all colors by that amount
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
|
// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
|
||||||
#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
|
#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
|
||||||
# ifdef VIA_EEPROM_CUSTOM_CONFIG_ADDR
|
# ifdef VIA_EEPROM_CUSTOM_CONFIG_ADDR
|
||||||
# define DYNAMIC_KEYMAP_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR+VIA_EEPROM_CUSTOM_CONFIG_SIZE)
|
# define DYNAMIC_KEYMAP_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR + VIA_EEPROM_CUSTOM_CONFIG_SIZE)
|
||||||
# else
|
# else
|
||||||
# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
|
# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
|
||||||
# endif
|
# endif
|
||||||
|
@ -42,14 +42,14 @@
|
||||||
|
|
||||||
// Dynamic macro starts after dynamic keymaps
|
// Dynamic macro starts after dynamic keymaps
|
||||||
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
|
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
|
||||||
# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR+(DYNAMIC_KEYMAP_LAYER_COUNT*MATRIX_ROWS*MATRIX_COLS*2))
|
# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Dynamic macro uses up all remaining memory
|
// Dynamic macro uses up all remaining memory
|
||||||
// Assumes 1K EEPROM on ATMega32U4
|
// Assumes 1K EEPROM on ATMega32U4
|
||||||
// Override for anything different
|
// Override for anything different
|
||||||
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
|
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
|
||||||
# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (1024-DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR)
|
# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (1024 - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
|
uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
|
||||||
|
|
|
@ -38,7 +38,7 @@ static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted,
|
||||||
*
|
*
|
||||||
* noinline to optimise for firmware size not speed (not in hot path)
|
* noinline to optimise for firmware size not speed (not in hot path)
|
||||||
*/
|
*/
|
||||||
static void __attribute__((noinline,unused)) handleKeycodeRGBMode(const uint8_t start, const uint8_t end) {
|
static void __attribute__((noinline, unused)) handleKeycodeRGBMode(const uint8_t start, const uint8_t end) {
|
||||||
if ((start <= rgblight_get_mode()) && (rgblight_get_mode() < end)) {
|
if ((start <= rgblight_get_mode()) && (rgblight_get_mode() < end)) {
|
||||||
rgblight_step();
|
rgblight_step();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -379,6 +379,7 @@ __attribute__((weak)) const bool ascii_to_altgr_lut[128] 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, 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, 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, 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, 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, 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};
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL SOH STX ETX EOT ENQ ACK BEL
|
__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL SOH STX ETX EOT ENQ ACK BEL
|
||||||
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
|
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
|
||||||
// BS TAB LF VT FF CR SO SI
|
// BS TAB LF VT FF CR SO SI
|
||||||
|
@ -412,6 +413,7 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL
|
||||||
KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
|
KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
|
||||||
// x y z { | } ~ DEL
|
// x y z { | } ~ DEL
|
||||||
KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL};
|
KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
void send_string(const char *str) { send_string_with_delay(str, 0); }
|
void send_string(const char *str) { send_string_with_delay(str, 0); }
|
||||||
|
|
||||||
|
|
|
@ -622,11 +622,11 @@ void rgblight_set(void) {
|
||||||
start_led = led + clipping_start_pos;
|
start_led = led + clipping_start_pos;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#ifdef RGBW
|
# ifdef RGBW
|
||||||
for (uint8_t i = 0; i < num_leds; i++) {
|
for (uint8_t i = 0; i < num_leds; i++) {
|
||||||
convert_rgb_to_rgbw(&start_led[i]);
|
convert_rgb_to_rgbw(&start_led[i]);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
ws2812_setleds(start_led, num_leds);
|
ws2812_setleds(start_led, num_leds);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
219
quantum/via.c
219
quantum/via.c
|
@ -32,37 +32,32 @@
|
||||||
|
|
||||||
// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
|
// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
|
||||||
// EEPROM is invalid and use/save defaults.
|
// EEPROM is invalid and use/save defaults.
|
||||||
bool via_eeprom_is_valid(void)
|
bool via_eeprom_is_valid(void) {
|
||||||
{
|
char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
||||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F);
|
||||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F);
|
||||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F);
|
||||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
|
||||||
|
|
||||||
return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 &&
|
return (eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0) == magic0 && eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1) == magic1 && eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2) == magic2);
|
||||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
|
|
||||||
eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets VIA/keyboard level usage of EEPROM to valid/invalid
|
// Sets VIA/keyboard level usage of EEPROM to valid/invalid
|
||||||
// Keyboard level code (eg. via_init_kb()) should not call this
|
// Keyboard level code (eg. via_init_kb()) should not call this
|
||||||
void via_eeprom_set_valid(bool valid)
|
void via_eeprom_set_valid(bool valid) {
|
||||||
{
|
char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
||||||
char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
|
uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F);
|
||||||
uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
|
uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F);
|
||||||
uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
|
uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F);
|
||||||
uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
|
|
||||||
|
|
||||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF);
|
eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0, valid ? magic0 : 0xFF);
|
||||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF);
|
eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1, valid ? magic1 : 0xFF);
|
||||||
eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF);
|
eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2, valid ? magic2 : 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flag QMK and VIA/keyboard level EEPROM as invalid.
|
// Flag QMK and VIA/keyboard level EEPROM as invalid.
|
||||||
// Used in bootmagic_lite() and VIA command handler.
|
// Used in bootmagic_lite() and VIA command handler.
|
||||||
// Keyboard level code should not need to call this.
|
// Keyboard level code should not need to call this.
|
||||||
void via_eeprom_reset(void)
|
void via_eeprom_reset(void) {
|
||||||
{
|
|
||||||
// Set the VIA specific EEPROM state as invalid.
|
// Set the VIA specific EEPROM state as invalid.
|
||||||
via_eeprom_set_valid(false);
|
via_eeprom_set_valid(false);
|
||||||
// Set the TMK/QMK EEPROM state as invalid.
|
// Set the TMK/QMK EEPROM state as invalid.
|
||||||
|
@ -72,8 +67,7 @@ void via_eeprom_reset(void)
|
||||||
// Override bootmagic_lite() so it can flag EEPROM as invalid
|
// Override bootmagic_lite() so it can flag EEPROM as invalid
|
||||||
// as well as jump to bootloader, thus performing a "factory reset"
|
// as well as jump to bootloader, thus performing a "factory reset"
|
||||||
// of dynamic keymaps and optionally backlight/other settings.
|
// of dynamic keymaps and optionally backlight/other settings.
|
||||||
void bootmagic_lite(void)
|
void bootmagic_lite(void) {
|
||||||
{
|
|
||||||
// The lite version of TMK's bootmagic based on Wilba.
|
// The lite version of TMK's bootmagic based on Wilba.
|
||||||
// 100% less potential for accidentally making the
|
// 100% less potential for accidentally making the
|
||||||
// keyboard do stupid things.
|
// keyboard do stupid things.
|
||||||
|
@ -106,12 +100,10 @@ void bootmagic_lite(void)
|
||||||
// for backlight, rotary encoders, etc.
|
// for backlight, rotary encoders, etc.
|
||||||
// The override should not set via_eeprom_set_valid(true) as
|
// The override should not set via_eeprom_set_valid(true) as
|
||||||
// the caller also needs to check the valid state.
|
// the caller also needs to check the valid state.
|
||||||
__attribute__((weak)) void via_init_kb(void) {
|
__attribute__((weak)) void via_init_kb(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
// Called by QMK core to initialize dynamic keymaps etc.
|
// Called by QMK core to initialize dynamic keymaps etc.
|
||||||
void via_init(void)
|
void via_init(void) {
|
||||||
{
|
|
||||||
// Let keyboard level test EEPROM valid state,
|
// Let keyboard level test EEPROM valid state,
|
||||||
// but not set it valid, it is done here.
|
// but not set it valid, it is done here.
|
||||||
via_init_kb();
|
via_init_kb();
|
||||||
|
@ -133,12 +125,11 @@ void via_init(void)
|
||||||
|
|
||||||
// This is generalized so the layout options EEPROM usage can be
|
// This is generalized so the layout options EEPROM usage can be
|
||||||
// variable, between 1 and 4 bytes.
|
// variable, between 1 and 4 bytes.
|
||||||
uint32_t via_get_layout_options(void)
|
uint32_t via_get_layout_options(void) {
|
||||||
{
|
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
// Start at the most significant byte
|
// Start at the most significant byte
|
||||||
void * source = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR);
|
void *source = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR);
|
||||||
for ( uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++ ) {
|
for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) {
|
||||||
value = value << 8;
|
value = value << 8;
|
||||||
value |= eeprom_read_byte(source);
|
value |= eeprom_read_byte(source);
|
||||||
source++;
|
source++;
|
||||||
|
@ -146,24 +137,21 @@ uint32_t via_get_layout_options(void)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void via_set_layout_options(uint32_t value)
|
void via_set_layout_options(uint32_t value) {
|
||||||
{
|
|
||||||
// Start at the least significant byte
|
// Start at the least significant byte
|
||||||
void * target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR+VIA_EEPROM_LAYOUT_OPTIONS_SIZE-1);
|
void *target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE - 1);
|
||||||
for ( uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++ ) {
|
for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) {
|
||||||
eeprom_update_byte(target, value & 0xFF );
|
eeprom_update_byte(target, value & 0xFF);
|
||||||
value = value >> 8;
|
value = value >> 8;
|
||||||
target--;
|
target--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by QMK core to process VIA-specific keycodes.
|
// Called by QMK core to process VIA-specific keycodes.
|
||||||
bool process_record_via(uint16_t keycode, keyrecord_t *record)
|
bool process_record_via(uint16_t keycode, keyrecord_t *record) {
|
||||||
{
|
|
||||||
// Handle macros
|
// Handle macros
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
if ( keycode >= MACRO00 && keycode <= MACRO15 )
|
if (keycode >= MACRO00 && keycode <= MACRO15) {
|
||||||
{
|
|
||||||
uint8_t id = keycode - MACRO00;
|
uint8_t id = keycode - MACRO00;
|
||||||
dynamic_keymap_macro_send(id);
|
dynamic_keymap_macro_send(id);
|
||||||
return false;
|
return false;
|
||||||
|
@ -173,7 +161,7 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record)
|
||||||
// TODO: ideally this would be generalized and refactored into
|
// TODO: ideally this would be generalized and refactored into
|
||||||
// QMK core as advanced keycodes, until then, the simple case
|
// QMK core as advanced keycodes, until then, the simple case
|
||||||
// can be available here to keyboards using VIA
|
// can be available here to keyboards using VIA
|
||||||
switch(keycode) {
|
switch (keycode) {
|
||||||
case FN_MO13:
|
case FN_MO13:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
layer_on(1);
|
layer_on(1);
|
||||||
|
@ -213,180 +201,149 @@ __attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
|
||||||
//
|
//
|
||||||
// raw_hid_send() is called at the end, with the same buffer, which was
|
// raw_hid_send() is called at the end, with the same buffer, which was
|
||||||
// possibly modified with returned values.
|
// possibly modified with returned values.
|
||||||
void raw_hid_receive( uint8_t *data, uint8_t length )
|
void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
{
|
|
||||||
uint8_t *command_id = &(data[0]);
|
uint8_t *command_id = &(data[0]);
|
||||||
uint8_t *command_data = &(data[1]);
|
uint8_t *command_data = &(data[1]);
|
||||||
switch ( *command_id )
|
switch (*command_id) {
|
||||||
{
|
case id_get_protocol_version: {
|
||||||
case id_get_protocol_version:
|
|
||||||
{
|
|
||||||
command_data[0] = VIA_PROTOCOL_VERSION >> 8;
|
command_data[0] = VIA_PROTOCOL_VERSION >> 8;
|
||||||
command_data[1] = VIA_PROTOCOL_VERSION & 0xFF;
|
command_data[1] = VIA_PROTOCOL_VERSION & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_get_keyboard_value:
|
case id_get_keyboard_value: {
|
||||||
{
|
switch (command_data[0]) {
|
||||||
switch ( command_data[0] )
|
case id_uptime: {
|
||||||
{
|
|
||||||
case id_uptime:
|
|
||||||
{
|
|
||||||
uint32_t value = timer_read32();
|
uint32_t value = timer_read32();
|
||||||
command_data[1] = (value >> 24 ) & 0xFF;
|
command_data[1] = (value >> 24) & 0xFF;
|
||||||
command_data[2] = (value >> 16 ) & 0xFF;
|
command_data[2] = (value >> 16) & 0xFF;
|
||||||
command_data[3] = (value >> 8 ) & 0xFF;
|
command_data[3] = (value >> 8) & 0xFF;
|
||||||
command_data[4] = value & 0xFF;
|
command_data[4] = value & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_layout_options:
|
case id_layout_options: {
|
||||||
{
|
|
||||||
uint32_t value = via_get_layout_options();
|
uint32_t value = via_get_layout_options();
|
||||||
command_data[1] = (value >> 24 ) & 0xFF;
|
command_data[1] = (value >> 24) & 0xFF;
|
||||||
command_data[2] = (value >> 16 ) & 0xFF;
|
command_data[2] = (value >> 16) & 0xFF;
|
||||||
command_data[3] = (value >> 8 ) & 0xFF;
|
command_data[3] = (value >> 8) & 0xFF;
|
||||||
command_data[4] = value & 0xFF;
|
command_data[4] = value & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_switch_matrix_state:
|
case id_switch_matrix_state: {
|
||||||
{
|
#if ((MATRIX_COLS / 8 + 1) * MATRIX_ROWS <= 28)
|
||||||
#if ( (MATRIX_COLS/8+1)*MATRIX_ROWS <= 28 )
|
|
||||||
uint8_t i = 1;
|
uint8_t i = 1;
|
||||||
for ( uint8_t row=0; row<MATRIX_ROWS; row++ ) {
|
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||||
matrix_row_t value = matrix_get_row(row);
|
matrix_row_t value = matrix_get_row(row);
|
||||||
#if (MATRIX_COLS > 24)
|
# if (MATRIX_COLS > 24)
|
||||||
command_data[i++] = (value >> 24 ) & 0xFF;
|
command_data[i++] = (value >> 24) & 0xFF;
|
||||||
#endif
|
# endif
|
||||||
#if (MATRIX_COLS > 16)
|
# if (MATRIX_COLS > 16)
|
||||||
command_data[i++] = (value >> 16 ) & 0xFF;
|
command_data[i++] = (value >> 16) & 0xFF;
|
||||||
#endif
|
# endif
|
||||||
#if (MATRIX_COLS > 8)
|
# if (MATRIX_COLS > 8)
|
||||||
command_data[i++] = (value >> 8 ) & 0xFF;
|
command_data[i++] = (value >> 8) & 0xFF;
|
||||||
#endif
|
# endif
|
||||||
command_data[i++] = value & 0xFF;
|
command_data[i++] = value & 0xFF;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
raw_hid_receive_kb(data, length);
|
||||||
raw_hid_receive_kb(data,length);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_set_keyboard_value:
|
case id_set_keyboard_value: {
|
||||||
{
|
switch (command_data[0]) {
|
||||||
switch ( command_data[0] )
|
case id_layout_options: {
|
||||||
{
|
uint32_t value = ((uint32_t)command_data[1] << 24) | ((uint32_t)command_data[2] << 16) | ((uint32_t)command_data[3] << 8) | (uint32_t)command_data[4];
|
||||||
case id_layout_options:
|
|
||||||
{
|
|
||||||
uint32_t value = ( (uint32_t)command_data[1] << 24 ) |
|
|
||||||
( (uint32_t)command_data[2] << 16 ) |
|
|
||||||
( (uint32_t)command_data[3] << 8 ) |
|
|
||||||
(uint32_t)command_data[4];
|
|
||||||
via_set_layout_options(value);
|
via_set_layout_options(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
raw_hid_receive_kb(data, length);
|
||||||
raw_hid_receive_kb(data,length);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_get_keycode:
|
case id_dynamic_keymap_get_keycode: {
|
||||||
{
|
uint16_t keycode = dynamic_keymap_get_keycode(command_data[0], command_data[1], command_data[2]);
|
||||||
uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
|
|
||||||
command_data[3] = keycode >> 8;
|
command_data[3] = keycode >> 8;
|
||||||
command_data[4] = keycode & 0xFF;
|
command_data[4] = keycode & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_set_keycode:
|
case id_dynamic_keymap_set_keycode: {
|
||||||
{
|
dynamic_keymap_set_keycode(command_data[0], command_data[1], command_data[2], (command_data[3] << 8) | command_data[4]);
|
||||||
dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_reset:
|
case id_dynamic_keymap_reset: {
|
||||||
{
|
|
||||||
dynamic_keymap_reset();
|
dynamic_keymap_reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_backlight_config_set_value:
|
case id_backlight_config_set_value:
|
||||||
case id_backlight_config_get_value:
|
case id_backlight_config_get_value:
|
||||||
case id_backlight_config_save:
|
case id_backlight_config_save: {
|
||||||
{
|
|
||||||
raw_hid_receive_kb(data, length);
|
raw_hid_receive_kb(data, length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_macro_get_count:
|
case id_dynamic_keymap_macro_get_count: {
|
||||||
{
|
|
||||||
command_data[0] = dynamic_keymap_macro_get_count();
|
command_data[0] = dynamic_keymap_macro_get_count();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_macro_get_buffer_size:
|
case id_dynamic_keymap_macro_get_buffer_size: {
|
||||||
{
|
|
||||||
uint16_t size = dynamic_keymap_macro_get_buffer_size();
|
uint16_t size = dynamic_keymap_macro_get_buffer_size();
|
||||||
command_data[0] = size >> 8;
|
command_data[0] = size >> 8;
|
||||||
command_data[1] = size & 0xFF;
|
command_data[1] = size & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_macro_get_buffer:
|
case id_dynamic_keymap_macro_get_buffer: {
|
||||||
{
|
uint16_t offset = (command_data[0] << 8) | command_data[1];
|
||||||
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
|
|
||||||
uint16_t size = command_data[2]; // size <= 28
|
uint16_t size = command_data[2]; // size <= 28
|
||||||
dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] );
|
dynamic_keymap_macro_get_buffer(offset, size, &command_data[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_macro_set_buffer:
|
case id_dynamic_keymap_macro_set_buffer: {
|
||||||
{
|
uint16_t offset = (command_data[0] << 8) | command_data[1];
|
||||||
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
|
|
||||||
uint16_t size = command_data[2]; // size <= 28
|
uint16_t size = command_data[2]; // size <= 28
|
||||||
dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] );
|
dynamic_keymap_macro_set_buffer(offset, size, &command_data[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_macro_reset:
|
case id_dynamic_keymap_macro_reset: {
|
||||||
{
|
|
||||||
dynamic_keymap_macro_reset();
|
dynamic_keymap_macro_reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_get_layer_count:
|
case id_dynamic_keymap_get_layer_count: {
|
||||||
{
|
|
||||||
command_data[0] = dynamic_keymap_get_layer_count();
|
command_data[0] = dynamic_keymap_get_layer_count();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_get_buffer:
|
case id_dynamic_keymap_get_buffer: {
|
||||||
{
|
uint16_t offset = (command_data[0] << 8) | command_data[1];
|
||||||
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
|
|
||||||
uint16_t size = command_data[2]; // size <= 28
|
uint16_t size = command_data[2]; // size <= 28
|
||||||
dynamic_keymap_get_buffer( offset, size, &command_data[3] );
|
dynamic_keymap_get_buffer(offset, size, &command_data[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_dynamic_keymap_set_buffer:
|
case id_dynamic_keymap_set_buffer: {
|
||||||
{
|
uint16_t offset = (command_data[0] << 8) | command_data[1];
|
||||||
uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
|
|
||||||
uint16_t size = command_data[2]; // size <= 28
|
uint16_t size = command_data[2]; // size <= 28
|
||||||
dynamic_keymap_set_buffer( offset, size, &command_data[3] );
|
dynamic_keymap_set_buffer(offset, size, &command_data[3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_eeprom_reset:
|
case id_eeprom_reset: {
|
||||||
{
|
|
||||||
via_eeprom_reset();
|
via_eeprom_reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_bootloader_jump:
|
case id_bootloader_jump: {
|
||||||
{
|
|
||||||
// Need to send data back before the jump
|
// Need to send data back before the jump
|
||||||
// Informs host that the command is handled
|
// Informs host that the command is handled
|
||||||
raw_hid_send( data, length );
|
raw_hid_send(data, length);
|
||||||
// Give host time to read it
|
// Give host time to read it
|
||||||
wait_ms(100);
|
wait_ms(100);
|
||||||
bootloader_jump();
|
bootloader_jump();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
// The command ID is not known
|
// The command ID is not known
|
||||||
// Return the unhandled state
|
// Return the unhandled state
|
||||||
*command_id = id_unhandled;
|
*command_id = id_unhandled;
|
||||||
|
@ -396,5 +353,5 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
|
||||||
|
|
||||||
// Return the same buffer, optionally with values changed
|
// Return the same buffer, optionally with values changed
|
||||||
// (i.e. returning state to the host, or the unhandled state).
|
// (i.e. returning state to the host, or the unhandled state).
|
||||||
raw_hid_send( data, length );
|
raw_hid_send(data, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
# define VIA_EEPROM_MAGIC_ADDR (EECONFIG_SIZE)
|
# define VIA_EEPROM_MAGIC_ADDR (EECONFIG_SIZE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VIA_EEPROM_LAYOUT_OPTIONS_ADDR (VIA_EEPROM_MAGIC_ADDR+3)
|
#define VIA_EEPROM_LAYOUT_OPTIONS_ADDR (VIA_EEPROM_MAGIC_ADDR + 3)
|
||||||
|
|
||||||
// Changing the layout options size after release will invalidate EEPROM,
|
// Changing the layout options size after release will invalidate EEPROM,
|
||||||
// but this is something that should be set correctly on initial implementation.
|
// but this is something that should be set correctly on initial implementation.
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
// The end of the EEPROM memory used by VIA
|
// The end of the EEPROM memory used by VIA
|
||||||
// By default, dynamic keymaps will start at this if there is no
|
// By default, dynamic keymaps will start at this if there is no
|
||||||
// custom config
|
// custom config
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_ADDR (VIA_EEPROM_LAYOUT_OPTIONS_ADDR+VIA_EEPROM_LAYOUT_OPTIONS_SIZE)
|
#define VIA_EEPROM_CUSTOM_CONFIG_ADDR (VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE)
|
||||||
|
|
||||||
#ifndef VIA_EEPROM_CUSTOM_CONFIG_SIZE
|
#ifndef VIA_EEPROM_CUSTOM_CONFIG_SIZE
|
||||||
# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 0
|
# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 0
|
||||||
|
@ -50,8 +50,7 @@
|
||||||
// so VIA Configurator can detect compatible firmware.
|
// so VIA Configurator can detect compatible firmware.
|
||||||
#define VIA_PROTOCOL_VERSION 0x0009
|
#define VIA_PROTOCOL_VERSION 0x0009
|
||||||
|
|
||||||
enum via_command_id
|
enum via_command_id {
|
||||||
{
|
|
||||||
id_get_protocol_version = 0x01, // always 0x01
|
id_get_protocol_version = 0x01, // always 0x01
|
||||||
id_get_keyboard_value,
|
id_get_keyboard_value,
|
||||||
id_set_keyboard_value,
|
id_set_keyboard_value,
|
||||||
|
@ -74,12 +73,7 @@ enum via_command_id
|
||||||
id_unhandled = 0xFF,
|
id_unhandled = 0xFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum via_keyboard_value_id
|
enum via_keyboard_value_id { id_uptime = 0x01, id_layout_options, id_switch_matrix_state };
|
||||||
{
|
|
||||||
id_uptime = 0x01,
|
|
||||||
id_layout_options,
|
|
||||||
id_switch_matrix_state
|
|
||||||
};
|
|
||||||
|
|
||||||
// Can't use SAFE_RANGE here, it might change if someone adds
|
// Can't use SAFE_RANGE here, it might change if someone adds
|
||||||
// new values to enum quantum_keycodes.
|
// new values to enum quantum_keycodes.
|
||||||
|
@ -148,4 +142,3 @@ void via_set_layout_options(uint32_t value);
|
||||||
|
|
||||||
// Called by QMK core to process VIA-specific keycodes.
|
// Called by QMK core to process VIA-specific keycodes.
|
||||||
bool process_record_via(uint16_t keycode, keyrecord_t *record);
|
bool process_record_via(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ int retro_tapping_counter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
||||||
__attribute__ ((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode) { return false; }
|
__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode) { return false; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TAP_CODE_DELAY
|
#ifndef TAP_CODE_DELAY
|
||||||
|
|
Loading…
Reference in a new issue