Last active
January 13, 2023 04:58
-
-
Save drashna/bbd6819ff475cda40f06886af2a48d3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"menus": [ | |
{ | |
"label": "Layer", | |
"content": [ | |
{ | |
"label": "Layer", | |
"content": [ | |
{ | |
"label": "Layer", | |
"type": "range", | |
"options": [0, 8], | |
"content": ["id_wl_layer", 0, 1] | |
} | |
] | |
} | |
] | |
} | |
], | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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