Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Optimize layout changes by doing runtime mapping #2565

Conversation

petejohanson
Copy link
Contributor

  • To avoid tons of migration, extra flash writes, etc, we keep the keymaps and settings using a key position index that's tied to the stock layout, and at runtime mapping key positions as needed.

@petejohanson petejohanson added enhancement New feature or request studio ZMK Studio (runtime keymaps) labels Oct 17, 2024
@petejohanson petejohanson self-assigned this Oct 17, 2024
@petejohanson petejohanson requested a review from a team as a code owner October 17, 2024 18:26
@petejohanson petejohanson marked this pull request as draft October 17, 2024 18:30
@petejohanson petejohanson force-pushed the core/physical-layout-remapping-integration branch from f728532 to b431edc Compare October 17, 2024 18:39
@petejohanson petejohanson marked this pull request as ready for review October 17, 2024 18:46
app/src/keymap.c Outdated Show resolved Hide resolved
app/src/keymap.c Show resolved Hide resolved
app/include/zmk/physical_layouts.h Outdated Show resolved Hide resolved
@@ -247,12 +257,27 @@ int zmk_keymap_set_layer_binding_at_idx(zmk_keymap_layer_id_t layer_id, uint8_t

ASSERT_LAYER_VAL(layer_id, -EINVAL)

uint32_t *pos_map;
int ret = zmk_physical_layouts_get_selected_to_stock_position_map(&pos_map);
if (ret < 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case isn't currently possible. Will it ever be possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than change the API later, I wanted to ensure we guard now in case things change later with how position maps get created.

@petejohanson petejohanson force-pushed the core/physical-layout-remapping-integration branch 2 times, most recently from 19fe334 to b5e6f31 Compare October 18, 2024 04:38
@petejohanson petejohanson force-pushed the core/physical-layout-remapping-integration branch from b5e6f31 to 5e0b167 Compare October 18, 2024 20:55
* To avoid tons of migration, extra flash writes, etc, we keep
  the keymaps and settings using a key position index that's tied
  to the stock layout, and at runtime mapping key positions as
  needed.
@petejohanson petejohanson force-pushed the core/physical-layout-remapping-integration branch from 5e0b167 to 130276e Compare October 18, 2024 20:58
@petejohanson
Copy link
Contributor Author

Have tested this on a 75% with a split backspace layout, and on my revxlp, no issues. Also had testing on BakenekoGo with two layouts.

@petejohanson petejohanson merged commit ea1a09b into zmkfirmware:main Oct 18, 2024
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request studio ZMK Studio (runtime keymaps)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants