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(core): Warn only with layouts + chosen transform #2490

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/include/zmk/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)];

Expand Down
21 changes: 19 additions & 2 deletions app/src/physical_layouts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) { \
Expand Down Expand Up @@ -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) = {
Expand All @@ -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",
Expand Down Expand Up @@ -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];
Expand Down