mirror of https://github.com/zmkfirmware/zmk.git
fix(studio): Properly return complete keymap from RPC (#2696)
Ensure the set active physical layout RPC returns the full keymap details including the available layers.
This commit is contained in:
parent
b26058b6c7
commit
0820991901
|
|
@ -97,23 +97,28 @@ static bool encode_keymap_layers(pb_ostream_t *stream, const pb_field_t *field,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void populate_keymap_extra_props(zmk_keymap_Keymap *keymap) {
|
||||||
|
keymap->max_layer_name_length = CONFIG_ZMK_KEYMAP_LAYER_NAME_MAX_LEN;
|
||||||
|
|
||||||
|
keymap->available_layers = 0;
|
||||||
|
|
||||||
|
for (zmk_keymap_layer_index_t index = 0; index < ZMK_KEYMAP_LAYERS_LEN; index++) {
|
||||||
|
zmk_keymap_layer_id_t id = zmk_keymap_layer_index_to_id(index);
|
||||||
|
|
||||||
|
if (id == UINT8_MAX) {
|
||||||
|
keymap->available_layers = ZMK_KEYMAP_LAYERS_LEN - index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zmk_studio_Response get_keymap(const zmk_studio_Request *req) {
|
zmk_studio_Response get_keymap(const zmk_studio_Request *req) {
|
||||||
LOG_DBG("");
|
LOG_DBG("");
|
||||||
zmk_keymap_Keymap resp = zmk_keymap_Keymap_init_zero;
|
zmk_keymap_Keymap resp = zmk_keymap_Keymap_init_zero;
|
||||||
|
|
||||||
resp.layers.funcs.encode = encode_keymap_layers;
|
resp.layers.funcs.encode = encode_keymap_layers;
|
||||||
|
|
||||||
resp.max_layer_name_length = CONFIG_ZMK_KEYMAP_LAYER_NAME_MAX_LEN;
|
populate_keymap_extra_props(&resp);
|
||||||
resp.available_layers = 0;
|
|
||||||
|
|
||||||
for (zmk_keymap_layer_index_t index = 0; index < ZMK_KEYMAP_LAYERS_LEN; index++) {
|
|
||||||
zmk_keymap_layer_id_t id = zmk_keymap_layer_index_to_id(index);
|
|
||||||
|
|
||||||
if (id == UINT8_MAX) {
|
|
||||||
resp.available_layers = ZMK_KEYMAP_LAYERS_LEN - index;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return KEYMAP_RESPONSE(get_keymap, resp);
|
return KEYMAP_RESPONSE(get_keymap, resp);
|
||||||
}
|
}
|
||||||
|
|
@ -332,6 +337,7 @@ zmk_studio_Response set_active_physical_layout(const zmk_studio_Request *req) {
|
||||||
zmk_keymap_SetActivePhysicalLayoutResponse_init_zero;
|
zmk_keymap_SetActivePhysicalLayoutResponse_init_zero;
|
||||||
resp.which_result = zmk_keymap_SetActivePhysicalLayoutResponse_ok_tag;
|
resp.which_result = zmk_keymap_SetActivePhysicalLayoutResponse_ok_tag;
|
||||||
resp.result.ok.layers.funcs.encode = encode_keymap_layers;
|
resp.result.ok.layers.funcs.encode = encode_keymap_layers;
|
||||||
|
populate_keymap_extra_props(&resp.result.ok);
|
||||||
|
|
||||||
if (old == index) {
|
if (old == index) {
|
||||||
return KEYMAP_RESPONSE(set_active_physical_layout, resp);
|
return KEYMAP_RESPONSE(set_active_physical_layout, resp);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue