Skip to content

Instantly share code, notes, and snippets.

@drashna
Last active January 13, 2023 04:58
Show Gist options
  • Save drashna/bbd6819ff475cda40f06886af2a48d3c to your computer and use it in GitHub Desktop.
Save drashna/bbd6819ff475cda40f06886af2a48d3c to your computer and use it in GitHub Desktop.
{
"menus": [
{
"label": "Layer",
"content": [
{
"label": "Layer",
"content": [
{
"label": "Layer",
"type": "range",
"options": [0, 8],
"content": ["id_wl_layer", 0, 1]
}
]
}
]
}
],
...
enum via_indicator_value {
id_wl_layer = 1,
};
void wl_config_set_value(uint8_t *data) {
// data = [ value_id, value_data ]
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_wl_layer:
default_layer_set(1UL<<*value_data);
break;
}
}
void wl_config_get_value(uint8_t *data) {
// data = [ value_id, value_data ]
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_wl_layer:
*value_data = get_highest_layer(default_layer_state);
break;
}
}
void wl_config_save(void) {
eeconfig_update_default_layer(default_layer_state);
}
void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
uint8_t *command_id = &(data[0]);
uint8_t *channel_id = &(data[1]);
uint8_t *value_id_and_data = &(data[2]);
if (*channel_id == id_custom_channel) {
switch (*command_id) {
case id_custom_set_value: {
wl_config_set_value(value_id_and_data);
break;
}
case id_custom_get_value: {
wl_config_get_value(value_id_and_data);
break;
}
case id_custom_save: {
wl_config_save();
break;
}
default: {
// Unhandled message.
*command_id = id_unhandled;
break;
}
}
return;
}
*command_id = id_unhandled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment