feat(core): Make physical layout key rotation optional (#2770)

To be able to save on flash space, for layouts on space constrained
devices that don't require rotation, make key rotation props
optional behind a new Kconfig flag.
This commit is contained in:
Pete Johanson
2025-01-15 14:48:18 -07:00
committed by GitHub
parent 6941abc2af
commit c367d8f636
5 changed files with 19 additions and 3 deletions

View File

@@ -497,6 +497,10 @@ endif # ZMK_BLE || ZMK_SPLIT_BLE
endmenu # Initialization Priorities
config ZMK_PHYSICAL_LAYOUT_KEY_ROTATION
bool "Support rotation of keys in physical layouts"
default y
menuconfig ZMK_KSCAN
bool "ZMK KScan Integration"
default y

View File

@@ -21,9 +21,11 @@ struct zmk_key_physical_attrs {
int16_t height;
int16_t x;
int16_t y;
#if IS_ENABLED(CONFIG_ZMK_PHYSICAL_LAYOUT_KEY_ROTATION)
int16_t rx;
int16_t ry;
int16_t r;
#endif
};
struct zmk_physical_layout {

View File

@@ -46,9 +46,11 @@ BUILD_ASSERT(
.height = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, height), \
.x = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, x), \
.y = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, y), \
.rx = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, rx), \
.ry = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, ry), \
.r = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, r), \
COND_CODE_1(IS_ENABLED(CONFIG_ZMK_PHYSICAL_LAYOUT_KEY_ROTATION), \
(.rx = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, rx), \
.ry = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, ry), \
.r = (int16_t)(int32_t)DT_INST_PHA_BY_IDX(n, keys, i, r), ), \
()) \
}
#define ZMK_LAYOUT_INST(n) \

View File

@@ -278,9 +278,11 @@ static bool encode_layout_keys(pb_ostream_t *stream, const pb_field_t *field, vo
.height = layout_kp->height,
.x = layout_kp->x,
.y = layout_kp->y,
#if IS_ENABLED(CONFIG_ZMK_PHYSICAL_LAYOUT_KEY_ROTATION)
.r = layout_kp->r,
.rx = layout_kp->rx,
.ry = layout_kp->ry,
#endif
};
if (!pb_encode_submessage(stream, &zmk_keymap_KeyPhysicalAttrs_msg, &layout_kp_msg)) {