Skip to content

Commit

Permalink
VIA Encoder Map Support (#17734)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilba authored Jul 20, 2022
1 parent 493d422 commit 4efe633
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions quantum/via.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,18 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
dynamic_keymap_set_buffer(offset, size, &command_data[3]);
break;
}
#ifdef ENCODER_MAP_ENABLE
case id_dynamic_keymap_get_encoder: {
uint16_t keycode = dynamic_keymap_get_encoder(command_data[0], command_data[1], command_data[2] != 0);
command_data[3] = keycode >> 8;
command_data[4] = keycode & 0xFF;
break;
}
case id_dynamic_keymap_set_encoder: {
dynamic_keymap_set_encoder(command_data[0], command_data[1], command_data[2] != 0, (command_data[3] << 8) | command_data[4]);
break;
}
#endif
default: {
// The command ID is not known
// Return the unhandled state
Expand Down
4 changes: 3 additions & 1 deletion quantum/via.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

// This is changed only when the command IDs change,
// so VIA Configurator can detect compatible firmware.
#define VIA_PROTOCOL_VERSION 0x0009
#define VIA_PROTOCOL_VERSION 0x000A

enum via_command_id {
id_get_protocol_version = 0x01, // always 0x01
Expand All @@ -80,6 +80,8 @@ enum via_command_id {
id_dynamic_keymap_get_layer_count = 0x11,
id_dynamic_keymap_get_buffer = 0x12,
id_dynamic_keymap_set_buffer = 0x13,
id_dynamic_keymap_get_encoder = 0x14,
id_dynamic_keymap_set_encoder = 0x15,
id_unhandled = 0xFF,
};

Expand Down

0 comments on commit 4efe633

Please sign in to comment.