diff options
-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); |