diff options
author | Peter Johanson <[email protected]> | 2024-11-01 11:12:32 -0600 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2024-11-04 13:30:40 -0700 |
commit | 19a096ab675c9c738b0cd0c1afdc9cc9b4e32a42 (patch) | |
tree | 2498bcebadc7b5181f5d43459dd39010eda6a7de | |
parent | f08b817d604f0e4b6e8abcfb4926f74abdb23d24 (diff) | |
download | zmk-19a096ab675c9c738b0cd0c1afdc9cc9b4e32a42.tar.gz zmk-19a096ab675c9c738b0cd0c1afdc9cc9b4e32a42.zip |
fix(keymap): Set bindings with changed layout
* Fix bug with setting keymap layer bindings when a non-stock layout
is selected.
-rw-r--r-- | app/src/keymap.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/src/keymap.c b/app/src/keymap.c index cb9529cd39..16b24bf274 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -294,7 +294,7 @@ int zmk_keymap_set_layer_binding_at_idx(zmk_keymap_layer_id_t layer_id, uint8_t uint8_t *pending = zmk_keymap_layer_pending_changes[layer_id]; - WRITE_BIT(pending[binding_idx / 8], binding_idx % 8, 1); + WRITE_BIT(pending[storage_binding_idx / 8], storage_binding_idx % 8, 1); // TODO: Need a mutex to protect access to the keymap data? memcpy(&zmk_keymap[layer_id][storage_binding_idx], &binding, sizeof(binding)); @@ -483,10 +483,11 @@ static int save_bindings(void) { for (int kp = 0; kp < ZMK_KEYMAP_LEN; kp++) { if (pending[kp / 8] & BIT(kp % 8)) { - LOG_DBG("Pending save for layer %d at key position %d", l, kp); - const struct zmk_behavior_binding *binding = - zmk_keymap_get_layer_binding_at_idx(l, kp); + const struct zmk_behavior_binding *binding = &zmk_keymap[l][kp]; + LOG_DBG("Pending save for layer %d at key position %d: %s with %d, %d", l, kp, + binding->behavior_dev, binding->param1, binding->param2); + struct zmk_behavior_binding_setting binding_setting = { .behavior_local_id = zmk_behavior_get_local_id(binding->behavior_dev), .param1 = binding->param1, @@ -512,10 +513,10 @@ static int save_bindings(void) { LOG_ERR("Failed to save keymap binding at %d on layer %d (%d)", l, kp, ret); return ret; } + + WRITE_BIT(pending[kp / 8], kp % 8, 0); } } - - *pending = 0; } return 0; |