fix: Optimize layout changes by doing runtime mapping

* 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.
This commit is contained in:
Peter Johanson
2024-10-17 12:24:43 -06:00
committed by Pete Johanson
parent a6d09f8c00
commit ea1a09bf99
4 changed files with 115 additions and 57 deletions

View File

@@ -49,3 +49,12 @@ int zmk_physical_layouts_revert_selected(void);
int zmk_physical_layouts_get_position_map(uint8_t source, uint8_t dest, size_t map_size,
uint32_t map[map_size]);
/**
* @brief Get a pointer to a position map array for mapping a key position in the selected
* physical layout to the stock/chosen physical layout
*
* @retval a negative errno value in the case of errors
* @retval a positive length of the position map array that map is updated to point to.
*/
int zmk_physical_layouts_get_selected_to_stock_position_map(uint32_t const **map);