VIA Protocol 12 + fixes (#19916)
Co-authored-by: Wilba <wilba@wilba.tech> Co-authored-by: zvecr <git@zvecr.com>
This commit is contained in:
parent
403b0addea
commit
7f805cc779
135 changed files with 761 additions and 572 deletions
|
@ -721,7 +721,70 @@ enum qk_keycode_defines {
|
|||
QK_AUTOCORRECT_TOGGLE = 0x7C76,
|
||||
QK_TRI_LAYER_LOWER = 0x7C77,
|
||||
QK_TRI_LAYER_UPPER = 0x7C78,
|
||||
SAFE_RANGE = 0x7E00,
|
||||
QK_KB_0 = 0x7E00,
|
||||
QK_KB_1 = 0x7E01,
|
||||
QK_KB_2 = 0x7E02,
|
||||
QK_KB_3 = 0x7E03,
|
||||
QK_KB_4 = 0x7E04,
|
||||
QK_KB_5 = 0x7E05,
|
||||
QK_KB_6 = 0x7E06,
|
||||
QK_KB_7 = 0x7E07,
|
||||
QK_KB_8 = 0x7E08,
|
||||
QK_KB_9 = 0x7E09,
|
||||
QK_KB_10 = 0x7E0A,
|
||||
QK_KB_11 = 0x7E0B,
|
||||
QK_KB_12 = 0x7E0C,
|
||||
QK_KB_13 = 0x7E0D,
|
||||
QK_KB_14 = 0x7E0E,
|
||||
QK_KB_15 = 0x7E0F,
|
||||
QK_KB_16 = 0x7E10,
|
||||
QK_KB_17 = 0x7E11,
|
||||
QK_KB_18 = 0x7E12,
|
||||
QK_KB_19 = 0x7E13,
|
||||
QK_KB_20 = 0x7E14,
|
||||
QK_KB_21 = 0x7E15,
|
||||
QK_KB_22 = 0x7E16,
|
||||
QK_KB_23 = 0x7E17,
|
||||
QK_KB_24 = 0x7E18,
|
||||
QK_KB_25 = 0x7E19,
|
||||
QK_KB_26 = 0x7E1A,
|
||||
QK_KB_27 = 0x7E1B,
|
||||
QK_KB_28 = 0x7E1C,
|
||||
QK_KB_29 = 0x7E1D,
|
||||
QK_KB_30 = 0x7E1E,
|
||||
QK_KB_31 = 0x7E1F,
|
||||
QK_USER_0 = 0x7F00,
|
||||
QK_USER_1 = 0x7F01,
|
||||
QK_USER_2 = 0x7F02,
|
||||
QK_USER_3 = 0x7F03,
|
||||
QK_USER_4 = 0x7F04,
|
||||
QK_USER_5 = 0x7F05,
|
||||
QK_USER_6 = 0x7F06,
|
||||
QK_USER_7 = 0x7F07,
|
||||
QK_USER_8 = 0x7F08,
|
||||
QK_USER_9 = 0x7F09,
|
||||
QK_USER_10 = 0x7F0A,
|
||||
QK_USER_11 = 0x7F0B,
|
||||
QK_USER_12 = 0x7F0C,
|
||||
QK_USER_13 = 0x7F0D,
|
||||
QK_USER_14 = 0x7F0E,
|
||||
QK_USER_15 = 0x7F0F,
|
||||
QK_USER_16 = 0x7F10,
|
||||
QK_USER_17 = 0x7F11,
|
||||
QK_USER_18 = 0x7F12,
|
||||
QK_USER_19 = 0x7F13,
|
||||
QK_USER_20 = 0x7F14,
|
||||
QK_USER_21 = 0x7F15,
|
||||
QK_USER_22 = 0x7F16,
|
||||
QK_USER_23 = 0x7F17,
|
||||
QK_USER_24 = 0x7F18,
|
||||
QK_USER_25 = 0x7F19,
|
||||
QK_USER_26 = 0x7F1A,
|
||||
QK_USER_27 = 0x7F1B,
|
||||
QK_USER_28 = 0x7F1C,
|
||||
QK_USER_29 = 0x7F1D,
|
||||
QK_USER_30 = 0x7F1E,
|
||||
QK_USER_31 = 0x7F1F,
|
||||
|
||||
// Alias
|
||||
XXXXXXX = KC_NO,
|
||||
|
@ -1351,3 +1414,5 @@ enum qk_keycode_defines {
|
|||
#define IS_BACKLIGHT_KEYCODE(code) ((code) >= QK_BACKLIGHT_ON && (code) <= QK_BACKLIGHT_TOGGLE_BREATHING)
|
||||
#define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE)
|
||||
#define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_TRI_LAYER_UPPER)
|
||||
#define IS_KB_KEYCODE(code) ((code) >= QK_KB_0 && (code) <= QK_KB_31)
|
||||
#define IS_USER_KEYCODE(code) ((code) >= QK_USER_0 && (code) <= QK_USER_31)
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#define QK_RSFT 0x1200
|
||||
#define QK_RALT 0x1400
|
||||
#define QK_RGUI 0x1800
|
||||
|
||||
#define SAFE_RANGE QK_KB
|
||||
// clang-format on
|
||||
|
||||
// Generic decoding for the whole QK_MODS range
|
||||
|
|
|
@ -153,38 +153,13 @@ __attribute__((weak)) void via_set_device_indication(uint8_t value) {
|
|||
bool process_record_via(uint16_t keycode, keyrecord_t *record) {
|
||||
// Handle macros
|
||||
if (record->event.pressed) {
|
||||
if (keycode >= MACRO00 && keycode <= MACRO15) {
|
||||
uint8_t id = keycode - MACRO00;
|
||||
if (keycode >= QK_MACRO && keycode <= QK_MACRO_MAX) {
|
||||
uint8_t id = keycode - QK_MACRO;
|
||||
dynamic_keymap_macro_send(id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: ideally this would be generalized and refactored into
|
||||
// QMK core as advanced keycodes, until then, the simple case
|
||||
// can be available here to keyboards using VIA
|
||||
switch (keycode) {
|
||||
case FN_MO13:
|
||||
if (record->event.pressed) {
|
||||
layer_on(1);
|
||||
update_tri_layer(1, 2, 3);
|
||||
} else {
|
||||
layer_off(1);
|
||||
update_tri_layer(1, 2, 3);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case FN_MO23:
|
||||
if (record->event.pressed) {
|
||||
layer_on(2);
|
||||
update_tri_layer(1, 2, 3);
|
||||
} else {
|
||||
layer_off(2);
|
||||
update_tri_layer(1, 2, 3);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -303,25 +278,22 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
|
|||
break;
|
||||
}
|
||||
case id_switch_matrix_state: {
|
||||
// Round up to the nearest number of bytes required to hold row state.
|
||||
// Multiply by number of rows to get the required size in bytes.
|
||||
// Guard against this being too big for the HID message.
|
||||
#if (((MATRIX_COLS + 7) / 8) * MATRIX_ROWS <= 28)
|
||||
uint8_t i = 1;
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
matrix_row_t value = matrix_get_row(row);
|
||||
# if (MATRIX_COLS > 24)
|
||||
uint8_t offset = command_data[1];
|
||||
uint8_t rows = 28 / ((MATRIX_COLS + 7) / 8);
|
||||
uint8_t i = 2;
|
||||
for (uint8_t row = 0; row < rows && row + offset < MATRIX_ROWS; row++) {
|
||||
matrix_row_t value = matrix_get_row(row + offset);
|
||||
#if (MATRIX_COLS > 24)
|
||||
command_data[i++] = (value >> 24) & 0xFF;
|
||||
# endif
|
||||
# if (MATRIX_COLS > 16)
|
||||
#endif
|
||||
#if (MATRIX_COLS > 16)
|
||||
command_data[i++] = (value >> 16) & 0xFF;
|
||||
# endif
|
||||
# if (MATRIX_COLS > 8)
|
||||
#endif
|
||||
#if (MATRIX_COLS > 8)
|
||||
command_data[i++] = (value >> 8) & 0xFF;
|
||||
# endif
|
||||
#endif
|
||||
command_data[i++] = value & 0xFF;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case id_firmware_version: {
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
// This is changed only when the command IDs change,
|
||||
// so VIA Configurator can detect compatible firmware.
|
||||
#define VIA_PROTOCOL_VERSION 0x000B
|
||||
#define VIA_PROTOCOL_VERSION 0x000C
|
||||
|
||||
// This is a version number for the firmware for the keyboard.
|
||||
// It can be used to ensure the VIA keyboard definition and the firmware
|
||||
|
@ -135,46 +135,6 @@ enum via_qmk_audio_value {
|
|||
id_qmk_audio_clicky_enable = 2,
|
||||
};
|
||||
|
||||
enum via_keycodes {
|
||||
FN_MO13 = QK_MACRO,
|
||||
FN_MO23,
|
||||
MACRO00,
|
||||
MACRO01,
|
||||
MACRO02,
|
||||
MACRO03,
|
||||
MACRO04,
|
||||
MACRO05,
|
||||
MACRO06,
|
||||
MACRO07,
|
||||
MACRO08,
|
||||
MACRO09,
|
||||
MACRO10,
|
||||
MACRO11,
|
||||
MACRO12,
|
||||
MACRO13,
|
||||
MACRO14,
|
||||
MACRO15,
|
||||
};
|
||||
|
||||
enum user_keycodes {
|
||||
USER00 = QK_USER,
|
||||
USER01,
|
||||
USER02,
|
||||
USER03,
|
||||
USER04,
|
||||
USER05,
|
||||
USER06,
|
||||
USER07,
|
||||
USER08,
|
||||
USER09,
|
||||
USER10,
|
||||
USER11,
|
||||
USER12,
|
||||
USER13,
|
||||
USER14,
|
||||
USER15,
|
||||
};
|
||||
|
||||
// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
|
||||
// EEPROM is invalid and use/save defaults.
|
||||
bool via_eeprom_is_valid(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue