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 3975d2fdaf
commit 03b5b38bc4
5 changed files with 116 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
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
@@ -227,7 +229,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) {