diff options
author | Pete Johanson <[email protected]> | 2024-12-06 16:10:58 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-06 18:10:58 -0500 |
commit | 0820991901a95ab7a0eb1f1cc608a631d514e26c (patch) | |
tree | 0dffc512235dd46183da455c096a05c94f7d481a | |
parent | b26058b6c7c83f8d1f095d2f9c6c3998b391a61b (diff) | |
download | zmk-0820991901a95ab7a0eb1f1cc608a631d514e26c.tar.gz zmk-0820991901a95ab7a0eb1f1cc608a631d514e26c.zip |
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.
-rw-r--r-- | app/src/studio/keymap_subsystem.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/src/studio/keymap_subsystem.c b/app/src/studio/keymap_subsystem.c index 4d659def98..3516a3fb9f 100644 --- a/app/src/studio/keymap_subsystem.c +++ b/app/src/studio/keymap_subsystem.c @@ -97,23 +97,28 @@ static bool encode_keymap_layers(pb_ostream_t *stream, const pb_field_t *field, return true; } -zmk_studio_Response get_keymap(const zmk_studio_Request *req) { - LOG_DBG(""); - zmk_keymap_Keymap resp = zmk_keymap_Keymap_init_zero; +static void populate_keymap_extra_props(zmk_keymap_Keymap *keymap) { + keymap->max_layer_name_length = CONFIG_ZMK_KEYMAP_LAYER_NAME_MAX_LEN; - resp.layers.funcs.encode = encode_keymap_layers; - - resp.max_layer_name_length = CONFIG_ZMK_KEYMAP_LAYER_NAME_MAX_LEN; - resp.available_layers = 0; + 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) { - resp.available_layers = ZMK_KEYMAP_LAYERS_LEN - index; + keymap->available_layers = ZMK_KEYMAP_LAYERS_LEN - index; break; } } +} + +zmk_studio_Response get_keymap(const zmk_studio_Request *req) { + LOG_DBG(""); + zmk_keymap_Keymap resp = zmk_keymap_Keymap_init_zero; + + resp.layers.funcs.encode = encode_keymap_layers; + + populate_keymap_extra_props(&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; resp.which_result = zmk_keymap_SetActivePhysicalLayoutResponse_ok_tag; resp.result.ok.layers.funcs.encode = encode_keymap_layers; + populate_keymap_extra_props(&resp.result.ok); if (old == index) { return KEYMAP_RESPONSE(set_active_physical_layout, resp); |