feat: Split physical layout selection sync.

* Ensure the split peripherals have the same selected physical
  layout on connection and change.
This commit is contained in:
Peter Johanson
2024-07-31 11:54:15 -06:00
committed by Pete Johanson
parent f992352936
commit 33e3b02ddb
5 changed files with 141 additions and 3 deletions

View File

@@ -22,6 +22,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/event_manager.h>
#include <zmk/events/position_state_changed.h>
ZMK_EVENT_IMPL(zmk_physical_layout_selection_changed);
#define DT_DRV_COMPAT zmk_physical_layout
#define USE_PHY_LAYOUTS \
@@ -247,7 +249,14 @@ int zmk_physical_layouts_select(uint8_t index) {
return -EINVAL;
}
return zmk_physical_layouts_select_layout(layouts[index]);
int ret = zmk_physical_layouts_select_layout(layouts[index]);
if (ret >= 0) {
raise_zmk_physical_layout_selection_changed(
(struct zmk_physical_layout_selection_changed){.selection = index});
}
return ret;
}
int zmk_physical_layouts_get_selected(void) {