diff --git a/app/include/zmk/matrix.h b/app/include/zmk/matrix.h index e38f5a4967c..436f86f5d18 100644 --- a/app/include/zmk/matrix.h +++ b/app/include/zmk/matrix.h @@ -13,10 +13,6 @@ #if DT_HAS_COMPAT_STATUS_OKAY(zmk_physical_layout) -#if ZMK_MATRIX_HAS_TRANSFORM -#error "To use physical layouts, remove the chosen `zmk,matrix-transform` value." -#endif - #define ZMK_PHYSICAL_LAYOUT_BYTE_ARRAY(node_id) \ uint8_t _CONCAT(prop_, node_id)[DT_PROP_LEN(DT_PHANDLE(node_id, transform), map)]; diff --git a/app/src/physical_layouts.c b/app/src/physical_layouts.c index e77a290ed13..c71b427a4dd 100644 --- a/app/src/physical_layouts.c +++ b/app/src/physical_layouts.c @@ -24,7 +24,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define DT_DRV_COMPAT zmk_physical_layout -#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) +#define USE_PHY_LAYOUTS \ + (DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) && !DT_HAS_CHOSEN(zmk_matrix_transform)) + +#if USE_PHY_LAYOUTS #define ZKPA_INIT(i, n) \ (const struct zmk_key_physical_attrs) { \ @@ -99,6 +102,13 @@ static const struct zmk_physical_layout *const layouts[] = { #elif DT_HAS_CHOSEN(zmk_matrix_transform) +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +#warning \ + "Ignoring the physical layouts and using the chosen matrix transform. Consider setting a chosen physical layout instead." + +#endif + ZMK_MATRIX_TRANSFORM_EXTERN(DT_CHOSEN(zmk_matrix_transform)); static const struct zmk_physical_layout _CONCAT(_zmk_physical_layout_, chosen) = { @@ -111,6 +121,13 @@ static const struct zmk_physical_layout *const layouts[] = { #elif DT_HAS_CHOSEN(zmk_kscan) +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +#warning \ + "Ignoring the physical layouts and using the chosen kscan with a synthetic transform. Consider setting a chosen physical layout instead." + +#endif + ZMK_MATRIX_TRANSFORM_DEFAULT_EXTERN(); static const struct zmk_physical_layout _CONCAT(_zmk_physical_layout_, chosen) = { .display_name = "Default", @@ -252,7 +269,7 @@ static int8_t saved_selected_index = -1; int zmk_physical_layouts_select_initial(void) { const struct zmk_physical_layout *initial; -#if DT_HAS_CHOSEN(zmk_physical_layout) +#if USE_PHY_LAYOUTS && DT_HAS_CHOSEN(zmk_physical_layout) initial = &_CONCAT(_zmk_physical_layout_, DT_CHOSEN(zmk_physical_layout)); #else initial = layouts[0];