Skip to content

Commit

Permalink
feat: Build asserts for requires studio layout bits.
Browse files Browse the repository at this point in the history
* When building with ZMK Studio, assert that we have physical layouts,
  and those layouts have key information set.
  • Loading branch information
petejohanson committed Sep 30, 2024
1 parent e68abe5 commit 8267010
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/physical_layouts.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ ZMK_EVENT_IMPL(zmk_physical_layout_selection_changed);
#define USE_PHY_LAYOUTS \
(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) && !DT_HAS_CHOSEN(zmk_matrix_transform))

BUILD_ASSERT(
!IS_ENABLED(CONFIG_ZMK_STUDIO) || USE_PHY_LAYOUTS,
"ZMK Studio requires physical layouts with key positions, and no chosen zmk,matrix-transform");

#if USE_PHY_LAYOUTS

#define ZKPA_INIT(i, n) \
Expand All @@ -43,6 +47,8 @@ ZMK_EVENT_IMPL(zmk_physical_layout_selection_changed);
}

#define ZMK_LAYOUT_INST(n) \
BUILD_ASSERT(!IS_ENABLED(CONFIG_ZMK_STUDIO) || DT_INST_NODE_HAS_PROP(n, keys), \
"ZMK Studio requires physical layouts with key positions"); \
static const struct zmk_key_physical_attrs const _CONCAT( \
_zmk_physical_layout_keys_, n)[DT_INST_PROP_LEN_OR(n, keys, 0)] = { \
LISTIFY(DT_INST_PROP_LEN_OR(n, keys, 0), ZKPA_INIT, (, ), n)}; \
Expand Down

0 comments on commit 8267010

Please sign in to comment.