From cca637d66e36a85706d1807d44a5fecbc66bc5f7 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Thu, 19 Sep 2024 01:34:20 -0600 Subject: [PATCH 01/42] fix: Properly calculate highest active layer for display. --- .../arm/corneish_zen/widgets/layer_status.c | 9 +++++---- app/boards/shields/nice_view/widgets/status.c | 7 ++++--- app/include/zmk/keymap.h | 2 +- app/src/display/widgets/layer_status.c | 7 ++++--- app/src/keymap.c | 17 ++++++++++++----- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/boards/arm/corneish_zen/widgets/layer_status.c b/app/boards/arm/corneish_zen/widgets/layer_status.c index 86418318092..82de72c99fd 100644 --- a/app/boards/arm/corneish_zen/widgets/layer_status.c +++ b/app/boards/arm/corneish_zen/widgets/layer_status.c @@ -19,13 +19,13 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); struct layer_status_state { - uint8_t index; + zmk_keymap_layer_index_t index; const char *label; }; static void set_layer_symbol(lv_obj_t *label, struct layer_status_state state) { const char *layer_label = state.label; - uint8_t active_layer_index = state.index; + zmk_keymap_layer_index_t active_layer_index = state.index; if (layer_label == NULL) { char text[6] = {}; @@ -44,8 +44,9 @@ static void layer_status_update_cb(struct layer_status_state state) { } static struct layer_status_state layer_status_get_state(const zmk_event_t *eh) { - uint8_t index = zmk_keymap_highest_layer_active(); - return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_name(index)}; + zmk_keymap_layer_index_t index = zmk_keymap_highest_layer_active(); + return (struct layer_status_state){ + .index = index, .label = zmk_keymap_layer_name(zmk_keymap_layer_index_to_id(index))}; } ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, layer_status_update_cb, diff --git a/app/boards/shields/nice_view/widgets/status.c b/app/boards/shields/nice_view/widgets/status.c index f5095cbf1d8..fa0223551c4 100644 --- a/app/boards/shields/nice_view/widgets/status.c +++ b/app/boards/shields/nice_view/widgets/status.c @@ -36,7 +36,7 @@ struct output_status_state { }; struct layer_status_state { - uint8_t index; + zmk_keymap_layer_index_t index; const char *label; }; @@ -277,8 +277,9 @@ static void layer_status_update_cb(struct layer_status_state state) { } static struct layer_status_state layer_status_get_state(const zmk_event_t *eh) { - uint8_t index = zmk_keymap_highest_layer_active(); - return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_name(index)}; + zmk_keymap_layer_index_t index = zmk_keymap_highest_layer_active(); + return (struct layer_status_state){ + .index = index, .label = zmk_keymap_layer_name(zmk_keymap_layer_index_to_id(index))}; } ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, layer_status_update_cb, diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 50b358ba92a..9b278a6050f 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -34,7 +34,7 @@ zmk_keymap_layer_id_t zmk_keymap_layer_index_to_id(zmk_keymap_layer_index_t laye zmk_keymap_layer_id_t zmk_keymap_layer_default(void); zmk_keymap_layers_state_t zmk_keymap_layer_state(void); bool zmk_keymap_layer_active(zmk_keymap_layer_id_t layer); -zmk_keymap_layer_id_t zmk_keymap_highest_layer_active(void); +zmk_keymap_layer_index_t zmk_keymap_highest_layer_active(void); int zmk_keymap_layer_activate(zmk_keymap_layer_id_t layer); int zmk_keymap_layer_deactivate(zmk_keymap_layer_id_t layer); int zmk_keymap_layer_toggle(zmk_keymap_layer_id_t layer); diff --git a/app/src/display/widgets/layer_status.c b/app/src/display/widgets/layer_status.c index 19e25d93312..d341ccd3223 100644 --- a/app/src/display/widgets/layer_status.c +++ b/app/src/display/widgets/layer_status.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); struct layer_status_state { - uint8_t index; + zmk_keymap_layer_index_t index; const char *label; }; @@ -44,8 +44,9 @@ static void layer_status_update_cb(struct layer_status_state state) { } static struct layer_status_state layer_status_get_state(const zmk_event_t *eh) { - uint8_t index = zmk_keymap_highest_layer_active(); - return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_name(index)}; + zmk_keymap_layer_index_t index = zmk_keymap_highest_layer_active(); + return (struct layer_status_state){ + .index = index, .label = zmk_keymap_layer_name(zmk_keymap_layer_index_to_id(index))}; } ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, layer_status_update_cb, diff --git a/app/src/keymap.c b/app/src/keymap.c index 41e57024b77..e49acb579c5 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -182,13 +182,20 @@ bool zmk_keymap_layer_active(zmk_keymap_layer_id_t layer) { return zmk_keymap_layer_active_with_state(layer, _zmk_keymap_layer_state); }; -zmk_keymap_layer_id_t zmk_keymap_highest_layer_active(void) { - for (uint8_t layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer > 0; layer--) { - if (zmk_keymap_layer_active(layer)) { - return layer; +zmk_keymap_layer_index_t zmk_keymap_highest_layer_active(void) { + for (int layer_idx = ZMK_KEYMAP_LAYERS_LEN - 1; + layer_idx >= LAYER_ID_TO_INDEX(_zmk_keymap_layer_default); layer_idx--) { + zmk_keymap_layer_id_t layer_id = LAYER_INDEX_TO_ID(layer_idx); + + if (layer_id == ZMK_KEYMAP_LAYER_ID_INVAL) { + continue; + } + if (zmk_keymap_layer_active(layer_id)) { + return LAYER_ID_TO_INDEX(layer_id); } } - return zmk_keymap_layer_default(); + + return LAYER_ID_TO_INDEX(zmk_keymap_layer_default()); } int zmk_keymap_layer_activate(zmk_keymap_layer_id_t layer) { return set_layer_state(layer, true); }; From 11f600d9e52233a038b86069c99c5f7947b7b925 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Fri, 20 Sep 2024 16:37:10 -0600 Subject: [PATCH 02/42] fix(display): Check layer name length too. --- app/boards/arm/corneish_zen/widgets/layer_status.c | 2 +- app/src/display/widgets/layer_status.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/boards/arm/corneish_zen/widgets/layer_status.c b/app/boards/arm/corneish_zen/widgets/layer_status.c index 82de72c99fd..002ce46b48d 100644 --- a/app/boards/arm/corneish_zen/widgets/layer_status.c +++ b/app/boards/arm/corneish_zen/widgets/layer_status.c @@ -27,7 +27,7 @@ static void set_layer_symbol(lv_obj_t *label, struct layer_status_state state) { const char *layer_label = state.label; zmk_keymap_layer_index_t active_layer_index = state.index; - if (layer_label == NULL) { + if (layer_label == NULL || strlen(layer_label) == 0) { char text[6] = {}; sprintf(text, " %i", active_layer_index); diff --git a/app/src/display/widgets/layer_status.c b/app/src/display/widgets/layer_status.c index d341ccd3223..64cb7c3d599 100644 --- a/app/src/display/widgets/layer_status.c +++ b/app/src/display/widgets/layer_status.c @@ -23,7 +23,7 @@ struct layer_status_state { }; static void set_layer_symbol(lv_obj_t *label, struct layer_status_state state) { - if (state.label == NULL) { + if (state.label == NULL || strlen(state.label) == 0) { char text[8] = {}; snprintf(text, sizeof(text), LV_SYMBOL_KEYBOARD " %i", state.index); From 9e36ebd52587c0364562057466a458fdcfcdc685 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Tue, 17 Jan 2023 19:05:04 +0100 Subject: [PATCH 03/42] feat(split): Make locality work nested behavior invocations Co-authored-by: Tokazio --- app/include/zmk/behavior.h | 14 ++++ app/include/zmk/behavior_queue.h | 4 +- app/include/zmk/split/bluetooth/service.h | 1 + app/src/behavior.c | 67 ++++++++++++++++++ app/src/behavior_queue.c | 17 +++-- app/src/behaviors/behavior_hold_tap.c | 24 ++++--- app/src/behaviors/behavior_macro.c | 15 ++-- app/src/behaviors/behavior_mod_morph.c | 4 +- .../behaviors/behavior_sensor_rotate_common.c | 4 +- app/src/behaviors/behavior_sticky_key.c | 15 ++-- app/src/behaviors/behavior_tap_dance.c | 15 ++-- app/src/keymap.c | 70 ++----------------- app/src/split/bluetooth/central.c | 1 + 13 files changed, 146 insertions(+), 105 deletions(-) diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h index d45bbfffe75..0940fc6eeef 100644 --- a/app/include/zmk/behavior.h +++ b/app/include/zmk/behavior.h @@ -26,6 +26,7 @@ struct zmk_behavior_binding_event { int layer; uint32_t position; int64_t timestamp; + uint8_t source; }; /** @@ -42,6 +43,19 @@ struct zmk_behavior_binding_event { */ const struct device *zmk_behavior_get_binding(const char *name); +/** + * @brief Invoke a behavior given its binding and invoking event details. + * + * @param src_binding Behavior binding to invoke. + * @param event The binding event struct containing details of the event that invoked it. + * @param pressed Whether the binding is pressed or released. + * + * @retval 0 If successful. + * @retval Negative errno code if failure. + */ +int zmk_behavior_invoke_binding(const struct zmk_behavior_binding *src_binding, + struct zmk_behavior_binding_event event, bool pressed); + /** * @brief Get a local ID for a behavior from its @p name field. * diff --git a/app/include/zmk/behavior_queue.h b/app/include/zmk/behavior_queue.h index 307482e7cd4..781f582e095 100644 --- a/app/include/zmk/behavior_queue.h +++ b/app/include/zmk/behavior_queue.h @@ -10,5 +10,5 @@ #include #include -int zmk_behavior_queue_add(uint32_t position, const struct zmk_behavior_binding behavior, - bool press, uint32_t wait); +int zmk_behavior_queue_add(uint32_t position, uint8_t source, + const struct zmk_behavior_binding behavior, bool press, uint32_t wait); diff --git a/app/include/zmk/split/bluetooth/service.h b/app/include/zmk/split/bluetooth/service.h index 112cd552942..1c9e75226ad 100644 --- a/app/include/zmk/split/bluetooth/service.h +++ b/app/include/zmk/split/bluetooth/service.h @@ -20,6 +20,7 @@ struct sensor_event { struct zmk_split_run_behavior_data { uint8_t position; + uint8_t source; uint8_t state; uint32_t param1; uint32_t param2; diff --git a/app/src/behavior.c b/app/src/behavior.c index e69cdf88702..f24f0223634 100644 --- a/app/src/behavior.c +++ b/app/src/behavior.c @@ -17,11 +17,18 @@ #endif +#include +#if ZMK_BLE_IS_CENTRAL +#include +#endif + #include #include #include #include +#include + #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -49,6 +56,66 @@ const struct device *z_impl_behavior_get_binding(const char *name) { return NULL; } +static int invoke_locally(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event, bool pressed) { + if (pressed) { + return behavior_keymap_binding_pressed(binding, event); + } else { + return behavior_keymap_binding_released(binding, event); + } +} + +int zmk_behavior_invoke_binding(const struct zmk_behavior_binding *src_binding, + struct zmk_behavior_binding_event event, bool pressed) { + // We want to make a copy of this, since it may be converted from + // relative to absolute before being invoked + struct zmk_behavior_binding binding = *src_binding; + + const struct device *behavior = zmk_behavior_get_binding(binding.behavior_dev); + + if (!behavior) { + LOG_WRN("No behavior assigned to %d on layer %d", event.position, event.layer); + return 1; + } + + int err = behavior_keymap_binding_convert_central_state_dependent_params(&binding, event); + if (err) { + LOG_ERR("Failed to convert relative to absolute behavior binding (err %d)", err); + return err; + } + + enum behavior_locality locality = BEHAVIOR_LOCALITY_CENTRAL; + err = behavior_get_locality(behavior, &locality); + if (err) { + LOG_ERR("Failed to get behavior locality %d", err); + return err; + } + + switch (locality) { + case BEHAVIOR_LOCALITY_CENTRAL: + return invoke_locally(&binding, event, pressed); + case BEHAVIOR_LOCALITY_EVENT_SOURCE: +#if ZMK_BLE_IS_CENTRAL + if (event.source == ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL) { + return invoke_locally(&binding, event, pressed); + } else { + return zmk_split_bt_invoke_behavior(event.source, &binding, event, pressed); + } +#else + return invoke_locally(&binding, event, pressed); +#endif + case BEHAVIOR_LOCALITY_GLOBAL: +#if ZMK_BLE_IS_CENTRAL + for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) { + zmk_split_bt_invoke_behavior(i, &binding, event, pressed); + } +#endif + return invoke_locally(&binding, event, pressed); + } + + return -ENOTSUP; +} + #if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA) int zmk_behavior_get_empty_param_metadata(const struct device *dev, diff --git a/app/src/behavior_queue.c b/app/src/behavior_queue.c index 1511e755d4f..19275fe1516 100644 --- a/app/src/behavior_queue.c +++ b/app/src/behavior_queue.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -14,6 +15,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct q_item { uint32_t position; + uint8_t source; struct zmk_behavior_binding binding; bool press : 1; uint32_t wait : 31; @@ -31,13 +33,13 @@ static void behavior_queue_process_next(struct k_work *work) { LOG_DBG("Invoking %s: 0x%02x 0x%02x", item.binding.behavior_dev, item.binding.param1, item.binding.param2); - struct zmk_behavior_binding_event event = {.position = item.position, - .timestamp = k_uptime_get()}; + struct zmk_behavior_binding_event event = { + .position = item.position, .timestamp = k_uptime_get(), .source = item.source}; if (item.press) { - behavior_keymap_binding_pressed(&item.binding, event); + zmk_behavior_invoke_binding(&item.binding, event, true); } else { - behavior_keymap_binding_released(&item.binding, event); + zmk_behavior_invoke_binding(&item.binding, event, false); } LOG_DBG("Processing next queued behavior in %dms", item.wait); @@ -49,9 +51,10 @@ static void behavior_queue_process_next(struct k_work *work) { } } -int zmk_behavior_queue_add(uint32_t position, const struct zmk_behavior_binding binding, bool press, - uint32_t wait) { - struct q_item item = {.press = press, .binding = binding, .wait = wait}; +int zmk_behavior_queue_add(uint32_t position, uint8_t source, + const struct zmk_behavior_binding binding, bool press, uint32_t wait) { + struct q_item item = { + .press = press, .binding = binding, .wait = wait, .position = position, .source = source}; const int ret = k_msgq_put(&zmk_behavior_queue_msgq, &item, K_NO_WAIT); if (ret < 0) { diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index c45ee803f53..7280451a063 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -18,7 +18,6 @@ #include #include #include -#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -77,6 +76,7 @@ struct behavior_hold_tap_data { // this data is specific for each hold-tap struct active_hold_tap { int32_t position; + uint8_t source; uint32_t param_hold; uint32_t param_tap; int64_t timestamp; @@ -250,14 +250,16 @@ static struct active_hold_tap *find_hold_tap(uint32_t position) { return NULL; } -static struct active_hold_tap *store_hold_tap(uint32_t position, uint32_t param_hold, - uint32_t param_tap, int64_t timestamp, +static struct active_hold_tap *store_hold_tap(uint32_t position, uint8_t source, + uint32_t param_hold, uint32_t param_tap, + int64_t timestamp, const struct behavior_hold_tap_config *config) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { continue; } active_hold_taps[i].position = position; + active_hold_taps[i].source = source; active_hold_taps[i].status = STATUS_UNDECIDED; active_hold_taps[i].config = config; active_hold_taps[i].param_hold = param_hold; @@ -400,45 +402,49 @@ static int press_hold_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, + .source = hold_tap->source, }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->hold_behavior_dev, .param1 = hold_tap->param_hold}; - return behavior_keymap_binding_pressed(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, true); } static int press_tap_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, + .source = hold_tap->source, }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->tap_behavior_dev, .param1 = hold_tap->param_tap}; store_last_hold_tapped(hold_tap); - return behavior_keymap_binding_pressed(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, true); } static int release_hold_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, + .source = hold_tap->source, }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->hold_behavior_dev, .param1 = hold_tap->param_hold}; - return behavior_keymap_binding_released(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, false); } static int release_tap_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, + .source = hold_tap->source, }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->tap_behavior_dev, .param1 = hold_tap->param_tap}; - return behavior_keymap_binding_released(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, false); } static int press_binding(struct active_hold_tap *hold_tap) { @@ -597,8 +603,8 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, return ZMK_BEHAVIOR_OPAQUE; } - struct active_hold_tap *hold_tap = - store_hold_tap(event.position, binding->param1, binding->param2, event.timestamp, cfg); + struct active_hold_tap *hold_tap = store_hold_tap(event.position, event.source, binding->param1, + binding->param2, event.timestamp, cfg); if (hold_tap == NULL) { LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", ZMK_BHV_HOLD_TAP_MAX_HELD); diff --git a/app/src/behaviors/behavior_macro.c b/app/src/behaviors/behavior_macro.c index b535ed8be07..adf3fa65747 100644 --- a/app/src/behaviors/behavior_macro.c +++ b/app/src/behaviors/behavior_macro.c @@ -158,7 +158,8 @@ static void replace_params(struct behavior_macro_trigger_state *state, state->param2_source = PARAM_SOURCE_BINDING; } -static void queue_macro(uint32_t position, const struct zmk_behavior_binding bindings[], +static void queue_macro(uint32_t position, uint8_t source, + const struct zmk_behavior_binding bindings[], struct behavior_macro_trigger_state state, const struct zmk_behavior_binding *macro_binding) { LOG_DBG("Iterating macro bindings - starting: %d, count: %d", state.start_index, state.count); @@ -169,14 +170,14 @@ static void queue_macro(uint32_t position, const struct zmk_behavior_binding bin switch (state.mode) { case MACRO_MODE_TAP: - zmk_behavior_queue_add(position, binding, true, state.tap_ms); - zmk_behavior_queue_add(position, binding, false, state.wait_ms); + zmk_behavior_queue_add(position, source, binding, true, state.tap_ms); + zmk_behavior_queue_add(position, source, binding, false, state.wait_ms); break; case MACRO_MODE_PRESS: - zmk_behavior_queue_add(position, binding, true, state.wait_ms); + zmk_behavior_queue_add(position, source, binding, true, state.wait_ms); break; case MACRO_MODE_RELEASE: - zmk_behavior_queue_add(position, binding, false, state.wait_ms); + zmk_behavior_queue_add(position, source, binding, false, state.wait_ms); break; default: LOG_ERR("Unknown macro mode: %d", state.mode); @@ -197,7 +198,7 @@ static int on_macro_binding_pressed(struct zmk_behavior_binding *binding, .start_index = 0, .count = state->press_bindings_count}; - queue_macro(event.position, cfg->bindings, trigger_state, binding); + queue_macro(event.position, event.source, cfg->bindings, trigger_state, binding); return ZMK_BEHAVIOR_OPAQUE; } @@ -208,7 +209,7 @@ static int on_macro_binding_released(struct zmk_behavior_binding *binding, const struct behavior_macro_config *cfg = dev->config; struct behavior_macro_state *state = dev->data; - queue_macro(event.position, cfg->bindings, state->release_state, binding); + queue_macro(event.position, event.source, cfg->bindings, state->release_state, binding); return ZMK_BEHAVIOR_OPAQUE; } diff --git a/app/src/behaviors/behavior_mod_morph.c b/app/src/behaviors/behavior_mod_morph.c index 303f96a7d05..6698f24886f 100644 --- a/app/src/behaviors/behavior_mod_morph.c +++ b/app/src/behaviors/behavior_mod_morph.c @@ -51,7 +51,7 @@ static int on_mod_morph_binding_pressed(struct zmk_behavior_binding *binding, } else { data->pressed_binding = (struct zmk_behavior_binding *)&cfg->normal_binding; } - return behavior_keymap_binding_pressed(data->pressed_binding, event); + return zmk_behavior_invoke_binding(data->pressed_binding, event, true); } static int on_mod_morph_binding_released(struct zmk_behavior_binding *binding, @@ -67,7 +67,7 @@ static int on_mod_morph_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding *pressed_binding = data->pressed_binding; data->pressed_binding = NULL; int err; - err = behavior_keymap_binding_released(pressed_binding, event); + err = zmk_behavior_invoke_binding(pressed_binding, event, false); zmk_hid_masked_modifiers_clear(); return err; } diff --git a/app/src/behaviors/behavior_sensor_rotate_common.c b/app/src/behaviors/behavior_sensor_rotate_common.c index 94bf40c18d4..677443ee290 100644 --- a/app/src/behaviors/behavior_sensor_rotate_common.c +++ b/app/src/behaviors/behavior_sensor_rotate_common.c @@ -90,8 +90,8 @@ int zmk_behavior_sensor_rotate_common_process(struct zmk_behavior_binding *bindi LOG_DBG("Sensor binding: %s", binding->behavior_dev); for (int i = 0; i < triggers; i++) { - zmk_behavior_queue_add(event.position, triggered_binding, true, cfg->tap_ms); - zmk_behavior_queue_add(event.position, triggered_binding, false, 0); + zmk_behavior_queue_add(event.position, event.source, triggered_binding, true, cfg->tap_ms); + zmk_behavior_queue_add(event.position, event.source, triggered_binding, false, 0); } return ZMK_BEHAVIOR_OPAQUE; diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 61c86fb7d21..a77ba4d08c4 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -40,6 +40,7 @@ struct behavior_sticky_key_config { struct active_sticky_key { uint32_t position; + uint8_t source; uint32_t param1; uint32_t param2; const struct behavior_sticky_key_config *config; @@ -55,8 +56,8 @@ struct active_sticky_key { struct active_sticky_key active_sticky_keys[ZMK_BHV_STICKY_KEY_MAX_HELD] = {}; -static struct active_sticky_key *store_sticky_key(uint32_t position, uint32_t param1, - uint32_t param2, +static struct active_sticky_key *store_sticky_key(uint32_t position, uint8_t source, + uint32_t param1, uint32_t param2, const struct behavior_sticky_key_config *config) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { struct active_sticky_key *const sticky_key = &active_sticky_keys[i]; @@ -65,6 +66,7 @@ static struct active_sticky_key *store_sticky_key(uint32_t position, uint32_t pa continue; } sticky_key->position = position; + sticky_key->source = source; sticky_key->param1 = param1; sticky_key->param2 = param2; sticky_key->config = config; @@ -101,8 +103,9 @@ static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key struct zmk_behavior_binding_event event = { .position = sticky_key->position, .timestamp = timestamp, + .source = sticky_key->source, }; - return behavior_keymap_binding_pressed(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, true); } static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_key, @@ -115,10 +118,11 @@ static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_k struct zmk_behavior_binding_event event = { .position = sticky_key->position, .timestamp = timestamp, + .source = sticky_key->source, }; clear_sticky_key(sticky_key); - return behavior_keymap_binding_released(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, false); } static inline void on_sticky_key_timeout(struct active_sticky_key *sticky_key) { @@ -149,7 +153,8 @@ static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding, stop_timer(sticky_key); release_sticky_key_behavior(sticky_key, event.timestamp); } - sticky_key = store_sticky_key(event.position, binding->param1, binding->param2, cfg); + sticky_key = + store_sticky_key(event.position, event.source, binding->param1, binding->param2, cfg); if (sticky_key == NULL) { LOG_ERR("unable to store sticky key, did you press more than %d sticky_key?", ZMK_BHV_STICKY_KEY_MAX_HELD); diff --git a/app/src/behaviors/behavior_tap_dance.c b/app/src/behaviors/behavior_tap_dance.c index 61e755850d9..606a16393cd 100644 --- a/app/src/behaviors/behavior_tap_dance.c +++ b/app/src/behaviors/behavior_tap_dance.c @@ -35,6 +35,7 @@ struct active_tap_dance { // Tap Dance Data int counter; uint32_t position; + uint8_t source; uint32_t param1; uint32_t param2; bool is_pressed; @@ -59,13 +60,15 @@ static struct active_tap_dance *find_tap_dance(uint32_t position) { return NULL; } -static int new_tap_dance(uint32_t position, const struct behavior_tap_dance_config *config, +static int new_tap_dance(uint32_t position, uint8_t source, + const struct behavior_tap_dance_config *config, struct active_tap_dance **tap_dance) { for (int i = 0; i < ZMK_BHV_TAP_DANCE_MAX_HELD; i++) { struct active_tap_dance *const ref_dance = &active_tap_dances[i]; if (ref_dance->position == ZMK_BHV_TAP_DANCE_POSITION_FREE) { ref_dance->counter = 0; ref_dance->position = position; + ref_dance->source = source; ref_dance->config = config; ref_dance->release_at = 0; ref_dance->is_pressed = true; @@ -108,8 +111,9 @@ static inline int press_tap_dance_behavior(struct active_tap_dance *tap_dance, i struct zmk_behavior_binding_event event = { .position = tap_dance->position, .timestamp = timestamp, + .source = tap_dance->source, }; - return behavior_keymap_binding_pressed(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, true); } static inline int release_tap_dance_behavior(struct active_tap_dance *tap_dance, @@ -118,9 +122,10 @@ static inline int release_tap_dance_behavior(struct active_tap_dance *tap_dance, struct zmk_behavior_binding_event event = { .position = tap_dance->position, .timestamp = timestamp, + .source = tap_dance->source, }; clear_tap_dance(tap_dance); - return behavior_keymap_binding_released(&binding, event); + return zmk_behavior_invoke_binding(&binding, event, false); } static int on_tap_dance_binding_pressed(struct zmk_behavior_binding *binding, @@ -130,7 +135,7 @@ static int on_tap_dance_binding_pressed(struct zmk_behavior_binding *binding, struct active_tap_dance *tap_dance; tap_dance = find_tap_dance(event.position); if (tap_dance == NULL) { - if (new_tap_dance(event.position, cfg, &tap_dance) == -ENOMEM) { + if (new_tap_dance(event.position, event.source, cfg, &tap_dance) == -ENOMEM) { LOG_ERR("Unable to create new tap dance. Insufficient space in active_tap_dances[]."); return ZMK_BEHAVIOR_OPAQUE; } @@ -261,4 +266,4 @@ static int behavior_tap_dance_init(const struct device *dev) { DT_INST_FOREACH_STATUS_OKAY(KP_INST) -#endif \ No newline at end of file +#endif diff --git a/app/src/keymap.c b/app/src/keymap.c index e49acb579c5..d4a4ab1f7de 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -7,7 +7,6 @@ #include #include #include -#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -18,11 +17,6 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -#include -#if ZMK_BLE_IS_CENTRAL -#include -#endif - #include #include #include @@ -585,76 +579,20 @@ int zmk_keymap_reset_settings(void) { return -ENOTSUP; } #endif // IS_ENABLED(CONFIG_ZMK_KEYMAP_SETTINGS_STORAGE) -int invoke_locally(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event, - bool pressed) { - if (pressed) { - return behavior_keymap_binding_pressed(binding, event); - } else { - return behavior_keymap_binding_released(binding, event); - } -} - int zmk_keymap_apply_position_state(uint8_t source, zmk_keymap_layer_id_t layer_id, uint32_t position, bool pressed, int64_t timestamp) { - // We want to make a copy of this, since it may be converted from - // relative to absolute before being invoked - - ASSERT_LAYER_VAL(layer_id, -EINVAL); - - struct zmk_behavior_binding binding = zmk_keymap[layer_id][position]; - const struct device *behavior; + struct zmk_behavior_binding *binding = &zmk_keymap[layer_id][position]; struct zmk_behavior_binding_event event = { .layer = layer_id, .position = position, .timestamp = timestamp, + .source = source, }; LOG_DBG("layer_id: %d position: %d, binding name: %s", layer_id, position, - binding.behavior_dev); - - behavior = zmk_behavior_get_binding(binding.behavior_dev); - - if (!behavior) { - LOG_WRN("No behavior assigned to %d on layer %d", position, layer_id); - return 1; - } + binding->behavior_dev); - int err = behavior_keymap_binding_convert_central_state_dependent_params(&binding, event); - if (err) { - LOG_ERR("Failed to convert relative to absolute behavior binding (err %d)", err); - return err; - } - - enum behavior_locality locality = BEHAVIOR_LOCALITY_CENTRAL; - err = behavior_get_locality(behavior, &locality); - if (err) { - LOG_ERR("Failed to get behavior locality %d", err); - return err; - } - - switch (locality) { - case BEHAVIOR_LOCALITY_CENTRAL: - return invoke_locally(&binding, event, pressed); - case BEHAVIOR_LOCALITY_EVENT_SOURCE: -#if ZMK_BLE_IS_CENTRAL - if (source == ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL) { - return invoke_locally(&binding, event, pressed); - } else { - return zmk_split_bt_invoke_behavior(source, &binding, event, pressed); - } -#else - return invoke_locally(&binding, event, pressed); -#endif - case BEHAVIOR_LOCALITY_GLOBAL: -#if ZMK_BLE_IS_CENTRAL - for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) { - zmk_split_bt_invoke_behavior(i, &binding, event, pressed); - } -#endif - return invoke_locally(&binding, event, pressed); - } - - return -ENOTSUP; + return zmk_behavior_invoke_binding(binding, event, pressed); } int zmk_keymap_position_state_changed(uint8_t source, uint32_t position, bool pressed, diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 0f4cd78b531..9c459bf1b1d 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -816,6 +816,7 @@ int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *bi .param1 = binding->param1, .param2 = binding->param2, .position = event.position, + .source = event.source, .state = state ? 1 : 0, }}; const size_t payload_dev_size = sizeof(payload.behavior_dev); From 4fdfb01b6aa3715ae9e28391991f8bb1b604db4d Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Fri, 9 Aug 2024 00:07:21 -0700 Subject: [PATCH 04/42] feat(split): Make combos invoke behaviors with locality TODO: Currently the source is hardcoded to central for source local behaviors --- app/src/combo.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/combo.c b/app/src/combo.c index 3f78878f01f..a990e2f2a60 100644 --- a/app/src/combo.c +++ b/app/src/combo.c @@ -291,21 +291,23 @@ static int release_pressed_keys() { static inline int press_combo_behavior(struct combo_cfg *combo, int32_t timestamp) { struct zmk_behavior_binding_event event = { .position = combo->virtual_key_position, + .source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, .timestamp = timestamp, }; last_combo_timestamp = timestamp; - return behavior_keymap_binding_pressed(&combo->behavior, event); + return zmk_behavior_invoke_binding(&combo->behavior, event, true); } static inline int release_combo_behavior(struct combo_cfg *combo, int32_t timestamp) { struct zmk_behavior_binding_event event = { .position = combo->virtual_key_position, + .source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, .timestamp = timestamp, }; - return behavior_keymap_binding_released(&combo->behavior, event); + return zmk_behavior_invoke_binding(&combo->behavior, event, false); } static void move_pressed_keys_to_active_combo(struct active_combo *active_combo) { From b249135742ebba10c07fa899b50cbb260c155a45 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Fri, 9 Aug 2024 11:27:36 -0700 Subject: [PATCH 05/42] feat(sensors): Make sensors always trigger on central (for now) --- app/src/behaviors/behavior_sensor_rotate_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/behaviors/behavior_sensor_rotate_common.c b/app/src/behaviors/behavior_sensor_rotate_common.c index 677443ee290..e8fd7c37a23 100644 --- a/app/src/behaviors/behavior_sensor_rotate_common.c +++ b/app/src/behaviors/behavior_sensor_rotate_common.c @@ -6,6 +6,7 @@ #include #include +#include #include "behavior_sensor_rotate_common.h" @@ -90,8 +91,10 @@ int zmk_behavior_sensor_rotate_common_process(struct zmk_behavior_binding *bindi LOG_DBG("Sensor binding: %s", binding->behavior_dev); for (int i = 0; i < triggers; i++) { - zmk_behavior_queue_add(event.position, event.source, triggered_binding, true, cfg->tap_ms); - zmk_behavior_queue_add(event.position, event.source, triggered_binding, false, 0); + zmk_behavior_queue_add(event.position, ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, + triggered_binding, true, cfg->tap_ms); + zmk_behavior_queue_add(event.position, ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, + triggered_binding, false, 0); } return ZMK_BEHAVIOR_OPAQUE; From fb18a4d871485b7e184f7a13d3095cf624b2b433 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Sat, 17 Aug 2024 21:03:43 -0700 Subject: [PATCH 06/42] refactor: Condition source props on CONFIG_ZMK_SPLIT --- app/include/zmk/behavior.h | 2 ++ app/include/zmk/behavior_queue.h | 2 +- app/src/behavior.c | 2 +- app/src/behavior_queue.c | 20 +++++++++++--- app/src/behaviors/behavior_hold_tap.c | 26 ++++++++++++++----- app/src/behaviors/behavior_macro.c | 14 +++++----- .../behaviors/behavior_sensor_rotate_common.c | 11 +++++--- app/src/behaviors/behavior_sticky_key.c | 17 ++++++++---- app/src/behaviors/behavior_tap_dance.c | 16 +++++++++--- app/src/combo.c | 8 ++++-- app/src/keymap.c | 2 ++ 11 files changed, 86 insertions(+), 34 deletions(-) diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h index 0940fc6eeef..5028d320257 100644 --- a/app/include/zmk/behavior.h +++ b/app/include/zmk/behavior.h @@ -26,7 +26,9 @@ struct zmk_behavior_binding_event { int layer; uint32_t position; int64_t timestamp; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) uint8_t source; +#endif }; /** diff --git a/app/include/zmk/behavior_queue.h b/app/include/zmk/behavior_queue.h index 781f582e095..b942bd28958 100644 --- a/app/include/zmk/behavior_queue.h +++ b/app/include/zmk/behavior_queue.h @@ -10,5 +10,5 @@ #include #include -int zmk_behavior_queue_add(uint32_t position, uint8_t source, +int zmk_behavior_queue_add(const struct zmk_behavior_binding_event *event, const struct zmk_behavior_binding behavior, bool press, uint32_t wait); diff --git a/app/src/behavior.c b/app/src/behavior.c index f24f0223634..9b20c706265 100644 --- a/app/src/behavior.c +++ b/app/src/behavior.c @@ -95,7 +95,7 @@ int zmk_behavior_invoke_binding(const struct zmk_behavior_binding *src_binding, case BEHAVIOR_LOCALITY_CENTRAL: return invoke_locally(&binding, event, pressed); case BEHAVIOR_LOCALITY_EVENT_SOURCE: -#if ZMK_BLE_IS_CENTRAL +#if ZMK_BLE_IS_CENTRAL // source is a member of event because CONFIG_ZMK_SPLIT is enabled if (event.source == ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL) { return invoke_locally(&binding, event, pressed); } else { diff --git a/app/src/behavior_queue.c b/app/src/behavior_queue.c index 19275fe1516..86837f42332 100644 --- a/app/src/behavior_queue.c +++ b/app/src/behavior_queue.c @@ -15,7 +15,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct q_item { uint32_t position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) uint8_t source; +#endif struct zmk_behavior_binding binding; bool press : 1; uint32_t wait : 31; @@ -34,7 +36,12 @@ static void behavior_queue_process_next(struct k_work *work) { item.binding.param2); struct zmk_behavior_binding_event event = { - .position = item.position, .timestamp = k_uptime_get(), .source = item.source}; + .position = item.position, + .timestamp = k_uptime_get(), +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + .source = item.source +#endif + }; if (item.press) { zmk_behavior_invoke_binding(&item.binding, event, true); @@ -51,10 +58,17 @@ static void behavior_queue_process_next(struct k_work *work) { } } -int zmk_behavior_queue_add(uint32_t position, uint8_t source, +int zmk_behavior_queue_add(const struct zmk_behavior_binding_event *event, const struct zmk_behavior_binding binding, bool press, uint32_t wait) { struct q_item item = { - .press = press, .binding = binding, .wait = wait, .position = position, .source = source}; + .press = press, + .binding = binding, + .wait = wait, + .position = event->position, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + .source = event->source, +#endif + }; const int ret = k_msgq_put(&zmk_behavior_queue_msgq, &item, K_NO_WAIT); if (ret < 0) { diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 7280451a063..3df3bc86436 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -76,7 +76,9 @@ struct behavior_hold_tap_data { // this data is specific for each hold-tap struct active_hold_tap { int32_t position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) uint8_t source; +#endif uint32_t param_hold; uint32_t param_tap; int64_t timestamp; @@ -250,21 +252,22 @@ static struct active_hold_tap *find_hold_tap(uint32_t position) { return NULL; } -static struct active_hold_tap *store_hold_tap(uint32_t position, uint8_t source, +static struct active_hold_tap *store_hold_tap(struct zmk_behavior_binding_event *event, uint32_t param_hold, uint32_t param_tap, - int64_t timestamp, const struct behavior_hold_tap_config *config) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { continue; } - active_hold_taps[i].position = position; - active_hold_taps[i].source = source; + active_hold_taps[i].position = event->position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + active_hold_taps[i].source = event->source; +#endif active_hold_taps[i].status = STATUS_UNDECIDED; active_hold_taps[i].config = config; active_hold_taps[i].param_hold = param_hold; active_hold_taps[i].param_tap = param_tap; - active_hold_taps[i].timestamp = timestamp; + active_hold_taps[i].timestamp = event->timestamp; active_hold_taps[i].position_of_first_other_key_pressed = -1; return &active_hold_taps[i]; } @@ -402,7 +405,9 @@ static int press_hold_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = hold_tap->source, +#endif }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->hold_behavior_dev, @@ -414,7 +419,9 @@ static int press_tap_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = hold_tap->source, +#endif }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->tap_behavior_dev, @@ -427,7 +434,9 @@ static int release_hold_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = hold_tap->source, +#endif }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->hold_behavior_dev, @@ -439,7 +448,9 @@ static int release_tap_binding(struct active_hold_tap *hold_tap) { struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = hold_tap->source, +#endif }; struct zmk_behavior_binding binding = {.behavior_dev = hold_tap->config->tap_behavior_dev, @@ -603,8 +614,9 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, return ZMK_BEHAVIOR_OPAQUE; } - struct active_hold_tap *hold_tap = store_hold_tap(event.position, event.source, binding->param1, - binding->param2, event.timestamp, cfg); + struct active_hold_tap *hold_tap = + store_hold_tap(&event, binding->param1, binding->param2, cfg); + if (hold_tap == NULL) { LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", ZMK_BHV_HOLD_TAP_MAX_HELD); diff --git a/app/src/behaviors/behavior_macro.c b/app/src/behaviors/behavior_macro.c index adf3fa65747..c16fb69a9e9 100644 --- a/app/src/behaviors/behavior_macro.c +++ b/app/src/behaviors/behavior_macro.c @@ -158,7 +158,7 @@ static void replace_params(struct behavior_macro_trigger_state *state, state->param2_source = PARAM_SOURCE_BINDING; } -static void queue_macro(uint32_t position, uint8_t source, +static void queue_macro(struct zmk_behavior_binding_event *event, const struct zmk_behavior_binding bindings[], struct behavior_macro_trigger_state state, const struct zmk_behavior_binding *macro_binding) { @@ -170,14 +170,14 @@ static void queue_macro(uint32_t position, uint8_t source, switch (state.mode) { case MACRO_MODE_TAP: - zmk_behavior_queue_add(position, source, binding, true, state.tap_ms); - zmk_behavior_queue_add(position, source, binding, false, state.wait_ms); + zmk_behavior_queue_add(event, binding, true, state.tap_ms); + zmk_behavior_queue_add(event, binding, false, state.wait_ms); break; case MACRO_MODE_PRESS: - zmk_behavior_queue_add(position, source, binding, true, state.wait_ms); + zmk_behavior_queue_add(event, binding, true, state.wait_ms); break; case MACRO_MODE_RELEASE: - zmk_behavior_queue_add(position, source, binding, false, state.wait_ms); + zmk_behavior_queue_add(event, binding, false, state.wait_ms); break; default: LOG_ERR("Unknown macro mode: %d", state.mode); @@ -198,7 +198,7 @@ static int on_macro_binding_pressed(struct zmk_behavior_binding *binding, .start_index = 0, .count = state->press_bindings_count}; - queue_macro(event.position, event.source, cfg->bindings, trigger_state, binding); + queue_macro(&event, cfg->bindings, trigger_state, binding); return ZMK_BEHAVIOR_OPAQUE; } @@ -209,7 +209,7 @@ static int on_macro_binding_released(struct zmk_behavior_binding *binding, const struct behavior_macro_config *cfg = dev->config; struct behavior_macro_state *state = dev->data; - queue_macro(event.position, event.source, cfg->bindings, state->release_state, binding); + queue_macro(&event, cfg->bindings, state->release_state, binding); return ZMK_BEHAVIOR_OPAQUE; } diff --git a/app/src/behaviors/behavior_sensor_rotate_common.c b/app/src/behaviors/behavior_sensor_rotate_common.c index e8fd7c37a23..278f1cb2be7 100644 --- a/app/src/behaviors/behavior_sensor_rotate_common.c +++ b/app/src/behaviors/behavior_sensor_rotate_common.c @@ -90,11 +90,14 @@ int zmk_behavior_sensor_rotate_common_process(struct zmk_behavior_binding *bindi LOG_DBG("Sensor binding: %s", binding->behavior_dev); +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + // set this value so that it always triggers on central, can be handled more properly later + event.source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL; +#endif + for (int i = 0; i < triggers; i++) { - zmk_behavior_queue_add(event.position, ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, - triggered_binding, true, cfg->tap_ms); - zmk_behavior_queue_add(event.position, ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, - triggered_binding, false, 0); + zmk_behavior_queue_add(&event, triggered_binding, true, cfg->tap_ms); + zmk_behavior_queue_add(&event, triggered_binding, false, 0); } return ZMK_BEHAVIOR_OPAQUE; diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index a77ba4d08c4..3faeec53a39 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -40,7 +40,9 @@ struct behavior_sticky_key_config { struct active_sticky_key { uint32_t position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) uint8_t source; +#endif uint32_t param1; uint32_t param2; const struct behavior_sticky_key_config *config; @@ -56,7 +58,7 @@ struct active_sticky_key { struct active_sticky_key active_sticky_keys[ZMK_BHV_STICKY_KEY_MAX_HELD] = {}; -static struct active_sticky_key *store_sticky_key(uint32_t position, uint8_t source, +static struct active_sticky_key *store_sticky_key(struct zmk_behavior_binding_event *event, uint32_t param1, uint32_t param2, const struct behavior_sticky_key_config *config) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { @@ -65,8 +67,10 @@ static struct active_sticky_key *store_sticky_key(uint32_t position, uint8_t sou sticky_key->timer_cancelled) { continue; } - sticky_key->position = position; - sticky_key->source = source; + sticky_key->position = event->position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + sticky_key->source = event->source; +#endif sticky_key->param1 = param1; sticky_key->param2 = param2; sticky_key->config = config; @@ -103,7 +107,9 @@ static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key struct zmk_behavior_binding_event event = { .position = sticky_key->position, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = sticky_key->source, +#endif }; return zmk_behavior_invoke_binding(&binding, event, true); } @@ -118,7 +124,9 @@ static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_k struct zmk_behavior_binding_event event = { .position = sticky_key->position, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = sticky_key->source, +#endif }; clear_sticky_key(sticky_key); @@ -153,8 +161,7 @@ static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding, stop_timer(sticky_key); release_sticky_key_behavior(sticky_key, event.timestamp); } - sticky_key = - store_sticky_key(event.position, event.source, binding->param1, binding->param2, cfg); + sticky_key = store_sticky_key(&event, binding->param1, binding->param2, cfg); if (sticky_key == NULL) { LOG_ERR("unable to store sticky key, did you press more than %d sticky_key?", ZMK_BHV_STICKY_KEY_MAX_HELD); diff --git a/app/src/behaviors/behavior_tap_dance.c b/app/src/behaviors/behavior_tap_dance.c index 606a16393cd..5423f93f7dc 100644 --- a/app/src/behaviors/behavior_tap_dance.c +++ b/app/src/behaviors/behavior_tap_dance.c @@ -35,7 +35,9 @@ struct active_tap_dance { // Tap Dance Data int counter; uint32_t position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) uint8_t source; +#endif uint32_t param1; uint32_t param2; bool is_pressed; @@ -60,15 +62,17 @@ static struct active_tap_dance *find_tap_dance(uint32_t position) { return NULL; } -static int new_tap_dance(uint32_t position, uint8_t source, +static int new_tap_dance(struct zmk_behavior_binding_event *event, const struct behavior_tap_dance_config *config, struct active_tap_dance **tap_dance) { for (int i = 0; i < ZMK_BHV_TAP_DANCE_MAX_HELD; i++) { struct active_tap_dance *const ref_dance = &active_tap_dances[i]; if (ref_dance->position == ZMK_BHV_TAP_DANCE_POSITION_FREE) { ref_dance->counter = 0; - ref_dance->position = position; - ref_dance->source = source; + ref_dance->position = event->position; +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + ref_dance->source = event->source; +#endif ref_dance->config = config; ref_dance->release_at = 0; ref_dance->is_pressed = true; @@ -111,7 +115,9 @@ static inline int press_tap_dance_behavior(struct active_tap_dance *tap_dance, i struct zmk_behavior_binding_event event = { .position = tap_dance->position, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = tap_dance->source, +#endif }; return zmk_behavior_invoke_binding(&binding, event, true); } @@ -122,7 +128,9 @@ static inline int release_tap_dance_behavior(struct active_tap_dance *tap_dance, struct zmk_behavior_binding_event event = { .position = tap_dance->position, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = tap_dance->source, +#endif }; clear_tap_dance(tap_dance); return zmk_behavior_invoke_binding(&binding, event, false); @@ -135,7 +143,7 @@ static int on_tap_dance_binding_pressed(struct zmk_behavior_binding *binding, struct active_tap_dance *tap_dance; tap_dance = find_tap_dance(event.position); if (tap_dance == NULL) { - if (new_tap_dance(event.position, event.source, cfg, &tap_dance) == -ENOMEM) { + if (new_tap_dance(&event, cfg, &tap_dance) == -ENOMEM) { LOG_ERR("Unable to create new tap dance. Insufficient space in active_tap_dances[]."); return ZMK_BEHAVIOR_OPAQUE; } diff --git a/app/src/combo.c b/app/src/combo.c index a990e2f2a60..c3334bdb754 100644 --- a/app/src/combo.c +++ b/app/src/combo.c @@ -291,8 +291,10 @@ static int release_pressed_keys() { static inline int press_combo_behavior(struct combo_cfg *combo, int32_t timestamp) { struct zmk_behavior_binding_event event = { .position = combo->virtual_key_position, - .source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + .source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, +#endif }; last_combo_timestamp = timestamp; @@ -303,8 +305,10 @@ static inline int press_combo_behavior(struct combo_cfg *combo, int32_t timestam static inline int release_combo_behavior(struct combo_cfg *combo, int32_t timestamp) { struct zmk_behavior_binding_event event = { .position = combo->virtual_key_position, - .source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) + .source = ZMK_POSITION_STATE_CHANGE_SOURCE_LOCAL, +#endif }; return zmk_behavior_invoke_binding(&combo->behavior, event, false); diff --git a/app/src/keymap.c b/app/src/keymap.c index d4a4ab1f7de..af94bbfd3f7 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -586,7 +586,9 @@ int zmk_keymap_apply_position_state(uint8_t source, zmk_keymap_layer_id_t layer_ .layer = layer_id, .position = position, .timestamp = timestamp, +#if IS_ENABLED(CONFIG_ZMK_SPLIT) .source = source, +#endif }; LOG_DBG("layer_id: %d position: %d, binding name: %s", layer_id, position, From 8166527ea35923d8be6278b9d1727285dd504d3c Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Fri, 9 Aug 2024 11:31:09 -0700 Subject: [PATCH 07/42] fix(docs): Remove split locality issue note --- docs/docs/features/split-keyboards.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/docs/features/split-keyboards.md b/docs/docs/features/split-keyboards.md index 8c69d51a8db..ff9397f7dd4 100644 --- a/docs/docs/features/split-keyboards.md +++ b/docs/docs/features/split-keyboards.md @@ -86,11 +86,6 @@ These behaviors only affect the keyboard part that they are invoked from: - [Reset behaviors](../keymaps/behaviors/reset.md) -:::warning[Nesting behaviors with locality] -Currently there is [an issue](https://github.com/zmkfirmware/zmk/issues/1494) preventing both global and source locality behaviors from working as expected if they are invoked from another behavior, such as a hold-tap, tap dance or a mod-morph. -For this reason it is recommended that these behaviors are placed directly on a keymap layer. -::: - :::note[Peripheral invocation] Peripherals must be paired and connected to the central in order to be able to activate these behaviors, even if it is possible to trigger the behavior using only keys on a particular peripheral. This is because the key bindings are processed on the central side which would then instruct the peripheral side to run the behavior's effect. From f992352936f6556da8b343a34e75ac61514d0ecf Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 23 Sep 2024 10:28:56 -0600 Subject: [PATCH 08/42] chore: Formatting fix. --- app/src/behavior_queue.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/behavior_queue.c b/app/src/behavior_queue.c index 86837f42332..82c58ca8548 100644 --- a/app/src/behavior_queue.c +++ b/app/src/behavior_queue.c @@ -35,11 +35,10 @@ static void behavior_queue_process_next(struct k_work *work) { LOG_DBG("Invoking %s: 0x%02x 0x%02x", item.binding.behavior_dev, item.binding.param1, item.binding.param2); - struct zmk_behavior_binding_event event = { - .position = item.position, - .timestamp = k_uptime_get(), + struct zmk_behavior_binding_event event = {.position = item.position, + .timestamp = k_uptime_get(), #if IS_ENABLED(CONFIG_ZMK_SPLIT) - .source = item.source + .source = item.source #endif }; From 33e3b02ddb0509a38b39dc565f21fdc17553ff0c Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 31 Jul 2024 11:54:15 -0600 Subject: [PATCH 09/42] feat: Split physical layout selection sync. * Ensure the split peripherals have the same selected physical layout on connection and change. --- app/include/zmk/physical_layouts.h | 7 +++ app/include/zmk/split/bluetooth/uuid.h | 1 + app/src/physical_layouts.c | 11 +++- app/src/split/bluetooth/central.c | 82 +++++++++++++++++++++++++- app/src/split/bluetooth/service.c | 43 +++++++++++++- 5 files changed, 141 insertions(+), 3 deletions(-) diff --git a/app/include/zmk/physical_layouts.h b/app/include/zmk/physical_layouts.h index e78602e3811..33004af738f 100644 --- a/app/include/zmk/physical_layouts.h +++ b/app/include/zmk/physical_layouts.h @@ -8,6 +8,13 @@ #include #include +#include + +struct zmk_physical_layout_selection_changed { + uint8_t selection; +}; + +ZMK_EVENT_DECLARE(zmk_physical_layout_selection_changed); struct zmk_key_physical_attrs { int16_t width; diff --git a/app/include/zmk/split/bluetooth/uuid.h b/app/include/zmk/split/bluetooth/uuid.h index dccdfc804c5..4a653c73b83 100644 --- a/app/include/zmk/split/bluetooth/uuid.h +++ b/app/include/zmk/split/bluetooth/uuid.h @@ -18,3 +18,4 @@ #define ZMK_SPLIT_BT_CHAR_RUN_BEHAVIOR_UUID ZMK_BT_SPLIT_UUID(0x00000002) #define ZMK_SPLIT_BT_CHAR_SENSOR_STATE_UUID ZMK_BT_SPLIT_UUID(0x00000003) #define ZMK_SPLIT_BT_UPDATE_HID_INDICATORS_UUID ZMK_BT_SPLIT_UUID(0x00000004) +#define ZMK_SPLIT_BT_SELECT_PHYS_LAYOUT_UUID ZMK_BT_SPLIT_UUID(0x00000005) diff --git a/app/src/physical_layouts.c b/app/src/physical_layouts.c index c71b427a4dd..59077ede27e 100644 --- a/app/src/physical_layouts.c +++ b/app/src/physical_layouts.c @@ -22,6 +22,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include +ZMK_EVENT_IMPL(zmk_physical_layout_selection_changed); + #define DT_DRV_COMPAT zmk_physical_layout #define USE_PHY_LAYOUTS \ @@ -247,7 +249,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) { diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 9c459bf1b1d..21ff611f568 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -30,6 +30,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include #include +#include static int start_scanning(void); @@ -56,6 +57,7 @@ struct peripheral_slot { #if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) uint16_t update_hid_indicators; #endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) + uint16_t selected_physical_layout_handle; uint8_t position_state[POSITION_STATE_DATA_LEN]; uint8_t changed_positions[POSITION_STATE_DATA_LEN]; }; @@ -141,6 +143,7 @@ int release_peripheral_slot(int index) { // Clean up previously discovered handles; slot->subscribe_params.value_handle = 0; slot->run_behavior_handle = 0; + slot->selected_physical_layout_handle = 0; #if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) slot->update_hid_indicators = 0; #endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) @@ -392,6 +395,46 @@ static int split_central_subscribe(struct bt_conn *conn, struct bt_gatt_subscrib return err; } +static int update_peripheral_selected_layout(struct peripheral_slot *slot, uint8_t layout_idx) { + if (slot->state != PERIPHERAL_SLOT_STATE_CONNECTED) { + return -ENOTCONN; + } + + if (slot->selected_physical_layout_handle == 0) { + // It appears that sometimes the peripheral is considered connected + // before the GATT characteristics have been discovered. If this is + // the case, the selected_physical_layout_handle will not yet be set. + return -EAGAIN; + } + + if (bt_conn_get_security(slot->conn) < BT_SECURITY_L2) { + return -EAGAIN; + } + + int err = bt_gatt_write_without_response(slot->conn, slot->selected_physical_layout_handle, + &layout_idx, sizeof(layout_idx), true); + + if (err < 0) { + LOG_ERR("Failed to write physical layout index to peripheral (err %d)", err); + } + + return err; +} + +static void update_peripherals_selected_physical_layout(struct k_work *_work) { + uint8_t layout_idx = zmk_physical_layouts_get_selected(); + for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) { + if (peripherals[i].state != PERIPHERAL_SLOT_STATE_CONNECTED) { + continue; + } + + update_peripheral_selected_layout(&peripherals[i], layout_idx); + } +} + +K_WORK_DEFINE(update_peripherals_selected_layouts_work, + update_peripherals_selected_physical_layout); + static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, struct bt_gatt_discover_params *params) { @@ -442,6 +485,11 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn, slot->discover_params.uuid = NULL; slot->discover_params.start_handle = attr->handle + 2; slot->run_behavior_handle = bt_gatt_attr_value_handle(attr); + } else if (!bt_uuid_cmp(((struct bt_gatt_chrc *)attr->user_data)->uuid, + BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SELECT_PHYS_LAYOUT_UUID))) { + LOG_DBG("Found select physical layout handle"); + slot->selected_physical_layout_handle = bt_gatt_attr_value_handle(attr); + k_work_submit(&update_peripherals_selected_layouts_work); #if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) } else if (!bt_uuid_cmp(((struct bt_gatt_chrc *)attr->user_data)->uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_UPDATE_HID_INDICATORS_UUID))) { @@ -467,7 +515,8 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn, #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING) */ } - bool subscribed = slot->run_behavior_handle && slot->subscribe_params.value_handle; + bool subscribed = slot->run_behavior_handle && slot->subscribe_params.value_handle && + slot->selected_physical_layout_handle; #if ZMK_KEYMAP_HAS_SENSORS subscribed = subscribed && slot->sensor_subscribe_params.value_handle; @@ -739,9 +788,30 @@ static void split_central_disconnected(struct bt_conn *conn, uint8_t reason) { start_scanning(); } +static void split_central_security_changed(struct bt_conn *conn, bt_security_t level, + enum bt_security_err err) { + struct peripheral_slot *slot = peripheral_slot_for_conn(conn); + if (!slot || !slot->selected_physical_layout_handle) { + return; + } + + if (err > 0) { + LOG_DBG("Skipping updating the physical layout for peripheral with security error"); + return; + } + + if (level < BT_SECURITY_L2) { + LOG_DBG("Skipping updating the physical layout for peripheral with insufficient security"); + return; + } + + k_work_submit(&update_peripherals_selected_layouts_work); +} + static struct bt_conn_cb conn_callbacks = { .connected = split_central_connected, .disconnected = split_central_disconnected, + .security_changed = split_central_security_changed, }; K_THREAD_STACK_DEFINE(split_central_split_run_q_stack, @@ -898,3 +968,13 @@ static int zmk_split_bt_central_init(void) { } SYS_INIT(zmk_split_bt_central_init, APPLICATION, CONFIG_ZMK_BLE_INIT_PRIORITY); + +static int zmk_split_bt_central_listener_cb(const zmk_event_t *eh) { + if (as_zmk_physical_layout_selection_changed(eh)) { + k_work_submit(&update_peripherals_selected_layouts_work); + } + return ZMK_EV_EVENT_BUBBLE; +} + +ZMK_LISTENER(zmk_split_bt_central, zmk_split_bt_central_listener_cb); +ZMK_SUBSCRIPTION(zmk_split_bt_central, zmk_physical_layout_selection_changed); \ No newline at end of file diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index 505eb363cd8..9529d51613c 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -19,6 +19,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include #include +#include #include #include @@ -138,6 +139,42 @@ static ssize_t split_svc_update_indicators(struct bt_conn *conn, const struct bt #endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) +static uint8_t selected_phys_layout = 0; + +static void split_svc_select_phys_layout_callback(struct k_work *work) { + LOG_DBG("Selecting physical layout after GATT write of %d", selected_phys_layout); + zmk_physical_layouts_select(selected_phys_layout); +} + +static K_WORK_DEFINE(split_svc_select_phys_layout_work, split_svc_select_phys_layout_callback); + +static ssize_t split_svc_select_phys_layout(struct bt_conn *conn, const struct bt_gatt_attr *attr, + const void *buf, uint16_t len, uint16_t offset, + uint8_t flags) { + if (offset + len > sizeof(uint8_t) || len == 0) { + return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); + } + + selected_phys_layout = *(uint8_t *)buf; + + k_work_submit(&split_svc_select_phys_layout_work); + + return len; +} + +static ssize_t split_svc_get_selected_phys_layout(struct bt_conn *conn, + const struct bt_gatt_attr *attrs, void *buf, + uint16_t len, uint16_t offset) { + int selected_ret = zmk_physical_layouts_get_selected(); + if (selected_ret < 0) { + return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); + } + + uint8_t selected = (uint8_t)selected_ret; + + return bt_gatt_attr_read(conn, attrs, buf, len, offset, &selected, sizeof(selected)); +} + BT_GATT_SERVICE_DEFINE( split_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)), BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), @@ -160,7 +197,11 @@ BT_GATT_SERVICE_DEFINE( BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_WRITE_ENCRYPT, NULL, split_svc_update_indicators, NULL), #endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS) -); + BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SELECT_PHYS_LAYOUT_UUID), + BT_GATT_CHRC_WRITE | BT_GATT_CHRC_READ, + BT_GATT_PERM_WRITE_ENCRYPT | BT_GATT_PERM_READ_ENCRYPT, + split_svc_get_selected_phys_layout, split_svc_select_phys_layout, + NULL), ); K_THREAD_STACK_DEFINE(service_q_stack, CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_STACK_SIZE); From 58dcf5c28520def16d00fa615c412cddc0151760 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:30:45 +0100 Subject: [PATCH 10/42] feat(power): Support multiple ext_power GPIOS --- app/src/ext_power_generic.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index 17b3ba64026..3975e038a0d 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -22,7 +22,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct ext_power_generic_config { - const struct gpio_dt_spec control; + const struct gpio_dt_spec *control; + const size_t control_gpios_count; const uint16_t init_delay_ms; }; @@ -59,9 +60,12 @@ static int ext_power_generic_enable(const struct device *dev) { struct ext_power_generic_data *data = dev->data; const struct ext_power_generic_config *config = dev->config; - if (gpio_pin_set_dt(&config->control, 1)) { - LOG_WRN("Failed to set ext-power control pin"); - return -EIO; + for (int i = 0; i < config->control_gpios_count; i++) { + const struct gpio_dt_spec *gpio = &config->control[i]; + if (gpio_pin_set_dt(gpio, 1)) { + LOG_WRN("Failed to set ext-power control pin %d", i); + return -EIO; + } } data->status = true; return ext_power_save_state(); @@ -71,10 +75,12 @@ static int ext_power_generic_disable(const struct device *dev) { struct ext_power_generic_data *data = dev->data; const struct ext_power_generic_config *config = dev->config; - if (gpio_pin_set_dt(&config->control, 0)) { - LOG_WRN("Failed to set ext-power control pin"); - LOG_WRN("Failed to clear ext-power control pin"); - return -EIO; + for (int i = 0; i < config->control_gpios_count; i++) { + const struct gpio_dt_spec *gpio = &config->control[i]; + if (gpio_pin_set_dt(gpio, 0)) { + LOG_WRN("Failed to clear ext-power control pin %d", i); + return -EIO; + } } data->status = false; return ext_power_save_state(); @@ -144,9 +150,12 @@ SETTINGS_STATIC_HANDLER_DEFINE(ext_power, "ext_power/state", NULL, ext_power_set static int ext_power_generic_init(const struct device *dev) { const struct ext_power_generic_config *config = dev->config; - if (gpio_pin_configure_dt(&config->control, GPIO_OUTPUT_INACTIVE)) { - LOG_ERR("Failed to configure ext-power control pin"); - return -EIO; + for (int i = 0; i < config->control_gpios_count; i++) { + const struct gpio_dt_spec *gpio = &config->control[i]; + if (gpio_pin_configure_dt(gpio, GPIO_OUTPUT_INACTIVE)) { + LOG_ERR("Failed to configure ext-power control pin %d", i); + return -EIO; + } } #if IS_ENABLED(CONFIG_SETTINGS) @@ -178,8 +187,12 @@ static int ext_power_generic_pm_action(const struct device *dev, enum pm_device_ } #endif /* CONFIG_PM_DEVICE */ +static const struct gpio_dt_spec ext_power_control_gpios[DT_INST_PROP_LEN(0, control_gpios)] = { + DT_INST_FOREACH_PROP_ELEM_SEP(0, control_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))}; + static const struct ext_power_generic_config config = { - .control = GPIO_DT_SPEC_INST_GET(0, control_gpios), + .control = ext_power_control_gpios, + .control_gpios_count = DT_INST_PROP_LEN(0, control_gpios), .init_delay_ms = DT_INST_PROP_OR(0, init_delay_ms, 0)}; static struct ext_power_generic_data data = { From 17f0a4d307700e278e53548cecb04bb49803b515 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:35:42 +0100 Subject: [PATCH 11/42] feat(ble): Set device name at runtime This allows for the device name to be set at runtime, possible uses for this include a custom display screen that lets you type it in using the keycode state event, future configuration in zmk studio, or altering it per profile as per #1169 --- app/Kconfig | 1 + app/include/zmk/ble.h | 2 ++ app/src/ble.c | 28 ++++++++++++++++--- .../snapshot.log | 2 -- .../bond-to-cleared-profile/snapshot.log | 2 -- .../snapshot.log | 1 - .../dont-bond-to-taken-profile/snapshot.log | 2 -- .../snapshot.log | 2 -- .../snapshot.log | 2 -- .../snapshot.log | 2 -- .../snapshot.log | 1 - .../snapshot.log | 1 - 12 files changed, 27 insertions(+), 19 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index 108fcbe7096..b0ffc72ac02 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -153,6 +153,7 @@ menuconfig ZMK_BLE select BT_SMP_APP_PAIRING_ACCEPT select BT_PERIPHERAL select BT_DIS + imply BT_DEVICE_NAME_DYNAMIC imply BT_SETTINGS if !ARCH_POSIX imply SETTINGS if !ARCH_POSIX imply ZMK_BATTERY_REPORTING if !ARCH_POSIX diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index cc55a6ce142..c44c5e16869 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -39,6 +39,8 @@ char *zmk_ble_active_profile_name(void); int zmk_ble_unpair_all(void); +int zmk_ble_set_device_name(char *name); + #if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) int zmk_ble_put_peripheral_addr(const bt_addr_le_t *addr); #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) */ diff --git a/app/src/ble.c b/app/src/ble.c index 9ecfb7ec394..e63c63b0cca 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -56,8 +56,9 @@ enum advertising_type { #define CURR_ADV(adv) (adv << 4) #define ZMK_ADV_CONN_NAME \ - BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME, BT_GAP_ADV_FAST_INT_MIN_2, \ - BT_GAP_ADV_FAST_INT_MAX_2, NULL) + BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | BT_LE_ADV_OPT_USE_NAME | \ + BT_LE_ADV_OPT_FORCE_NAME_IN_AD, \ + BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, NULL) static struct zmk_ble_profile profiles[ZMK_BLE_PROFILE_COUNT]; static uint8_t active_profile; @@ -67,8 +68,7 @@ static uint8_t active_profile; BUILD_ASSERT(DEVICE_NAME_LEN <= 16, "ERROR: BLE device name is too long. Max length: 16"); -static const struct bt_data zmk_ble_ad[] = { - BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), +static struct bt_data zmk_ble_ad[] = { BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03), BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_SOME, 0x12, 0x18, /* HID Service */ @@ -335,6 +335,26 @@ struct bt_conn *zmk_ble_active_profile_conn(void) { char *zmk_ble_active_profile_name(void) { return profiles[active_profile].name; } +int zmk_ble_set_device_name(char *name) { + // Copy new name to advertising parameters + int err = bt_set_name(name); + LOG_DBG("New device name: %s", name); + if (err) { + LOG_ERR("Failed to set new device name (err %d)", err); + return err; + } + if (advertising_status == ZMK_ADV_CONN) { + // Stop current advertising so it can restart with new name + err = bt_le_adv_stop(); + advertising_status = ZMK_ADV_NONE; + if (err) { + LOG_ERR("Failed to stop advertising (err %d)", err); + return err; + } + } + return update_advertising(); +} + #if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) int zmk_ble_put_peripheral_addr(const bt_addr_le_t *addr) { diff --git a/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log b/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log index 077634f249d..c7a0884d4f7 100644 --- a/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log +++ b/app/tests/ble/profiles/bond-clear-then-bond-second-client/snapshot.log @@ -2,7 +2,6 @@ profile 0 bt_id: No static addresses stored in controller profile 0 ble_central: main: [Bluetooth initialized] profile 0 ble_central: start_scan: [Scanning successfully started] profile 0 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 0 ble_central: eir_found: [AD]: 9 data_len 0 profile 0 ble_central: eir_found: [AD]: 25 data_len 2 profile 0 ble_central: eir_found: [AD]: 1 data_len 1 profile 0 ble_central: eir_found: [AD]: 2 data_len 4 @@ -13,7 +12,6 @@ profile 1 bt_id: No static addresses stored in controller profile 1 ble_central: main: [Bluetooth initialized] profile 1 ble_central: start_scan: [Scanning successfully started] profile 1 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 1 ble_central: eir_found: [AD]: 9 data_len 0 profile 1 ble_central: eir_found: [AD]: 25 data_len 2 profile 1 ble_central: eir_found: [AD]: 1 data_len 1 profile 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log b/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log index 077634f249d..c7a0884d4f7 100644 --- a/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log +++ b/app/tests/ble/profiles/bond-to-cleared-profile/snapshot.log @@ -2,7 +2,6 @@ profile 0 bt_id: No static addresses stored in controller profile 0 ble_central: main: [Bluetooth initialized] profile 0 ble_central: start_scan: [Scanning successfully started] profile 0 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 0 ble_central: eir_found: [AD]: 9 data_len 0 profile 0 ble_central: eir_found: [AD]: 25 data_len 2 profile 0 ble_central: eir_found: [AD]: 1 data_len 1 profile 0 ble_central: eir_found: [AD]: 2 data_len 4 @@ -13,7 +12,6 @@ profile 1 bt_id: No static addresses stored in controller profile 1 ble_central: main: [Bluetooth initialized] profile 1 ble_central: start_scan: [Scanning successfully started] profile 1 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 1 ble_central: eir_found: [AD]: 9 data_len 0 profile 1 ble_central: eir_found: [AD]: 25 data_len 2 profile 1 ble_central: eir_found: [AD]: 1 data_len 1 profile 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log b/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log index 62cb2d6d92f..61f3e09e1c2 100644 --- a/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log +++ b/app/tests/ble/profiles/connnect-and-output-to-selection/snapshot.log @@ -2,7 +2,6 @@ ble_central: main: [Bluetooth initialized] ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log b/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log index 6ea4fc721b9..d754b9c4807 100644 --- a/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log +++ b/app/tests/ble/profiles/dont-bond-to-taken-profile/snapshot.log @@ -2,7 +2,6 @@ profile 0 bt_id: No static addresses stored in controller profile 0 ble_central: main: [Bluetooth initialized] profile 0 ble_central: start_scan: [Scanning successfully started] profile 0 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 0 ble_central: eir_found: [AD]: 9 data_len 0 profile 0 ble_central: eir_found: [AD]: 25 data_len 2 profile 0 ble_central: eir_found: [AD]: 1 data_len 1 profile 0 ble_central: eir_found: [AD]: 2 data_len 4 @@ -13,7 +12,6 @@ profile 1 bt_id: No static addresses stored in controller profile 1 ble_central: main: [Bluetooth initialized] profile 1 ble_central: start_scan: [Scanning successfully started] profile 1 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 1 ble_central: eir_found: [AD]: 9 data_len 0 profile 1 ble_central: eir_found: [AD]: 25 data_len 2 profile 1 ble_central: eir_found: [AD]: 1 data_len 1 profile 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log index 1a88748d1df..bc345b0bfb6 100644 --- a/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log +++ b/app/tests/ble/profiles/first-and-second-profile-paired-then-send-data/snapshot.log @@ -2,7 +2,6 @@ profile 0 bt_id: No static addresses stored in controller profile 0 ble_central: main: [Bluetooth initialized] profile 0 ble_central: start_scan: [Scanning successfully started] profile 0 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 0 ble_central: eir_found: [AD]: 9 data_len 0 profile 0 ble_central: eir_found: [AD]: 25 data_len 2 profile 0 ble_central: eir_found: [AD]: 1 data_len 1 profile 0 ble_central: eir_found: [AD]: 2 data_len 4 @@ -22,7 +21,6 @@ profile 0 00 00 04 00 00 00 00 00 |. profile 0 ble_central: notify_func: payload profile 0 00 00 00 00 00 00 00 00 |........ profile 1 ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 -profile 1 ble_central: eir_found: [AD]: 9 data_len 0 profile 1 ble_central: eir_found: [AD]: 25 data_len 2 profile 1 ble_central: eir_found: [AD]: 1 data_len 1 profile 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log index 6c0bac58898..e54d7092395 100644 --- a/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log +++ b/app/tests/ble/profiles/overwrite-enabled-reconnect-without-bond-then-output-to-selection/snapshot.log @@ -2,7 +2,6 @@ ble_central: main: [Bluetooth initialized] ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 @@ -12,7 +11,6 @@ ble_central: disconnected: [Disconnected]: FD:9E:B2:48:47:39 (random) (reason 0x16) ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log b/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log index 2323de6faae..c6f2d914508 100644 --- a/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log +++ b/app/tests/ble/profiles/reconnect-then-output-to-selection/snapshot.log @@ -2,7 +2,6 @@ ble_central: main: [Bluetooth initialized] ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 @@ -12,7 +11,6 @@ ble_central: disconnected: [Disconnected]: FD:9E:B2:48:47:39 (random) (reason 0x16) ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/security/read-hid-after-connect-with-auto-sec/snapshot.log b/app/tests/ble/security/read-hid-after-connect-with-auto-sec/snapshot.log index b8ee29eb257..fa40c20a67b 100644 --- a/app/tests/ble/security/read-hid-after-connect-with-auto-sec/snapshot.log +++ b/app/tests/ble/security/read-hid-after-connect-with-auto-sec/snapshot.log @@ -2,7 +2,6 @@ ble_central: main: [Bluetooth initialized] ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 diff --git a/app/tests/ble/security/read-hid-after-connect-without-auto-sec/snapshot.log b/app/tests/ble/security/read-hid-after-connect-without-auto-sec/snapshot.log index 2157fd035d6..e32f76afb7c 100644 --- a/app/tests/ble/security/read-hid-after-connect-without-auto-sec/snapshot.log +++ b/app/tests/ble/security/read-hid-after-connect-without-auto-sec/snapshot.log @@ -2,7 +2,6 @@ ble_central: main: [Bluetooth initialized] ble_central: start_scan: [Scanning successfully started] ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -59 - ble_central: eir_found: [AD]: 9 data_len 0 ble_central: eir_found: [AD]: 25 data_len 2 ble_central: eir_found: [AD]: 1 data_len 1 ble_central: eir_found: [AD]: 2 data_len 4 From 21e1b2acad171536923777433f08fb8313eaab7f Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 25 Sep 2024 11:06:52 -0600 Subject: [PATCH 12/42] feat: Add RPC thread analysis support. --- app/src/studio/rpc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/studio/rpc.c b/app/src/studio/rpc.c index bd980eb4605..7b8dd605d29 100644 --- a/app/src/studio/rpc.c +++ b/app/src/studio/rpc.c @@ -11,6 +11,7 @@ #include #include +#include #include LOG_MODULE_REGISTER(zmk_studio, CONFIG_ZMK_STUDIO_LOG_LEVEL); @@ -215,6 +216,9 @@ static void rpc_main(void) { for (;;) { pb_istream_t stream = pb_istream_for_rx_ring_buf(); zmk_studio_Request req = zmk_studio_Request_init_zero; +#if IS_ENABLED(CONFIG_THREAD_ANALYZER) + thread_analyzer_print(); +#endif // IS_ENABLED(CONFIG_THREAD_ANALYZER) bool status = pb_decode(&stream, &zmk_studio_Request_msg, &req); rpc_framing_state = FRAMING_STATE_IDLE; @@ -223,6 +227,9 @@ static void rpc_main(void) { zmk_studio_Response resp = handle_request(&req); int err = send_response(&resp); +#if IS_ENABLED(CONFIG_THREAD_ANALYZER) + thread_analyzer_print(); +#endif // IS_ENABLED(CONFIG_THREAD_ANALYZER) if (err < 0) { LOG_ERR("Failed to send the RPC response %d", err); } From 5d4b6df6a7d5bc29675d016d63e0bef899f29a99 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 25 Sep 2024 16:31:23 -0600 Subject: [PATCH 13/42] feat(studio): Log entry into all RPC. --- app/src/studio/behavior_subsystem.c | 4 +++- app/src/studio/core_subsystem.c | 3 +++ app/src/studio/keymap_subsystem.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/studio/behavior_subsystem.c b/app/src/studio/behavior_subsystem.c index b8d1ef1d67a..96c1f236e67 100644 --- a/app/src/studio/behavior_subsystem.c +++ b/app/src/studio/behavior_subsystem.c @@ -33,6 +33,7 @@ static bool encode_behavior_summaries(pb_ostream_t *stream, const pb_field_t *fi } zmk_studio_Response list_all_behaviors(const zmk_studio_Request *req) { + LOG_DBG(""); zmk_behaviors_ListAllBehaviorsResponse beh_resp = zmk_behaviors_ListAllBehaviorsResponse_init_zero; beh_resp.behaviors.funcs.encode = encode_behavior_summaries; @@ -164,9 +165,10 @@ static struct encode_metadata_sets_state state = {}; zmk_studio_Response get_behavior_details(const zmk_studio_Request *req) { uint32_t behavior_id = req->subsystem.behaviors.request_type.get_behavior_details.behavior_id; - const char *behavior_name = zmk_behavior_find_behavior_name_from_local_id(behavior_id); + LOG_DBG("behavior_id %d, name %s", behavior_id, behavior_name); + if (!behavior_name) { LOG_WRN("No behavior found for ID %d", behavior_id); return ZMK_RPC_SIMPLE_ERR(GENERIC); diff --git a/app/src/studio/core_subsystem.c b/app/src/studio/core_subsystem.c index 2cdc9d7ce48..1739919a62f 100644 --- a/app/src/studio/core_subsystem.c +++ b/app/src/studio/core_subsystem.c @@ -45,6 +45,7 @@ static bool encode_device_info_serial_number(pb_ostream_t *stream, const pb_fiel #endif // IS_ENABLED(CONFIG_HWINFO) zmk_studio_Response get_device_info(const zmk_studio_Request *req) { + LOG_DBG(""); zmk_core_GetDeviceInfoResponse resp = zmk_core_GetDeviceInfoResponse_init_zero; resp.name.funcs.encode = encode_device_info_name; @@ -56,12 +57,14 @@ zmk_studio_Response get_device_info(const zmk_studio_Request *req) { } zmk_studio_Response get_lock_state(const zmk_studio_Request *req) { + LOG_DBG(""); zmk_core_LockState resp = zmk_studio_core_get_lock_state(); return CORE_RESPONSE(get_lock_state, resp); } zmk_studio_Response reset_settings(const zmk_studio_Request *req) { + LOG_DBG(""); ZMK_RPC_SUBSYSTEM_SETTINGS_RESET_FOREACH(sub) { int ret = sub->callback(); if (ret < 0) { diff --git a/app/src/studio/keymap_subsystem.c b/app/src/studio/keymap_subsystem.c index d734afb6029..25297b63c8d 100644 --- a/app/src/studio/keymap_subsystem.c +++ b/app/src/studio/keymap_subsystem.c @@ -98,6 +98,7 @@ static bool encode_keymap_layers(pb_ostream_t *stream, const pb_field_t *field, } zmk_studio_Response get_keymap(const zmk_studio_Request *req) { + LOG_DBG(""); zmk_keymap_Keymap resp = zmk_keymap_Keymap_init_zero; resp.layers.funcs.encode = encode_keymap_layers; @@ -117,6 +118,7 @@ zmk_studio_Response get_keymap(const zmk_studio_Request *req) { } zmk_studio_Response set_layer_binding(const zmk_studio_Request *req) { + LOG_DBG(""); const zmk_keymap_SetLayerBindingRequest *set_req = &req->subsystem.keymap.request_type.set_layer_binding; @@ -165,6 +167,7 @@ zmk_studio_Response set_layer_binding(const zmk_studio_Request *req) { } zmk_studio_Response check_unsaved_changes(const zmk_studio_Request *req) { + LOG_DBG(""); int layout_changes = zmk_physical_layouts_check_unsaved_selection(); int keymap_changes = zmk_keymap_check_unsaved_changes(); @@ -172,6 +175,7 @@ zmk_studio_Response check_unsaved_changes(const zmk_studio_Request *req) { } zmk_studio_Response save_changes(const zmk_studio_Request *req) { + LOG_DBG(""); int ret = zmk_physical_layouts_save_selected(); if (ret < 0) { @@ -192,6 +196,7 @@ zmk_studio_Response save_changes(const zmk_studio_Request *req) { } zmk_studio_Response discard_changes(const zmk_studio_Request *req) { + LOG_DBG(""); int ret = zmk_physical_layouts_revert_selected(); if (ret < 0) { return ZMK_RPC_SIMPLE_ERR(GENERIC); @@ -288,6 +293,7 @@ static bool encode_layouts(pb_ostream_t *stream, const pb_field_t *field, void * } zmk_studio_Response get_physical_layouts(const zmk_studio_Request *req) { + LOG_DBG(""); zmk_keymap_PhysicalLayouts resp = zmk_keymap_PhysicalLayouts_init_zero; resp.active_layout_index = zmk_physical_layouts_get_selected(); resp.layouts.funcs.encode = encode_layouts; @@ -336,6 +342,7 @@ static void migrate_keymap(const uint8_t old) { } zmk_studio_Response set_active_physical_layout(const zmk_studio_Request *req) { + LOG_DBG(""); uint8_t index = (uint8_t)req->subsystem.keymap.request_type.set_active_physical_layout; int old = zmk_physical_layouts_get_selected(); @@ -364,6 +371,7 @@ zmk_studio_Response set_active_physical_layout(const zmk_studio_Request *req) { } zmk_studio_Response move_layer(const zmk_studio_Request *req) { + LOG_DBG(""); const zmk_keymap_MoveLayerRequest *move_req = &req->subsystem.keymap.request_type.move_layer; zmk_keymap_MoveLayerResponse resp = zmk_keymap_MoveLayerResponse_init_zero; @@ -386,6 +394,7 @@ zmk_studio_Response move_layer(const zmk_studio_Request *req) { } zmk_studio_Response add_layer(const zmk_studio_Request *req) { + LOG_DBG(""); // Use a static here to keep the value valid during serialization static zmk_keymap_layer_id_t layer_id = 0; @@ -428,6 +437,7 @@ zmk_studio_Response add_layer(const zmk_studio_Request *req) { } zmk_studio_Response remove_layer(const zmk_studio_Request *req) { + LOG_DBG(""); const zmk_keymap_RemoveLayerRequest *rm_req = &req->subsystem.keymap.request_type.remove_layer; zmk_keymap_RemoveLayerResponse resp = zmk_keymap_RemoveLayerResponse_init_zero; @@ -456,6 +466,7 @@ zmk_studio_Response remove_layer(const zmk_studio_Request *req) { } zmk_studio_Response restore_layer(const zmk_studio_Request *req) { + LOG_DBG(""); const zmk_keymap_RestoreLayerRequest *restore_req = &req->subsystem.keymap.request_type.restore_layer; @@ -492,6 +503,7 @@ zmk_studio_Response restore_layer(const zmk_studio_Request *req) { } zmk_studio_Response set_layer_props(const zmk_studio_Request *req) { + LOG_DBG(""); const zmk_keymap_SetLayerPropsRequest *set_req = &req->subsystem.keymap.request_type.set_layer_props; From 4a8ceba0db8bcd9c1ffda85d14f4b40080cae7fe Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 25 Sep 2024 18:11:31 -0600 Subject: [PATCH 14/42] chore: Fix keymap const warning. --- app/src/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/keymap.c b/app/src/keymap.c index af94bbfd3f7..ad3c7278a21 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -581,7 +581,7 @@ int zmk_keymap_reset_settings(void) { return -ENOTSUP; } int zmk_keymap_apply_position_state(uint8_t source, zmk_keymap_layer_id_t layer_id, uint32_t position, bool pressed, int64_t timestamp) { - struct zmk_behavior_binding *binding = &zmk_keymap[layer_id][position]; + const struct zmk_behavior_binding *binding = &zmk_keymap[layer_id][position]; struct zmk_behavior_binding_event event = { .layer = layer_id, .position = position, From a17266847dcd5e3e202ed7eb559665f22a10b86e Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Thu, 26 Sep 2024 10:01:14 -0600 Subject: [PATCH 15/42] fix: Force Ubuntu 22.04, pending CI fixes. --- .github/workflows/build-user-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index c3e4789dc5d..7b4f10b0b09 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -26,7 +26,7 @@ on: jobs: matrix: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 name: Fetch Build Keyboards outputs: build_matrix: ${{ env.build_matrix }} From 1f900bfc9cd8d8946c8855d1ca869dffa45e2a1f Mon Sep 17 00:00:00 2001 From: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:49:13 +0200 Subject: [PATCH 16/42] docs: Added a note on bluetooth profiles under "unable to connect to device" (#2509) * docs: Added a note on bluetooth profiles under "unable to connect to device" Co-authored-by: Cem Aksoylar --------- Co-authored-by: Cem Aksoylar --- docs/docs/troubleshooting/connection-issues.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/docs/troubleshooting/connection-issues.mdx b/docs/docs/troubleshooting/connection-issues.mdx index a57a3d205f7..7de953a96ca 100644 --- a/docs/docs/troubleshooting/connection-issues.mdx +++ b/docs/docs/troubleshooting/connection-issues.mdx @@ -97,6 +97,10 @@ The settings reset firmware has Bluetooth disabled to prevent the two sides from ## Unable to Connect to Device +### Bluetooth Profiles + +A very common issue is that the wrong Bluetooth profile has been selected, or the Bluetooth profile already has a saved connection. Learn more about Bluetooth profiles [here](../features/bluetooth.md), and learn how to adjust Bluetooth profiles via the `&bt` behavior [here](../keymaps/behaviors/bluetooth.md). + ### Additional Bluetooth Options Some devices and operating systems may have additional restrictions that they require be met before allowing a bluetooth peripheral to pair with them. If your keyboard is visible to your host but you are having issues trouble connecting or no input is registered, this might be the cause. Some of ZMK's [experimental bluetooth settings](../config/bluetooth.md) may suffice to resolve the issue. In particular: From 0a25fa2f95c0d7f5c93ad15ff12f634b11ec2537 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:57:02 +0100 Subject: [PATCH 17/42] feat(boards): add common keyboard layouts --- .../layouts/common/60percent/60percent.dtsi | 72 ++++++++++++++ app/dts/layouts/common/60percent/all1u.dtsi | 77 +++++++++++++++ app/dts/layouts/common/60percent/ansi.dtsi | 72 ++++++++++++++ app/dts/layouts/common/60percent/hhkb.dtsi | 71 ++++++++++++++ app/dts/layouts/common/60percent/iso.dtsi | 73 ++++++++++++++ .../layouts/common/65percent/65percent.dtsi | 72 ++++++++++++++ app/dts/layouts/common/65percent/all1u.dtsi | 85 ++++++++++++++++ app/dts/layouts/common/65percent/ansi.dtsi | 79 +++++++++++++++ app/dts/layouts/common/65percent/hhkb.dtsi | 76 ++++++++++++++ app/dts/layouts/common/65percent/iso.dtsi | 80 +++++++++++++++ .../layouts/common/75percent/75percent.dtsi | 59 +++++++++++ app/dts/layouts/common/75percent/all1u.dtsi | 98 +++++++++++++++++++ app/dts/layouts/common/75percent/ansi.dtsi | 95 ++++++++++++++++++ app/dts/layouts/common/75percent/iso.dtsi | 96 ++++++++++++++++++ app/dts/layouts/common/ortho_4x12/1x2u.dtsi | 58 +++++++++++ app/dts/layouts/common/ortho_4x12/2x2u.dtsi | 57 +++++++++++ app/dts/layouts/common/ortho_4x12/all1u.dtsi | 59 +++++++++++ .../layouts/common/ortho_4x12/ortho_4x12.dtsi | 53 ++++++++++ app/dts/layouts/common/ortho_5x12/1x2u.dtsi | 70 +++++++++++++ app/dts/layouts/common/ortho_5x12/2x2u.dtsi | 69 +++++++++++++ app/dts/layouts/common/ortho_5x12/all1u.dtsi | 71 ++++++++++++++ .../layouts/common/ortho_5x12/ortho_5x12.dtsi | 56 +++++++++++ app/dts/layouts/common/tkl/ansi.dtsi | 98 +++++++++++++++++++ 23 files changed, 1696 insertions(+) create mode 100644 app/dts/layouts/common/60percent/60percent.dtsi create mode 100644 app/dts/layouts/common/60percent/all1u.dtsi create mode 100644 app/dts/layouts/common/60percent/ansi.dtsi create mode 100644 app/dts/layouts/common/60percent/hhkb.dtsi create mode 100644 app/dts/layouts/common/60percent/iso.dtsi create mode 100644 app/dts/layouts/common/65percent/65percent.dtsi create mode 100644 app/dts/layouts/common/65percent/all1u.dtsi create mode 100644 app/dts/layouts/common/65percent/ansi.dtsi create mode 100644 app/dts/layouts/common/65percent/hhkb.dtsi create mode 100644 app/dts/layouts/common/65percent/iso.dtsi create mode 100644 app/dts/layouts/common/75percent/75percent.dtsi create mode 100644 app/dts/layouts/common/75percent/all1u.dtsi create mode 100644 app/dts/layouts/common/75percent/ansi.dtsi create mode 100644 app/dts/layouts/common/75percent/iso.dtsi create mode 100644 app/dts/layouts/common/ortho_4x12/1x2u.dtsi create mode 100644 app/dts/layouts/common/ortho_4x12/2x2u.dtsi create mode 100644 app/dts/layouts/common/ortho_4x12/all1u.dtsi create mode 100644 app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi create mode 100644 app/dts/layouts/common/ortho_5x12/1x2u.dtsi create mode 100644 app/dts/layouts/common/ortho_5x12/2x2u.dtsi create mode 100644 app/dts/layouts/common/ortho_5x12/all1u.dtsi create mode 100644 app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi create mode 100644 app/dts/layouts/common/tkl/ansi.dtsi diff --git a/app/dts/layouts/common/60percent/60percent.dtsi b/app/dts/layouts/common/60percent/60percent.dtsi new file mode 100644 index 00000000000..03f42e2a1bb --- /dev/null +++ b/app/dts/layouts/common/60percent/60percent.dtsi @@ -0,0 +1,72 @@ +#include +#include +#include +#include + +&layout_60_ansi { + status = "disabled"; +}; + +&layout_60_iso { + status = "disabled"; +}; + +&layout_60_all1u { + status = "disabled"; +}; + +&layout_60_hhkb { + status = "disabled"; +}; + +/ { + layouts_common_60_percent_position_map: layouts_common_60_percent_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + + layout_60_all1u { + physical-layout = <&layout_60_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 28> + , <29 30 31 32 33 34 35 36 37 38 39 40 41> + , <42 43 44 45 46 47 48 49 50 51 52 53 54 55 56> + , <57 58 59 60 61 62 64 63 65> + ; + }; + + layout_60_ansi { + physical-layout = <&layout_60_ansi>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 61> + , <14 15 16 17 18 19 20 21 22 23 24 25 26 27> + , <28 29 30 31 32 33 34 35 36 37 38 39 40> + , <41 62 42 43 44 45 46 47 48 49 50 51 52 63 64> + , <53 54 55 56 57 58 60 59 65> + ; + }; + + layout_60_hhkb { + physical-layout = <&layout_60_hhkb>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 60> + , <14 15 16 17 18 19 20 21 22 23 24 25 26 27> + , <28 29 30 31 32 33 34 35 36 37 38 39 40> + , <41 61 42 43 44 45 46 47 48 49 50 51 52 62 63> + , <53 54 55 56 57 58 59 64 65> + ; + }; + + layout_60_iso { + physical-layout = <&layout_60_iso>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 62> + , <14 15 16 17 18 19 20 21 22 23 24 25 26 63> + , <27 28 29 30 31 32 33 34 35 36 37 38 40> + , <41 42 43 44 45 46 47 48 49 50 51 52 53 64 65> + , <54 55 56 57 58 59 61 60 39> + ; + }; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/60percent/all1u.dtsi b/app/dts/layouts/common/60percent/all1u.dtsi new file mode 100644 index 00000000000..47e3ad38241 --- /dev/null +++ b/app/dts/layouts/common/60percent/all1u.dtsi @@ -0,0 +1,77 @@ +#include + +/ { + layout_60_all1u: layout_60_all1u { + compatible = "zmk,physical-layout"; + display-name = "60% All 1U"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 150 100 1350 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 225 100 1275 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + , <&key_physical_attrs 100 100 1200 300 0 0 0> + , <&key_physical_attrs 100 100 1300 300 0 0 0> + , <&key_physical_attrs 100 100 1400 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 125 100 125 400 0 0 0> + , <&key_physical_attrs 125 100 250 400 0 0 0> + , <&key_physical_attrs 625 100 375 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1200 400 0 0 0> + , <&key_physical_attrs 100 100 1300 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/60percent/ansi.dtsi b/app/dts/layouts/common/60percent/ansi.dtsi new file mode 100644 index 00000000000..2c8074bc72c --- /dev/null +++ b/app/dts/layouts/common/60percent/ansi.dtsi @@ -0,0 +1,72 @@ +#include + +/ { + layout_60_ansi: layout_60_ansi { + compatible = "zmk,physical-layout"; + display-name = "60% ANSI"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 200 100 1300 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 150 100 1350 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 225 100 1275 200 0 0 0> + , <&key_physical_attrs 225 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 625 300 0 0 0> + , <&key_physical_attrs 100 100 725 300 0 0 0> + , <&key_physical_attrs 100 100 825 300 0 0 0> + , <&key_physical_attrs 100 100 925 300 0 0 0> + , <&key_physical_attrs 100 100 1025 300 0 0 0> + , <&key_physical_attrs 100 100 1125 300 0 0 0> + , <&key_physical_attrs 275 100 1225 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 125 100 125 400 0 0 0> + , <&key_physical_attrs 125 100 250 400 0 0 0> + , <&key_physical_attrs 625 100 375 400 0 0 0> + , <&key_physical_attrs 125 100 1000 400 0 0 0> + , <&key_physical_attrs 125 100 1125 400 0 0 0> + , <&key_physical_attrs 125 100 1250 400 0 0 0> + , <&key_physical_attrs 125 100 1375 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/60percent/hhkb.dtsi b/app/dts/layouts/common/60percent/hhkb.dtsi new file mode 100644 index 00000000000..f14e72be46c --- /dev/null +++ b/app/dts/layouts/common/60percent/hhkb.dtsi @@ -0,0 +1,71 @@ +#include + +/ { + layout_60_hhkb: layout_60_hhkb { + compatible = "zmk,physical-layout"; + display-name = "60% HHKB/Tsangan layout"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 200 100 1300 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 150 100 1350 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 225 100 1275 200 0 0 0> + , <&key_physical_attrs 225 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 625 300 0 0 0> + , <&key_physical_attrs 100 100 725 300 0 0 0> + , <&key_physical_attrs 100 100 825 300 0 0 0> + , <&key_physical_attrs 100 100 925 300 0 0 0> + , <&key_physical_attrs 100 100 1025 300 0 0 0> + , <&key_physical_attrs 100 100 1125 300 0 0 0> + , <&key_physical_attrs 275 100 1225 300 0 0 0> + , <&key_physical_attrs 150 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 150 400 0 0 0> + , <&key_physical_attrs 150 100 250 400 0 0 0> + , <&key_physical_attrs 700 100 400 400 0 0 0> + , <&key_physical_attrs 150 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1250 400 0 0 0> + , <&key_physical_attrs 150 100 1350 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/60percent/iso.dtsi b/app/dts/layouts/common/60percent/iso.dtsi new file mode 100644 index 00000000000..2e3a00d8208 --- /dev/null +++ b/app/dts/layouts/common/60percent/iso.dtsi @@ -0,0 +1,73 @@ +#include + +/ { + layout_60_iso: layout_60_iso { + compatible = "zmk,physical-layout"; + display-name = "60% ISO"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 200 100 1300 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 100 100 1275 200 0 0 0> + , <&key_physical_attrs 125 200 1375 100 0 0 0> + , <&key_physical_attrs 125 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 125 300 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 625 300 0 0 0> + , <&key_physical_attrs 100 100 725 300 0 0 0> + , <&key_physical_attrs 100 100 825 300 0 0 0> + , <&key_physical_attrs 100 100 925 300 0 0 0> + , <&key_physical_attrs 100 100 1025 300 0 0 0> + , <&key_physical_attrs 100 100 1125 300 0 0 0> + , <&key_physical_attrs 275 100 1225 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 125 100 125 400 0 0 0> + , <&key_physical_attrs 125 100 250 400 0 0 0> + , <&key_physical_attrs 625 100 375 400 0 0 0> + , <&key_physical_attrs 125 100 1000 400 0 0 0> + , <&key_physical_attrs 125 100 1125 400 0 0 0> + , <&key_physical_attrs 125 100 1250 400 0 0 0> + , <&key_physical_attrs 125 100 1375 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/65percent/65percent.dtsi b/app/dts/layouts/common/65percent/65percent.dtsi new file mode 100644 index 00000000000..9e46d315e93 --- /dev/null +++ b/app/dts/layouts/common/65percent/65percent.dtsi @@ -0,0 +1,72 @@ +#include +#include +#include +#include + +&layout_65_ansi { + status = "disabled"; +}; + +&layout_65_iso { + status = "disabled"; +}; + +&layout_65_all1u { + status = "disabled"; +}; + +&layout_65_hhkb { + status = "disabled"; +}; + +/ { + layouts_common_65_percent_position_map: layouts_common_65_percent_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + + layout_65_all1u { + physical-layout = <&layout_65_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 30> + , <31 32 33 34 35 36 37 38 39 40 41 42 43 44> + , <45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60> + , <61 62 63 64 65 66 67 68 69 70> + ; + }; + + layout_65_ansi { + physical-layout = <&layout_65_ansi>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 68 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 28 29> + , <30 31 32 33 34 35 36 37 38 39 40 41 42 43> + , <44 69 45 46 47 48 49 50 51 52 53 54 55 70 56 57> + , <58 59 60 61 62 63 64 65 66 67> + ; + }; + + layout_65_hhkb { + physical-layout = <&layout_65_hhkb>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 65 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 28 29> + , <30 31 32 33 34 35 36 37 38 39 40 41 42 43> + , <44 66 45 46 47 48 49 50 51 52 53 54 55 67 68 56> + , <57 58 59 60 61 62 63 69 70 64> + ; + }; + + layout_65_iso { + physical-layout = <&layout_65_iso>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 69 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 70 28> + , <29 30 31 32 33 34 35 36 37 38 39 40 42 43> + , <44 45 46 47 48 49 50 51 52 53 54 55 56 41 57 58> + , <59 60 61 62 63 64 65 66 67 68> + ; + }; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/65percent/all1u.dtsi b/app/dts/layouts/common/65percent/all1u.dtsi new file mode 100644 index 00000000000..8ab62ef2869 --- /dev/null +++ b/app/dts/layouts/common/65percent/all1u.dtsi @@ -0,0 +1,85 @@ +#include + +/ { + layout_65_all1u: layout_65_all1u { + compatible = "zmk,physical-layout"; + display-name = "65% All 1U"; + + kscan = <&kscan0>; + transform = <&matrix_transform_65_all1u>; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 150 100 1350 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 225 100 1275 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + , <&key_physical_attrs 100 100 1200 300 0 0 0> + , <&key_physical_attrs 100 100 1300 300 0 0 0> + , <&key_physical_attrs 100 100 1400 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 125 100 125 400 0 0 0> + , <&key_physical_attrs 125 100 250 400 0 0 0> + , <&key_physical_attrs 625 100 375 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1200 400 0 0 0> + , <&key_physical_attrs 100 100 1300 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/65percent/ansi.dtsi b/app/dts/layouts/common/65percent/ansi.dtsi new file mode 100644 index 00000000000..9685515c4b7 --- /dev/null +++ b/app/dts/layouts/common/65percent/ansi.dtsi @@ -0,0 +1,79 @@ +#include + +/ { + layout_65_ansi: layout_65_ansi { + compatible = "zmk,physical-layout"; + display-name = "65% ANSI"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 200 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 150 100 1350 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 225 100 1275 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 225 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 625 300 0 0 0> + , <&key_physical_attrs 100 100 725 300 0 0 0> + , <&key_physical_attrs 100 100 825 300 0 0 0> + , <&key_physical_attrs 100 100 925 300 0 0 0> + , <&key_physical_attrs 100 100 1025 300 0 0 0> + , <&key_physical_attrs 100 100 1125 300 0 0 0> + , <&key_physical_attrs 175 100 1225 300 0 0 0> + , <&key_physical_attrs 100 100 1400 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 125 100 125 400 0 0 0> + , <&key_physical_attrs 125 100 250 400 0 0 0> + , <&key_physical_attrs 625 100 375 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1200 400 0 0 0> + , <&key_physical_attrs 100 100 1300 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/65percent/hhkb.dtsi b/app/dts/layouts/common/65percent/hhkb.dtsi new file mode 100644 index 00000000000..cbadad96e5d --- /dev/null +++ b/app/dts/layouts/common/65percent/hhkb.dtsi @@ -0,0 +1,76 @@ +#include + +/ { + layout_65_hhkb: layout_65_hhkb { + compatible = "zmk,physical-layout"; + display-name = "65% HHKB/Tsangan"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 200 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 150 100 1350 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 225 100 1275 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 225 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 625 300 0 0 0> + , <&key_physical_attrs 100 100 725 300 0 0 0> + , <&key_physical_attrs 100 100 825 300 0 0 0> + , <&key_physical_attrs 100 100 925 300 0 0 0> + , <&key_physical_attrs 100 100 1025 300 0 0 0> + , <&key_physical_attrs 100 100 1125 300 0 0 0> + , <&key_physical_attrs 275 100 1225 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 150 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 150 400 0 0 0> + , <&key_physical_attrs 150 100 250 400 0 0 0> + , <&key_physical_attrs 700 100 400 400 0 0 0> + , <&key_physical_attrs 150 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1250 400 0 0 0> + , <&key_physical_attrs 150 100 1350 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/65percent/iso.dtsi b/app/dts/layouts/common/65percent/iso.dtsi new file mode 100644 index 00000000000..3395c614e34 --- /dev/null +++ b/app/dts/layouts/common/65percent/iso.dtsi @@ -0,0 +1,80 @@ +#include + +/ { + layout_65_iso: layout_65_iso { + compatible = "zmk,physical-layout"; + display-name = "65% ISO"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 200 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 150 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 150 100 0 0 0> + , <&key_physical_attrs 100 100 250 100 0 0 0> + , <&key_physical_attrs 100 100 350 100 0 0 0> + , <&key_physical_attrs 100 100 450 100 0 0 0> + , <&key_physical_attrs 100 100 550 100 0 0 0> + , <&key_physical_attrs 100 100 650 100 0 0 0> + , <&key_physical_attrs 100 100 750 100 0 0 0> + , <&key_physical_attrs 100 100 850 100 0 0 0> + , <&key_physical_attrs 100 100 950 100 0 0 0> + , <&key_physical_attrs 100 100 1050 100 0 0 0> + , <&key_physical_attrs 100 100 1150 100 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 175 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 175 200 0 0 0> + , <&key_physical_attrs 100 100 275 200 0 0 0> + , <&key_physical_attrs 100 100 375 200 0 0 0> + , <&key_physical_attrs 100 100 475 200 0 0 0> + , <&key_physical_attrs 100 100 575 200 0 0 0> + , <&key_physical_attrs 100 100 675 200 0 0 0> + , <&key_physical_attrs 100 100 775 200 0 0 0> + , <&key_physical_attrs 100 100 875 200 0 0 0> + , <&key_physical_attrs 100 100 975 200 0 0 0> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 100 100 1275 200 0 0 0> + , <&key_physical_attrs 125 200 1375 100 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 125 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 125 300 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 625 300 0 0 0> + , <&key_physical_attrs 100 100 725 300 0 0 0> + , <&key_physical_attrs 100 100 825 300 0 0 0> + , <&key_physical_attrs 100 100 925 300 0 0 0> + , <&key_physical_attrs 100 100 1025 300 0 0 0> + , <&key_physical_attrs 100 100 1125 300 0 0 0> + , <&key_physical_attrs 175 100 1225 300 0 0 0> + , <&key_physical_attrs 100 100 1400 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 125 100 125 400 0 0 0> + , <&key_physical_attrs 125 100 250 400 0 0 0> + , <&key_physical_attrs 625 100 375 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1200 400 0 0 0> + , <&key_physical_attrs 100 100 1300 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/75percent/75percent.dtsi b/app/dts/layouts/common/75percent/75percent.dtsi new file mode 100644 index 00000000000..1781fbd3ba0 --- /dev/null +++ b/app/dts/layouts/common/75percent/75percent.dtsi @@ -0,0 +1,59 @@ +#include +#include +#include + +&layout_75_ansi { + status = "disabled"; +}; + +&layout_75_iso { + status = "disabled"; +}; + +&layout_75_all1u { + status = "disabled"; +}; + +/ { + layouts_common_75_percent_position_map: layouts_common_75_percent_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + + layout_75_all1u { + physical-layout = <&layout_75_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31> + , <32 33 34 35 36 37 38 39 40 41 42 43 44 45 46> + , <47 48 49 50 51 52 53 54 55 56 57 58 59 60> + , <61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76> + , <77 78 79 80 81 82 83 84 85 86> + ; + }; + + layout_75_ansi { + physical-layout = <&layout_75_ansi>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 84 30> + , <31 32 33 34 35 36 37 38 39 40 41 42 43 44 45> + , <46 47 48 49 50 51 52 53 54 55 56 57 58 59> + , <60 85 61 62 63 64 65 66 67 68 69 70 71 86 72 73> + , <74 75 76 77 78 79 80 81 82 83> + ; + }; + + layout_75_iso { + physical-layout = <&layout_75_iso>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 85 30> + , <31 32 33 34 35 36 37 38 39 40 41 42 43 86 44> + , <45 46 47 48 49 50 51 52 53 54 55 56 58 59> + , <60 61 62 63 64 65 66 67 68 69 70 71 72 57 73 74> + , <75 76 77 78 79 80 81 82 83 84> + ; + }; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/75percent/all1u.dtsi b/app/dts/layouts/common/75percent/all1u.dtsi new file mode 100644 index 00000000000..04c12bdbb14 --- /dev/null +++ b/app/dts/layouts/common/75percent/all1u.dtsi @@ -0,0 +1,98 @@ +#include + +/ { + layout_75_all1u: layout_75_all1u { + compatible = "zmk,physical-layout"; + display-name = "75% All 1U"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 1200 100 0 0 0> + , <&key_physical_attrs 100 100 1300 100 0 0 0> + , <&key_physical_attrs 100 100 1400 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 150 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 150 200 0 0 0> + , <&key_physical_attrs 100 100 250 200 0 0 0> + , <&key_physical_attrs 100 100 350 200 0 0 0> + , <&key_physical_attrs 100 100 450 200 0 0 0> + , <&key_physical_attrs 100 100 550 200 0 0 0> + , <&key_physical_attrs 100 100 650 200 0 0 0> + , <&key_physical_attrs 100 100 750 200 0 0 0> + , <&key_physical_attrs 100 100 850 200 0 0 0> + , <&key_physical_attrs 100 100 950 200 0 0 0> + , <&key_physical_attrs 100 100 1050 200 0 0 0> + , <&key_physical_attrs 100 100 1150 200 0 0 0> + , <&key_physical_attrs 100 100 1250 200 0 0 0> + , <&key_physical_attrs 150 100 1350 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 175 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 175 300 0 0 0> + , <&key_physical_attrs 100 100 275 300 0 0 0> + , <&key_physical_attrs 100 100 375 300 0 0 0> + , <&key_physical_attrs 100 100 475 300 0 0 0> + , <&key_physical_attrs 100 100 575 300 0 0 0> + , <&key_physical_attrs 100 100 675 300 0 0 0> + , <&key_physical_attrs 100 100 775 300 0 0 0> + , <&key_physical_attrs 100 100 875 300 0 0 0> + , <&key_physical_attrs 100 100 975 300 0 0 0> + , <&key_physical_attrs 100 100 1075 300 0 0 0> + , <&key_physical_attrs 100 100 1175 300 0 0 0> + , <&key_physical_attrs 225 100 1275 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 100 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 100 400 0 0 0> + , <&key_physical_attrs 100 100 200 400 0 0 0> + , <&key_physical_attrs 100 100 300 400 0 0 0> + , <&key_physical_attrs 100 100 400 400 0 0 0> + , <&key_physical_attrs 100 100 500 400 0 0 0> + , <&key_physical_attrs 100 100 600 400 0 0 0> + , <&key_physical_attrs 100 100 700 400 0 0 0> + , <&key_physical_attrs 100 100 800 400 0 0 0> + , <&key_physical_attrs 100 100 900 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + , <&key_physical_attrs 100 100 1200 400 0 0 0> + , <&key_physical_attrs 100 100 1300 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + , <&key_physical_attrs 125 100 0 500 0 0 0> + , <&key_physical_attrs 125 100 125 500 0 0 0> + , <&key_physical_attrs 125 100 250 500 0 0 0> + , <&key_physical_attrs 625 100 375 500 0 0 0> + , <&key_physical_attrs 100 100 1000 500 0 0 0> + , <&key_physical_attrs 100 100 1100 500 0 0 0> + , <&key_physical_attrs 100 100 1200 500 0 0 0> + , <&key_physical_attrs 100 100 1300 500 0 0 0> + , <&key_physical_attrs 100 100 1400 500 0 0 0> + , <&key_physical_attrs 100 100 1500 500 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/75percent/ansi.dtsi b/app/dts/layouts/common/75percent/ansi.dtsi new file mode 100644 index 00000000000..6c9a65c7650 --- /dev/null +++ b/app/dts/layouts/common/75percent/ansi.dtsi @@ -0,0 +1,95 @@ +#include + +/ { + layout_75_ansi: layout_75_ansi { + compatible = "zmk,physical-layout"; + display-name = "75% ANSI"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 1200 100 0 0 0> + , <&key_physical_attrs 200 100 1300 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 150 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 150 200 0 0 0> + , <&key_physical_attrs 100 100 250 200 0 0 0> + , <&key_physical_attrs 100 100 350 200 0 0 0> + , <&key_physical_attrs 100 100 450 200 0 0 0> + , <&key_physical_attrs 100 100 550 200 0 0 0> + , <&key_physical_attrs 100 100 650 200 0 0 0> + , <&key_physical_attrs 100 100 750 200 0 0 0> + , <&key_physical_attrs 100 100 850 200 0 0 0> + , <&key_physical_attrs 100 100 950 200 0 0 0> + , <&key_physical_attrs 100 100 1050 200 0 0 0> + , <&key_physical_attrs 100 100 1150 200 0 0 0> + , <&key_physical_attrs 100 100 1250 200 0 0 0> + , <&key_physical_attrs 150 100 1350 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 175 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 175 300 0 0 0> + , <&key_physical_attrs 100 100 275 300 0 0 0> + , <&key_physical_attrs 100 100 375 300 0 0 0> + , <&key_physical_attrs 100 100 475 300 0 0 0> + , <&key_physical_attrs 100 100 575 300 0 0 0> + , <&key_physical_attrs 100 100 675 300 0 0 0> + , <&key_physical_attrs 100 100 775 300 0 0 0> + , <&key_physical_attrs 100 100 875 300 0 0 0> + , <&key_physical_attrs 100 100 975 300 0 0 0> + , <&key_physical_attrs 100 100 1075 300 0 0 0> + , <&key_physical_attrs 100 100 1175 300 0 0 0> + , <&key_physical_attrs 225 100 1275 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 225 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 225 400 0 0 0> + , <&key_physical_attrs 100 100 325 400 0 0 0> + , <&key_physical_attrs 100 100 425 400 0 0 0> + , <&key_physical_attrs 100 100 525 400 0 0 0> + , <&key_physical_attrs 100 100 625 400 0 0 0> + , <&key_physical_attrs 100 100 725 400 0 0 0> + , <&key_physical_attrs 100 100 825 400 0 0 0> + , <&key_physical_attrs 100 100 925 400 0 0 0> + , <&key_physical_attrs 100 100 1025 400 0 0 0> + , <&key_physical_attrs 100 100 1125 400 0 0 0> + , <&key_physical_attrs 175 100 1225 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + , <&key_physical_attrs 125 100 0 500 0 0 0> + , <&key_physical_attrs 125 100 125 500 0 0 0> + , <&key_physical_attrs 125 100 250 500 0 0 0> + , <&key_physical_attrs 625 100 375 500 0 0 0> + , <&key_physical_attrs 100 100 1000 500 0 0 0> + , <&key_physical_attrs 100 100 1100 500 0 0 0> + , <&key_physical_attrs 100 100 1200 500 0 0 0> + , <&key_physical_attrs 100 100 1300 500 0 0 0> + , <&key_physical_attrs 100 100 1400 500 0 0 0> + , <&key_physical_attrs 100 100 1500 500 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/75percent/iso.dtsi b/app/dts/layouts/common/75percent/iso.dtsi new file mode 100644 index 00000000000..f3ee0c51073 --- /dev/null +++ b/app/dts/layouts/common/75percent/iso.dtsi @@ -0,0 +1,96 @@ +#include + +/ { + layout_75_iso: layout_75_iso { + compatible = "zmk,physical-layout"; + display-name = "75% ISO"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 1200 100 0 0 0> + , <&key_physical_attrs 200 100 1300 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 150 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 150 200 0 0 0> + , <&key_physical_attrs 100 100 250 200 0 0 0> + , <&key_physical_attrs 100 100 350 200 0 0 0> + , <&key_physical_attrs 100 100 450 200 0 0 0> + , <&key_physical_attrs 100 100 550 200 0 0 0> + , <&key_physical_attrs 100 100 650 200 0 0 0> + , <&key_physical_attrs 100 100 750 200 0 0 0> + , <&key_physical_attrs 100 100 850 200 0 0 0> + , <&key_physical_attrs 100 100 950 200 0 0 0> + , <&key_physical_attrs 100 100 1050 200 0 0 0> + , <&key_physical_attrs 100 100 1150 200 0 0 0> + , <&key_physical_attrs 100 100 1250 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 175 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 175 300 0 0 0> + , <&key_physical_attrs 100 100 275 300 0 0 0> + , <&key_physical_attrs 100 100 375 300 0 0 0> + , <&key_physical_attrs 100 100 475 300 0 0 0> + , <&key_physical_attrs 100 100 575 300 0 0 0> + , <&key_physical_attrs 100 100 675 300 0 0 0> + , <&key_physical_attrs 100 100 775 300 0 0 0> + , <&key_physical_attrs 100 100 875 300 0 0 0> + , <&key_physical_attrs 100 100 975 300 0 0 0> + , <&key_physical_attrs 100 100 1075 300 0 0 0> + , <&key_physical_attrs 100 100 1175 300 0 0 0> + , <&key_physical_attrs 100 100 1275 300 0 0 0> + , <&key_physical_attrs 125 200 1375 200 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 125 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 125 400 0 0 0> + , <&key_physical_attrs 100 100 225 400 0 0 0> + , <&key_physical_attrs 100 100 325 400 0 0 0> + , <&key_physical_attrs 100 100 425 400 0 0 0> + , <&key_physical_attrs 100 100 525 400 0 0 0> + , <&key_physical_attrs 100 100 625 400 0 0 0> + , <&key_physical_attrs 100 100 725 400 0 0 0> + , <&key_physical_attrs 100 100 825 400 0 0 0> + , <&key_physical_attrs 100 100 925 400 0 0 0> + , <&key_physical_attrs 100 100 1025 400 0 0 0> + , <&key_physical_attrs 100 100 1125 400 0 0 0> + , <&key_physical_attrs 175 100 1225 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + , <&key_physical_attrs 125 100 0 500 0 0 0> + , <&key_physical_attrs 125 100 125 500 0 0 0> + , <&key_physical_attrs 125 100 250 500 0 0 0> + , <&key_physical_attrs 625 100 375 500 0 0 0> + , <&key_physical_attrs 100 100 1000 500 0 0 0> + , <&key_physical_attrs 100 100 1100 500 0 0 0> + , <&key_physical_attrs 100 100 1200 500 0 0 0> + , <&key_physical_attrs 100 100 1300 500 0 0 0> + , <&key_physical_attrs 100 100 1400 500 0 0 0> + , <&key_physical_attrs 100 100 1500 500 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_4x12/1x2u.dtsi b/app/dts/layouts/common/ortho_4x12/1x2u.dtsi new file mode 100644 index 00000000000..23646afc9c7 --- /dev/null +++ b/app/dts/layouts/common/ortho_4x12/1x2u.dtsi @@ -0,0 +1,58 @@ +#include + +/ { + layout_ortho_4x12_1x2u: layout_ortho_4x12_1x2u { + compatible = "zmk,physical-layout"; + display-name = "40% 1x2U Space"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 600 200 0 0 0> + , <&key_physical_attrs 100 100 700 200 0 0 0> + , <&key_physical_attrs 100 100 800 200 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 200 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_4x12/2x2u.dtsi b/app/dts/layouts/common/ortho_4x12/2x2u.dtsi new file mode 100644 index 00000000000..d091786938a --- /dev/null +++ b/app/dts/layouts/common/ortho_4x12/2x2u.dtsi @@ -0,0 +1,57 @@ +#include + +/ { + layout_ortho_4x12_2x2u: layout_ortho_4x12_2x2u { + compatible = "zmk,physical-layout"; + display-name = "40% 2x2U Space"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 600 200 0 0 0> + , <&key_physical_attrs 100 100 700 200 0 0 0> + , <&key_physical_attrs 100 100 800 200 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 200 100 400 300 0 0 0> + , <&key_physical_attrs 200 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_4x12/all1u.dtsi b/app/dts/layouts/common/ortho_4x12/all1u.dtsi new file mode 100644 index 00000000000..323821d4662 --- /dev/null +++ b/app/dts/layouts/common/ortho_4x12/all1u.dtsi @@ -0,0 +1,59 @@ +#include + +/ { + layout_ortho_4x12_all1u: layout_ortho_4x12_all1u { + compatible = "zmk,physical-layout"; + display-name = "40% All 1U/Grid"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 600 200 0 0 0> + , <&key_physical_attrs 100 100 700 200 0 0 0> + , <&key_physical_attrs 100 100 800 200 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi b/app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi new file mode 100644 index 00000000000..0c361b109bc --- /dev/null +++ b/app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi @@ -0,0 +1,53 @@ +#include +#include +#include + +&layout_ortho_4x12_all1u { + status = "disabled"; +}; + +&layout_ortho_4x12_1x2u { + status = "disabled"; +}; + +&layout_ortho_4x12_2x2u { + status = "disabled"; +}; + +/ { + layouts_common_ortho_4x12_position_map: layouts_common_ortho_4x12_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + + layout_ortho_4x12_all1u { + physical-layout = <&layout_ortho_4x12_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + ; + }; + + layout_ortho_4x12_2x2u { + physical-layout = <&layout_ortho_4x12_2x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 46 47 41 42 43 44 45> + ; + }; + + layout_ortho_4x12_1x2u { + physical-layout = <&layout_ortho_4x12_1x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 47 42 43 44 45 46> + ; + }; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_5x12/1x2u.dtsi b/app/dts/layouts/common/ortho_5x12/1x2u.dtsi new file mode 100644 index 00000000000..2072cc35dd1 --- /dev/null +++ b/app/dts/layouts/common/ortho_5x12/1x2u.dtsi @@ -0,0 +1,70 @@ +#include + +/ { + layout_ortho_5x12_1x2u: layout_ortho_5x12_1x2u { + compatible = "zmk,physical-layout"; + display-name = "50% 1x2U Space"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 600 200 0 0 0> + , <&key_physical_attrs 100 100 700 200 0 0 0> + , <&key_physical_attrs 100 100 800 200 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + , <&key_physical_attrs 100 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 100 400 0 0 0> + , <&key_physical_attrs 100 100 200 400 0 0 0> + , <&key_physical_attrs 100 100 300 400 0 0 0> + , <&key_physical_attrs 100 100 400 400 0 0 0> + , <&key_physical_attrs 200 100 500 400 0 0 0> + , <&key_physical_attrs 100 100 700 400 0 0 0> + , <&key_physical_attrs 100 100 800 400 0 0 0> + , <&key_physical_attrs 100 100 900 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_5x12/2x2u.dtsi b/app/dts/layouts/common/ortho_5x12/2x2u.dtsi new file mode 100644 index 00000000000..5e55f734e19 --- /dev/null +++ b/app/dts/layouts/common/ortho_5x12/2x2u.dtsi @@ -0,0 +1,69 @@ +#include + +/ { + layout_ortho_5x12_2x2u: layout_ortho_5x12_2x2u { + compatible = "zmk,physical-layout"; + display-name = "50% 2x2U Space"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 600 200 0 0 0> + , <&key_physical_attrs 100 100 700 200 0 0 0> + , <&key_physical_attrs 100 100 800 200 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + , <&key_physical_attrs 100 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 100 400 0 0 0> + , <&key_physical_attrs 100 100 200 400 0 0 0> + , <&key_physical_attrs 100 100 300 400 0 0 0> + , <&key_physical_attrs 200 100 400 400 0 0 0> + , <&key_physical_attrs 200 100 600 400 0 0 0> + , <&key_physical_attrs 100 100 800 400 0 0 0> + , <&key_physical_attrs 100 100 900 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + ; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_5x12/all1u.dtsi b/app/dts/layouts/common/ortho_5x12/all1u.dtsi new file mode 100644 index 00000000000..53afb469f85 --- /dev/null +++ b/app/dts/layouts/common/ortho_5x12/all1u.dtsi @@ -0,0 +1,71 @@ +#include + +/ { + layout_ortho_5x12_all1u: layout_ortho_5x12_all1u { + compatible = "zmk,physical-layout"; + display-name = "50% All 1U/Grid"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 600 0 0 0 0> + , <&key_physical_attrs 100 100 700 0 0 0 0> + , <&key_physical_attrs 100 100 800 0 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 600 100 0 0 0> + , <&key_physical_attrs 100 100 700 100 0 0 0> + , <&key_physical_attrs 100 100 800 100 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 600 200 0 0 0> + , <&key_physical_attrs 100 100 700 200 0 0 0> + , <&key_physical_attrs 100 100 800 200 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 600 300 0 0 0> + , <&key_physical_attrs 100 100 700 300 0 0 0> + , <&key_physical_attrs 100 100 800 300 0 0 0> + , <&key_physical_attrs 100 100 900 300 0 0 0> + , <&key_physical_attrs 100 100 1000 300 0 0 0> + , <&key_physical_attrs 100 100 1100 300 0 0 0> + , <&key_physical_attrs 100 100 0 400 0 0 0> + , <&key_physical_attrs 100 100 100 400 0 0 0> + , <&key_physical_attrs 100 100 200 400 0 0 0> + , <&key_physical_attrs 100 100 300 400 0 0 0> + , <&key_physical_attrs 100 100 400 400 0 0 0> + , <&key_physical_attrs 100 100 500 400 0 0 0> + , <&key_physical_attrs 100 100 600 400 0 0 0> + , <&key_physical_attrs 100 100 700 400 0 0 0> + , <&key_physical_attrs 100 100 800 400 0 0 0> + , <&key_physical_attrs 100 100 900 400 0 0 0> + , <&key_physical_attrs 100 100 1000 400 0 0 0> + , <&key_physical_attrs 100 100 1100 400 0 0 0> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi b/app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi new file mode 100644 index 00000000000..d1a6df7e812 --- /dev/null +++ b/app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi @@ -0,0 +1,56 @@ +#include +#include +#include + +&layout_ortho_5x12_all1u { + status = "disabled"; +}; + +&layout_ortho_5x12_1x2u { + status = "disabled"; +}; + +&layout_ortho_5x12_2x2u { + status = "disabled"; +}; + +/ { + layouts_common_ortho_5x12_position_map: layouts_common_ortho_5x12_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + + layout_ortho_5x12_all1u { + physical-layout = <&layout_ortho_5x12_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + , <48 49 50 51 52 53 54 55 56 57 58 59> + ; + }; + + layout_ortho_5x12_2x2u { + physical-layout = <&layout_ortho_5x12_2x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + , <48 49 50 51 52 58 59 53 54 55 56 57> + ; + }; + + layout_ortho_5x12_1x2u { + physical-layout = <&layout_ortho_5x12_1x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + , <48 49 50 51 52 53 59 54 55 56 57 58> + ; + }; + }; +}; \ No newline at end of file diff --git a/app/dts/layouts/common/tkl/ansi.dtsi b/app/dts/layouts/common/tkl/ansi.dtsi new file mode 100644 index 00000000000..639ac471a67 --- /dev/null +++ b/app/dts/layouts/common/tkl/ansi.dtsi @@ -0,0 +1,98 @@ +#include + +/ { + layout_tkl_ansi: layout_tkl_ansi { + compatible = "zmk,physical-layout"; + display-name = "TKL 87 Key ANSI"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 500 0 0 0 0> + , <&key_physical_attrs 100 100 650 0 0 0 0> + , <&key_physical_attrs 100 100 750 0 0 0 0> + , <&key_physical_attrs 100 100 850 0 0 0 0> + , <&key_physical_attrs 100 100 950 0 0 0 0> + , <&key_physical_attrs 100 100 1100 0 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 100 100 1525 0 0 0 0> + , <&key_physical_attrs 100 100 1625 0 0 0 0> + , <&key_physical_attrs 100 100 1725 0 0 0 0> + , <&key_physical_attrs 100 100 0 150 0 0 0> + , <&key_physical_attrs 100 100 100 150 0 0 0> + , <&key_physical_attrs 100 100 200 150 0 0 0> + , <&key_physical_attrs 100 100 300 150 0 0 0> + , <&key_physical_attrs 100 100 400 150 0 0 0> + , <&key_physical_attrs 100 100 500 150 0 0 0> + , <&key_physical_attrs 100 100 600 150 0 0 0> + , <&key_physical_attrs 100 100 700 150 0 0 0> + , <&key_physical_attrs 100 100 800 150 0 0 0> + , <&key_physical_attrs 100 100 900 150 0 0 0> + , <&key_physical_attrs 100 100 1000 150 0 0 0> + , <&key_physical_attrs 100 100 1100 150 0 0 0> + , <&key_physical_attrs 100 100 1200 150 0 0 0> + , <&key_physical_attrs 200 100 1300 150 0 0 0> + , <&key_physical_attrs 100 100 1525 150 0 0 0> + , <&key_physical_attrs 100 100 1625 150 0 0 0> + , <&key_physical_attrs 100 100 1725 150 0 0 0> + , <&key_physical_attrs 150 100 0 250 0 0 0> + , <&key_physical_attrs 100 100 150 250 0 0 0> + , <&key_physical_attrs 100 100 250 250 0 0 0> + , <&key_physical_attrs 100 100 350 250 0 0 0> + , <&key_physical_attrs 100 100 450 250 0 0 0> + , <&key_physical_attrs 100 100 550 250 0 0 0> + , <&key_physical_attrs 100 100 650 250 0 0 0> + , <&key_physical_attrs 100 100 750 250 0 0 0> + , <&key_physical_attrs 100 100 850 250 0 0 0> + , <&key_physical_attrs 100 100 950 250 0 0 0> + , <&key_physical_attrs 100 100 1050 250 0 0 0> + , <&key_physical_attrs 100 100 1150 250 0 0 0> + , <&key_physical_attrs 100 100 1250 250 0 0 0> + , <&key_physical_attrs 150 100 1350 250 0 0 0> + , <&key_physical_attrs 100 100 1525 250 0 0 0> + , <&key_physical_attrs 100 100 1625 250 0 0 0> + , <&key_physical_attrs 100 100 1725 250 0 0 0> + , <&key_physical_attrs 175 100 0 350 0 0 0> + , <&key_physical_attrs 100 100 175 350 0 0 0> + , <&key_physical_attrs 100 100 275 350 0 0 0> + , <&key_physical_attrs 100 100 375 350 0 0 0> + , <&key_physical_attrs 100 100 475 350 0 0 0> + , <&key_physical_attrs 100 100 575 350 0 0 0> + , <&key_physical_attrs 100 100 675 350 0 0 0> + , <&key_physical_attrs 100 100 775 350 0 0 0> + , <&key_physical_attrs 100 100 875 350 0 0 0> + , <&key_physical_attrs 100 100 975 350 0 0 0> + , <&key_physical_attrs 100 100 1075 350 0 0 0> + , <&key_physical_attrs 100 100 1175 350 0 0 0> + , <&key_physical_attrs 225 100 1275 350 0 0 0> + , <&key_physical_attrs 225 100 0 450 0 0 0> + , <&key_physical_attrs 100 100 225 450 0 0 0> + , <&key_physical_attrs 100 100 325 450 0 0 0> + , <&key_physical_attrs 100 100 425 450 0 0 0> + , <&key_physical_attrs 100 100 525 450 0 0 0> + , <&key_physical_attrs 100 100 625 450 0 0 0> + , <&key_physical_attrs 100 100 725 450 0 0 0> + , <&key_physical_attrs 100 100 825 450 0 0 0> + , <&key_physical_attrs 100 100 925 450 0 0 0> + , <&key_physical_attrs 100 100 1025 450 0 0 0> + , <&key_physical_attrs 100 100 1125 450 0 0 0> + , <&key_physical_attrs 275 100 1225 450 0 0 0> + , <&key_physical_attrs 100 100 1625 450 0 0 0> + , <&key_physical_attrs 125 100 0 550 0 0 0> + , <&key_physical_attrs 125 100 125 550 0 0 0> + , <&key_physical_attrs 125 100 250 550 0 0 0> + , <&key_physical_attrs 625 100 375 550 0 0 0> + , <&key_physical_attrs 125 100 1000 550 0 0 0> + , <&key_physical_attrs 125 100 1125 550 0 0 0> + , <&key_physical_attrs 125 100 1250 550 0 0 0> + , <&key_physical_attrs 125 100 1375 550 0 0 0> + , <&key_physical_attrs 100 100 1525 550 0 0 0> + , <&key_physical_attrs 100 100 1625 550 0 0 0> + , <&key_physical_attrs 100 100 1725 550 0 0 0> + ; + }; +}; From ec32c566ce0b7b5c6557c7ab70bf8347952848d4 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:57:45 +0100 Subject: [PATCH 18/42] feat(boards): Tofu65 V2 Physical layout --- app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts index 60ba1da0143..bc6a9d02b4b 100644 --- a/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts +++ b/app/boards/arm/kbdfans_tofu65/kbdfans_tofu65_v2.dts @@ -8,6 +8,8 @@ #include #include +#include + / { chosen { @@ -15,7 +17,7 @@ zephyr,flash = &flash0; zephyr,code-partition = &code_partition; zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &layout_65_ansi; }; xtal_clk: xtal-clk { @@ -115,3 +117,6 @@ zephyr_udc0: &usbd { status = "okay"; }; +&layout_65_ansi { + transform = <&default_transform>; +}; From a47f1fe2e173e97c22d9f44cbd5a65889b8b3a0a Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:02:27 +0100 Subject: [PATCH 19/42] feat(boards): nice!60 physical layout --- app/boards/arm/nice60/nice60.dts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/boards/arm/nice60/nice60.dts b/app/boards/arm/nice60/nice60.dts index fec8a678e76..35eececd439 100644 --- a/app/boards/arm/nice60/nice60.dts +++ b/app/boards/arm/nice60/nice60.dts @@ -10,6 +10,8 @@ #include #include +#include + #include "nice60-pinctrl.dtsi" / { @@ -22,7 +24,7 @@ zephyr,flash = &flash0; zmk,battery = &vbatt; zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &layout_60_ansi; zmk,underglow = &led_strip; }; @@ -169,3 +171,7 @@ zephyr_udc0: &usbd { }; }; }; + +&layout_60_ansi { + transform = <&default_transform>; +}; From a8f7888f4d6c289deea1cbbc4c1f1ee85cc19d66 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Thu, 26 Sep 2024 14:29:34 +0100 Subject: [PATCH 20/42] feat(boards): BT60 V1 Physical Layout --- app/boards/arm/bt60/bt60.dtsi | 2 -- app/boards/arm/bt60/bt60_v1.dts | 36 ++++++++++++-------- app/boards/arm/bt60/bt60_v1.keymap | 49 ++++++--------------------- app/boards/arm/bt60/bt60_v1_hs.dts | 8 +++-- app/boards/arm/bt60/bt60_v1_hs.keymap | 10 +++--- 5 files changed, 44 insertions(+), 61 deletions(-) diff --git a/app/boards/arm/bt60/bt60.dtsi b/app/boards/arm/bt60/bt60.dtsi index 83ff3f04aa9..5e176e60244 100644 --- a/app/boards/arm/bt60/bt60.dtsi +++ b/app/boards/arm/bt60/bt60.dtsi @@ -17,8 +17,6 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,battery = &vbatt; - zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; }; sensors: sensors { diff --git a/app/boards/arm/bt60/bt60_v1.dts b/app/boards/arm/bt60/bt60_v1.dts index 315d8cceb84..d7ecb5aeacd 100644 --- a/app/boards/arm/bt60/bt60_v1.dts +++ b/app/boards/arm/bt60/bt60_v1.dts @@ -6,12 +6,13 @@ /dts-v1/; #include "bt60.dtsi" +#include / { chosen { zmk,kscan = &kscan0; - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_60_ansi; }; ansi_transform: keymap_transform_0 { @@ -66,19 +67,6 @@ >; }; - split_transform: keymap_transform_4 { - compatible = "zmk,matrix-transform"; - columns = <15>; - rows = <5>; - map = < - RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) - RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) - RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,13) - RC(3,0) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,12) RC(3,14) - RC(4,0) RC(4,1) RC(4,2) RC(4,6) RC(4,10) RC(4,11) RC(4,12) RC(4,13) - >; - }; - kscan0: kscan_0 { compatible = "zmk,kscan-gpio-matrix"; wakeup-source; @@ -112,3 +100,23 @@ ; }; }; + +&layout_60_ansi { + status = "okay"; + transform = <&ansi_transform>; +}; + +&layout_60_iso { + status = "okay"; + transform = <&iso_transform>; +}; + +&layout_60_all1u { + status = "okay"; + transform = <&all_1u_transform>; +}; + +&layout_60_hhkb { + status = "okay"; + transform = <&hhkb_transform>; +}; diff --git a/app/boards/arm/bt60/bt60_v1.keymap b/app/boards/arm/bt60/bt60_v1.keymap index be3b206a161..65442b582e0 100644 --- a/app/boards/arm/bt60/bt60_v1.keymap +++ b/app/boards/arm/bt60/bt60_v1.keymap @@ -2,26 +2,25 @@ #include #include -#define ANSI true -//#define HHKB true -//#define ISO true -//#define ALL_1U true -//#define SPLIT_BKSP_RSHFT true +#define ANSI +//#define HHKB +//#define ISO +//#define ALL_1U / { chosen { #ifdef ANSI - zmk,matrix-transform = &ansi_transform; - #elif defined(HHKB) - zmk,matrix-transform = &hhkb_transform; + zmk,physical-layout = &layout_60_ansi; #elif defined(ISO) - zmk,matrix-transform = &iso_transform; + zmk,physical-layout = &layout_60_iso; #elif defined(ALL_1U) - zmk,matrix-transform = &all_1u_transform; + zmk,physical-layout = &layout_60_all1u; + #elif defined(HHKB) + zmk,physical-layout = &layout_60_hhkb; #else - zmk,matrix-transform = &split_transform; + #error "Layout not defined, please define a layout by uncommenting the appropriate line in bt60_v1.keymap" #endif }; @@ -148,33 +147,7 @@ sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; }; #else - default_layer { - // ------------------------------------------------------------------------------------------ - // | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |BSPC| DEL | - // | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | - // | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | - // | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | 1 | - // | CTL | WIN | ALT | SPACE | ALT | 1 | CTRL | - // ------------------------------------------------------------------------------------------ - bindings = < - &kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &kp DEL - &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH - &kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp RET - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT &mo 1 - &kp LCTRL &kp LGUI &kp LALT &kp SPACE &kp RALT &kp RGUI &kp C_MENU &kp RCTRL - >; - sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; - }; - raise { - bindings = < - &kp GRAVE &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp DEL &trans - &trans &trans &kp UP &trans &trans &trans &trans &trans &kp INS &trans &kp PSCRN &kp SLCK &kp PAUSE_BREAK &sys_reset - &trans &kp LEFT &kp DOWN &kp RIGHT &trans &trans &trans &trans &trans &trans &kp HOME &kp PG_UP &bootloader - &kp C_PREV &kp C_VOL_DN &kp C_VOL_UP &kp C_MUTE &trans &trans &trans &trans &trans &kp END &kp PG_DN &kp C_NEXT &trans - &bt BT_PRV &bt BT_NXT &trans &trans &trans &trans &trans &bt BT_CLR - >; - sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; - }; + #error "Layout not defined, please define a layout by uncommenting the appropriate line in bt60_v2.keymap" #endif }; }; diff --git a/app/boards/arm/bt60/bt60_v1_hs.dts b/app/boards/arm/bt60/bt60_v1_hs.dts index 27e38286178..23d4d55bbd1 100644 --- a/app/boards/arm/bt60/bt60_v1_hs.dts +++ b/app/boards/arm/bt60/bt60_v1_hs.dts @@ -6,12 +6,12 @@ /dts-v1/; #include "bt60.dtsi" - +#include / { chosen { zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &layout_60_ansi; }; default_transform: keymap_transform_0 { @@ -60,3 +60,7 @@ ; }; }; + +&layout_60_ansi { + transform = <&default_transform>; +}; diff --git a/app/boards/arm/bt60/bt60_v1_hs.keymap b/app/boards/arm/bt60/bt60_v1_hs.keymap index f1e483e3a1b..a36246e5b96 100644 --- a/app/boards/arm/bt60/bt60_v1_hs.keymap +++ b/app/boards/arm/bt60/bt60_v1_hs.keymap @@ -8,14 +8,14 @@ default_layer { // ------------------------------------------------------------------------------------------ - // | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BSPC | DEL - // | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | | | + // | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BSPC | + // | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | | | // | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | // | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | - // | CTL | WIN | ALT | SPACE | ALT | 1 | MENU | CTRL | + // | CTL | WIN | ALT | SPACE | ALT | 1 | MENU | CTRL | // ------------------------------------------------------------------------------------------ bindings = < - &kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &bt BT_CLR + &kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH &kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp RET &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT @@ -25,7 +25,7 @@ }; raise { bindings = < - &kp GRAVE &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp DEL &trans + &kp GRAVE &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp DEL &trans &trans &kp UP &trans &trans &trans &trans &trans &kp INS &trans &kp PSCRN &kp SLCK &kp PAUSE_BREAK &sys_reset &trans &kp LEFT &kp DOWN &kp RIGHT &trans &trans &trans &trans &trans &trans &kp HOME &kp PG_UP &bootloader &kp C_PREV &kp C_VOL_DN &kp C_VOL_UP &kp C_MUTE &trans &trans &trans &trans &trans &kp END &kp PG_DN &kp C_NEXT From 026be009a62017049a172048a0cdcf6295cdd0be Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Thu, 26 Sep 2024 14:22:47 +0100 Subject: [PATCH 21/42] feat(boards): CKP physical layout --- app/boards/arm/ckp/bt60_v2.dts | 23 ++++++++++++++++++++++- app/boards/arm/ckp/bt60_v2.keymap | 8 ++++---- app/boards/arm/ckp/bt65_v1.dts | 23 ++++++++++++++++++++++- app/boards/arm/ckp/bt65_v1.keymap | 8 ++++---- app/boards/arm/ckp/bt75_v1.dts | 18 +++++++++++++++++- app/boards/arm/ckp/bt75_v1.keymap | 6 +++--- 6 files changed, 72 insertions(+), 14 deletions(-) diff --git a/app/boards/arm/ckp/bt60_v2.dts b/app/boards/arm/ckp/bt60_v2.dts index a3ef75fb3a9..751cad0989c 100644 --- a/app/boards/arm/ckp/bt60_v2.dts +++ b/app/boards/arm/ckp/bt60_v2.dts @@ -6,6 +6,7 @@ /dts-v1/; #include "ckp.dtsi" +#include / { @@ -13,7 +14,7 @@ compatible = "polarityworks,bt60_v2"; chosen { - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_60_ansi; }; @@ -69,3 +70,23 @@ >; }; }; + +&layout_60_ansi { + status = "okay"; + transform = <&ansi_transform>; +}; + +&layout_60_iso { + status = "okay"; + transform = <&iso_transform>; +}; + +&layout_60_all1u { + status = "okay"; + transform = <&all_1u_transform>; +}; + +&layout_60_hhkb { + status = "okay"; + transform = <&hhkb_transform>; +}; diff --git a/app/boards/arm/ckp/bt60_v2.keymap b/app/boards/arm/ckp/bt60_v2.keymap index f72401f67e1..478cf7bdef9 100644 --- a/app/boards/arm/ckp/bt60_v2.keymap +++ b/app/boards/arm/ckp/bt60_v2.keymap @@ -12,13 +12,13 @@ / { chosen { #ifdef ANSI - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_60_ansi; #elif defined(ISO) - zmk,matrix-transform = &iso_transform; + zmk,physical-layout = &layout_60_iso; #elif defined(ALL_1U) - zmk,matrix-transform = &all_1u_transform; + zmk,physical-layout = &layout_60_all1u; #elif defined(HHKB) - zmk,matrix-transform = &hhkb_transform; + zmk,physical-layout = &layout_60_hhkb; #else #error "Layout not defined, please define a layout by uncommenting the appropriate line in bt60_v2.keymap" #endif diff --git a/app/boards/arm/ckp/bt65_v1.dts b/app/boards/arm/ckp/bt65_v1.dts index f79587ce128..cdea235f5ec 100644 --- a/app/boards/arm/ckp/bt65_v1.dts +++ b/app/boards/arm/ckp/bt65_v1.dts @@ -6,6 +6,7 @@ /dts-v1/; #include "ckp.dtsi" +#include / { @@ -13,7 +14,7 @@ compatible = "polarityworks,bt65_v1"; chosen { - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_65_ansi; }; @@ -69,3 +70,23 @@ >; }; }; + +&layout_65_ansi { + status = "okay"; + transform = <&ansi_transform>; +}; + +&layout_65_iso { + status = "okay"; + transform = <&iso_transform>; +}; + +&layout_65_all1u { + status = "okay"; + transform = <&all_1u_transform>; +}; + +&layout_65_hhkb { + status = "okay"; + transform = <&hhkb_transform>; +}; diff --git a/app/boards/arm/ckp/bt65_v1.keymap b/app/boards/arm/ckp/bt65_v1.keymap index a4041084490..da4941438e3 100644 --- a/app/boards/arm/ckp/bt65_v1.keymap +++ b/app/boards/arm/ckp/bt65_v1.keymap @@ -12,13 +12,13 @@ / { chosen { #ifdef ANSI - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_65_ansi; #elif defined(ISO) - zmk,matrix-transform = &iso_transform; + zmk,physical-layout = &layout_65_iso; #elif defined(ALL_1U) - zmk,matrix-transform = &all_1u_transform; + zmk,physical-layout = &layout_65_all1u; #elif defined(HHKB) - zmk,matrix-transform = &hhkb_transform; + zmk,physical-layout = &layout_65_hhkb; #else #error "Layout not defined, please define a layout by uncommenting the appropriate line in bt65_v1.keymap" #endif diff --git a/app/boards/arm/ckp/bt75_v1.dts b/app/boards/arm/ckp/bt75_v1.dts index 41281086544..7077aa1de6c 100644 --- a/app/boards/arm/ckp/bt75_v1.dts +++ b/app/boards/arm/ckp/bt75_v1.dts @@ -6,6 +6,7 @@ /dts-v1/; #include "ckp.dtsi" +#include / { @@ -13,7 +14,7 @@ compatible = "polarityworks,bt75_v1"; chosen { - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_75_ansi; }; @@ -59,3 +60,18 @@ >; }; }; + +&layout_75_ansi { + status = "okay"; + transform = <&ansi_transform>; +}; + +&layout_75_iso { + status = "okay"; + transform = <&iso_transform>; +}; + +&layout_75_all1u { + status = "okay"; + transform = <&all_1u_transform>; +}; diff --git a/app/boards/arm/ckp/bt75_v1.keymap b/app/boards/arm/ckp/bt75_v1.keymap index 888dcb643d9..ff0db7b0c0d 100644 --- a/app/boards/arm/ckp/bt75_v1.keymap +++ b/app/boards/arm/ckp/bt75_v1.keymap @@ -11,11 +11,11 @@ / { chosen { #ifdef ANSI - zmk,matrix-transform = &ansi_transform; + zmk,physical-layout = &layout_75_ansi; #elif defined(ISO) - zmk,matrix-transform = &iso_transform; + zmk,physical-layout = &layout_75_iso; #elif defined(ALL_1U) - zmk,matrix-transform = &all_1u_transform; + zmk,physical-layout = &layout_75_all1u; #else #error "Layout not defined, please define a layout using by uncommenting the appropriate line in bt75_v1.keymap" #endif From 91e1a7cfefc5e49a8d7284b6ac011162c1c1370a Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:09:54 +0100 Subject: [PATCH 22/42] feat(boards): Planck physical layout --- app/boards/arm/planck/planck_rev6.dts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/boards/arm/planck/planck_rev6.dts b/app/boards/arm/planck/planck_rev6.dts index 85b751400a1..d3aaf8fed6e 100644 --- a/app/boards/arm/planck/planck_rev6.dts +++ b/app/boards/arm/planck/planck_rev6.dts @@ -9,6 +9,9 @@ #include #include +#include + + / { model = "Plack PCD, rev6"; compatible = "planck,rev6", "st,stm32f303"; @@ -17,7 +20,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,kscan = &kscan0; - zmk,matrix-transform = &layout_grid_transform; + zmk,physical-layout = &layout_ortho_4x12_all1u; }; kscan0: kscan { @@ -137,3 +140,18 @@ zephyr_udc0: &usb { }; }; }; + +&layout_ortho_4x12_all1u { + status = "okay"; + transform = <&layout_grid_transform>; +}; + +&layout_ortho_4x12_1x2u { + status = "okay"; + transform = <&layout_mit_transform>; +}; + +&layout_ortho_4x12_2x2u { + status = "okay"; + transform = <&layout_2x2u_transform>; +}; From e80b1584de667371bc0c67270c7a50f9dad69a97 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:10:10 +0100 Subject: [PATCH 23/42] feat(boards): Preonic physical layout --- app/boards/arm/preonic/preonic_rev3.dts | 18 +++++++++++++++++- app/boards/arm/preonic/preonic_rev3.keymap | 1 - 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/boards/arm/preonic/preonic_rev3.dts b/app/boards/arm/preonic/preonic_rev3.dts index 79f88c33b0a..8032e459482 100644 --- a/app/boards/arm/preonic/preonic_rev3.dts +++ b/app/boards/arm/preonic/preonic_rev3.dts @@ -9,6 +9,7 @@ #include #include +#include / { model = "Preonic PCD, rev3"; @@ -18,7 +19,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,kscan = &kscan0; - zmk,matrix-transform = &layout_grid_transform; + zmk,physical-layout = &layout_ortho_5x12_all1u; }; kscan0: kscan_0 { @@ -131,3 +132,18 @@ zephyr_udc0: &usb { }; }; }; + +&layout_ortho_5x12_all1u { + status = "okay"; + transform = <&layout_grid_transform>; +}; + +&layout_ortho_5x12_1x2u { + status = "okay"; + transform = <&layout_mit_transform>; +}; + +&layout_ortho_5x12_2x2u { + status = "okay"; + transform = <&layout_2x2u_transform>; +}; diff --git a/app/boards/arm/preonic/preonic_rev3.keymap b/app/boards/arm/preonic/preonic_rev3.keymap index d25c5ca8f61..a3d85a94f80 100644 --- a/app/boards/arm/preonic/preonic_rev3.keymap +++ b/app/boards/arm/preonic/preonic_rev3.keymap @@ -13,7 +13,6 @@ #define RAISE 2 / { - chosen { zmk,matrix-transform = &layout_grid_transform; }; keymap { compatible = "zmk,keymap"; default_layer { From e68abe57d8b63219343c206f9116a70b150a9df4 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:27:46 +0100 Subject: [PATCH 24/42] feat(shields): Shield physical layouts --- .../boardsource5x12/boardsource5x12.overlay | 22 +++++++++++++++++- app/boards/shields/contra/contra.overlay | 23 ++++++++++++++++++- app/boards/shields/crbn/crbn.overlay | 19 +++++++++++++++ app/boards/shields/m60/m60.overlay | 7 +++++- 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/app/boards/shields/boardsource5x12/boardsource5x12.overlay b/app/boards/shields/boardsource5x12/boardsource5x12.overlay index 15ae7b68f25..2e2c22d8aa8 100644 --- a/app/boards/shields/boardsource5x12/boardsource5x12.overlay +++ b/app/boards/shields/boardsource5x12/boardsource5x12.overlay @@ -6,9 +6,25 @@ #include +#include + / { chosen { zmk,kscan = &kscan0; + zmk,physical-layout = &layout_ortho_5x12_all1u; + }; + + matrix_transform_50_all1u: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <12>; + rows = <5>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) + RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) + RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11) + >; }; kscan0: kscan { @@ -40,4 +56,8 @@ , <&pro_micro 6 GPIO_ACTIVE_HIGH> ; }; -}; \ No newline at end of file +}; + +&layout_ortho_5x12_all1u { + transform = <&matrix_transform_50_all1u>; +}; diff --git a/app/boards/shields/contra/contra.overlay b/app/boards/shields/contra/contra.overlay index 45cc3088f23..e304ea77799 100644 --- a/app/boards/shields/contra/contra.overlay +++ b/app/boards/shields/contra/contra.overlay @@ -4,9 +4,26 @@ * SPDX-License-Identifier: MIT */ +#include + +#include + / { chosen { zmk,kscan = &kscan0; + zmk,physical-layout = &layout_ortho_4x12_all1u; + }; + + matrix_transform_40_all1u: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <12>; + rows = <4>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) + RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) + >; }; kscan0: kscan_0 { @@ -37,4 +54,8 @@ , <&pro_micro 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; }; -}; \ No newline at end of file +}; + +&layout_ortho_4x12_all1u { + transform = <&matrix_transform_40_all1u>; +}; diff --git a/app/boards/shields/crbn/crbn.overlay b/app/boards/shields/crbn/crbn.overlay index c6a2b87c040..977bfadc27d 100644 --- a/app/boards/shields/crbn/crbn.overlay +++ b/app/boards/shields/crbn/crbn.overlay @@ -6,9 +6,24 @@ #include +#include + / { chosen { zmk,kscan = &kscan0; + zmk,physical-layout = &layout_ortho_4x12_all1u; + }; + + matrix_transform_40_all1u: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <12>; + rows = <4>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) + RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) + >; }; kscan0: kscan_0 { @@ -54,3 +69,7 @@ triggers-per-rotation = <20>; }; }; + +&layout_ortho_4x12_all1u { + transform = <&matrix_transform_40_all1u>; +}; diff --git a/app/boards/shields/m60/m60.overlay b/app/boards/shields/m60/m60.overlay index c479233cd52..15690f52406 100644 --- a/app/boards/shields/m60/m60.overlay +++ b/app/boards/shields/m60/m60.overlay @@ -6,10 +6,12 @@ #include +#include + / { chosen { zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &layout_60_ansi; }; kscan0: kscan { @@ -58,3 +60,6 @@ RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7 }; }; +&layout_60_ansi { + transform = <&default_transform>; +}; From a314128ea8e0d499b1a8118e195326318cbbfd79 Mon Sep 17 00:00:00 2001 From: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:06:00 +0200 Subject: [PATCH 25/42] docs: Pull encoders from new shield guide to its own page (#2510) Co-authored-by: Cem Aksoylar --- .../hardware-integration/encoders.md | 76 +++++++++++++++ .../hardware-integration/new-shield.mdx | 94 +------------------ docs/docs/features/encoders.md | 2 +- docs/sidebars.js | 1 + 4 files changed, 79 insertions(+), 94 deletions(-) create mode 100644 docs/docs/development/hardware-integration/encoders.md diff --git a/docs/docs/development/hardware-integration/encoders.md b/docs/docs/development/hardware-integration/encoders.md new file mode 100644 index 00000000000..16b489d1f6d --- /dev/null +++ b/docs/docs/development/hardware-integration/encoders.md @@ -0,0 +1,76 @@ +--- +title: EC11 Encoders +sidebar_label: Encoders +--- + +EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's configuration (.conf), devicetree (.dtsi/.overlay), and keymap (.keymap) files. + +## Configuration File + +In your configuration file you will need to add the following lines so that the encoders can be enabled/disabled: + +```ini +# Uncomment to enable encoder +# CONFIG_EC11=y +# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y +``` + +These should be commented by default for encoders that are optional/can be swapped with switches, but can be uncommented if encoders are part of the default design. + +:::note +If building locally for split boards, you may need to add these lines to the specific half's configuration file as well as the combined configuration file, see the [configuration overview](../../config/index.md) for details. +::: + +## Devicetree File + +In your devicetree file you will need to define each sensor with their properties. For split keyboards, do this in the .dtsi file that is shared by all parts; otherwise do it in the .dts (for boards) or .overlay (shields) file, see [configuration overview](../../config/index.md#devicetree-files) for details. Add the following lines: + +```dts + left_encoder: encoder_left { + compatible = "alps,ec11"; + a-gpios = ; + b-gpios = ; + steps = <80>; + status = "disabled"; + }; +``` + +Here you need to replace `PIN_A` and `PIN_B` with the appropriate pins that your PCB utilizes for the encoder(s). See shield overlays section in the [new shield guide](new-shield.mdx#shield-overlays) on the appropriate node label and pin number to use for GPIOs. + +The `steps` property should corresponded to the documented pulses per rotation for the encoders used on the keyboard, typically found on the datasheet of the component. If users use different encoders when they build, the value can be overridden in their keymap. + +Add additional encoders as necessary by duplicating the above lines, replacing `left` with whatever you would like to call your encoder, and updating the pins. + +Once you have defined the encoder sensors, you will have to add them to the list of sensors: + +```dts + sensors: sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&left_encoder &right_encoder>; + triggers-per-rotation = <20>; + }; +``` + +In this example, a `left_encoder` and `right_encoder` are both added. Additional encoders can be added with spaces separating each, and the order they are added here determines the order in which you define their behavior in your keymap. + +In addition, a default value for the number of times the sensors trigger the bound behavior per full rotation is set via the `triggers-per-rotation` property. See [Encoders Config](../../config/encoders.md#devicetree) for more details. + +Add the following lines to the .dts/.overlay file that contains the encoder to enable it: + +```dts +&left_encoder { + status = "okay"; +}; +``` + +Make sure to add this to the .dts/.overlay file, rather than any shared (.dtsi) files. + +## Keymap + +Add the following line to your keymap file to add default encoder behavior bindings: + +```dts +sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; +``` + +Add additional bindings as necessary to match the default number of encoders on your board. See the [Encoders](../../features/encoders.md) and [Keymaps](../../keymaps/index.mdx) documentation pages for more details. diff --git a/docs/docs/development/hardware-integration/new-shield.mdx b/docs/docs/development/hardware-integration/new-shield.mdx index 6d5921611ea..7a74f1bec83 100644 --- a/docs/docs/development/hardware-integration/new-shield.mdx +++ b/docs/docs/development/hardware-integration/new-shield.mdx @@ -28,9 +28,8 @@ The high level steps are: - Add a default keymap, which users can override in their own configs as needed. - Add a `.zmk.yml` metadata file to document the high level details of your shield, and the features it supports. - Update the `build.yaml` file from the repository template to have some sample builds of the firmware to test. -- Add support for features such as encoders, OLED displays, or RGB underglow. -It may be helpful to review the upstream [shields documentation](https://docs.zephyrproject.org/3.5.0/hardware/porting/shields.html#shields) to get a proper understanding of the underlying system before continuing. +After adding ZMK support for a basic shield using this guide, check the sidebar for guides on adding any additional features (such as encoders) that your keyboard has. It may be helpful to review the upstream [shields documentation](https://docs.zephyrproject.org/3.5.0/hardware/porting/shields.html#shields) to get a proper understanding of the underlying system before continuing. :::note ZMK support for [split keyboards](../../features/split-keyboards.md) requires a few more files than single boards to ensure proper connectivity between the central and peripheral units. Check the following guides thoroughly to ensure that all the files are in place. @@ -502,97 +501,6 @@ include: shield: _right ``` -## Adding Features - -### Encoders - -EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's configuration (.conf), device tree (.dtsi), overlay (.overlay), and keymap (.keymap) files. - - - - -In your configuration file you will need to add the following lines so that the encoders can be enabled/disabled: - -```ini -# Uncomment to enable encoder -# CONFIG_EC11=y -# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y -``` - -These should be commented by default for encoders that are optional/can be swapped with switches, but can be uncommented if encoders are part of the default design. - -:::note -If building locally for split boards, you may need to add these lines to the specific half's configuration file as well as the combined configuration file. -::: - - - -In your device tree file you will need to add the following lines to define the encoder sensor: - -```dts - left_encoder: encoder_left { - compatible = "alps,ec11"; - a-gpios = ; - b-gpios = ; - steps = <80>; - status = "disabled"; - }; -``` - -Here you need to replace `PIN_A` and `PIN_B` with the appropriate pins that your PCB utilizes for the encoder(s). See [shield overlays section above](#shield-overlays) on the appropriate node label and pin number to use for GPIOs. - -The `steps` property should corresponded to the documented pulses per rotation for the encoders used on the keyboard, typically found on the datasheet of the component. If users use different encoders when they build, the value can be overridden in their keymap. - -Add additional encoders as necessary by duplicating the above lines, replacing `left` with whatever you would like to call your encoder, and updating the pins. Note that support for peripheral (right) side sensors over BLE is still in progress. - -Once you have defined the encoder sensors, you will have to add them to the list of sensors: - -```dts - sensors: sensors { - compatible = "zmk,keymap-sensors"; - sensors = <&left_encoder &right_encoder>; - triggers-per-rotation = <20>; - }; -``` - -In this example, a left_encoder and right_encoder are both added. Additional encoders can be added with spaces separating each, and the order they are added here determines the order in which you define their behavior in your keymap. - -In addition, a default value for the number of times the sensors trigger the bound behavior per full rotation is set via the `triggers-per-rotation` property. See [Encoders Config](../../config/encoders.md#devicetree) for more details. - - - -Add the following lines to your overlay file(s) to enable the encoder: - -```dts -&left_encoder { - status = "okay"; -}; -``` - -:::note -For split keyboards, make sure to add left hand encoders to the left .overlay file and right hand encoders to the right .overlay file. -::: - - - -Add the following line to your keymap file to add default encoder behavior bindings: - -```dts -sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; -``` - -Add additional bindings as necessary to match the default number of encoders on your board. See the [Encoders](../../features/encoders.md) and [Keymaps](../../keymaps/index.mdx) documentation pages for more details. - - - - ## Testing ### GitHub Actions diff --git a/docs/docs/features/encoders.md b/docs/docs/features/encoders.md index 046973f478a..267f2e3db5b 100644 --- a/docs/docs/features/encoders.md +++ b/docs/docs/features/encoders.md @@ -41,4 +41,4 @@ Here, the left encoder is configured to control volume up and down while the rig ## Adding Encoder Support -See the [New Keyboard Shield](../development/hardware-integration/new-shield.mdx#encoders) documentation for how to add or modify additional encoders to your shield. +See the [Hardware Integration page for encoders](../development/hardware-integration/encoders.md) for instructions on adding them to your keyboard. diff --git a/docs/sidebars.js b/docs/sidebars.js index 8825746f451..9f67147149c 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -129,6 +129,7 @@ module.exports = { "development/hardware-integration/boards-shields-keymaps", "development/hardware-integration/studio-setup", "development/hardware-integration/shift-registers", + "development/hardware-integration/encoders", ], }, { From f618871f53fc146ec166a866249974eedc7f6b3b Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Wed, 28 Aug 2024 21:57:58 -0700 Subject: [PATCH 26/42] feat(shields): Add more shared layouts --- app/boards/shields/kyria/kyria-layout.dtsi | 137 +++++++++++++++++++++ app/dts/layouts/kata0510/lily58.dtsi | 69 +++++++++++ 2 files changed, 206 insertions(+) create mode 100644 app/boards/shields/kyria/kyria-layout.dtsi create mode 100644 app/dts/layouts/kata0510/lily58.dtsi diff --git a/app/boards/shields/kyria/kyria-layout.dtsi b/app/boards/shields/kyria/kyria-layout.dtsi new file mode 100644 index 00000000000..59079a86485 --- /dev/null +++ b/app/boards/shields/kyria/kyria-layout.dtsi @@ -0,0 +1,137 @@ +#include + +/ { + splitkb_kyria_6col_layout: splitkb_kyria_6col_layout { + compatible = "zmk,physical-layout"; + display-name = "6-column"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 75 0 0 0> + , <&key_physical_attrs 100 100 100 75 0 0 0> + , <&key_physical_attrs 100 100 200 25 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 25 0 0 0> + , <&key_physical_attrs 100 100 500 37 0 0 0> + , <&key_physical_attrs 100 100 1100 37 0 0 0> + , <&key_physical_attrs 100 100 1200 25 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 25 0 0 0> + , <&key_physical_attrs 100 100 1500 75 0 0 0> + , <&key_physical_attrs 100 100 1600 75 0 0 0> + , <&key_physical_attrs 100 100 0 175 0 0 0> + , <&key_physical_attrs 100 100 100 175 0 0 0> + , <&key_physical_attrs 100 100 200 125 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 125 0 0 0> + , <&key_physical_attrs 100 100 500 137 0 0 0> + , <&key_physical_attrs 100 100 1100 137 0 0 0> + , <&key_physical_attrs 100 100 1200 125 0 0 0> + , <&key_physical_attrs 100 100 1300 100 0 0 0> + , <&key_physical_attrs 100 100 1400 125 0 0 0> + , <&key_physical_attrs 100 100 1500 175 0 0 0> + , <&key_physical_attrs 100 100 1600 175 0 0 0> + , <&key_physical_attrs 100 100 0 275 0 0 0> + , <&key_physical_attrs 100 100 100 275 0 0 0> + , <&key_physical_attrs 100 100 200 225 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 225 0 0 0> + , <&key_physical_attrs 100 100 500 237 0 0 0> + , <&key_physical_attrs 100 100 350 225 3000 400 792> + , <&key_physical_attrs 100 100 350 225 4500 400 792> + , <&key_physical_attrs 100 100 1250 225 (-4500) 1300 792> + , <&key_physical_attrs 100 100 1250 225 (-3000) 1300 792> + , <&key_physical_attrs 100 100 1100 237 0 0 0> + , <&key_physical_attrs 100 100 1200 225 0 0 0> + , <&key_physical_attrs 100 100 1300 200 0 0 0> + , <&key_physical_attrs 100 100 1400 225 0 0 0> + , <&key_physical_attrs 100 100 1500 275 0 0 0> + , <&key_physical_attrs 100 100 1600 275 0 0 0> + , <&key_physical_attrs 100 100 250 325 0 0 0> + , <&key_physical_attrs 100 100 350 325 0 0 0> + , <&key_physical_attrs 100 100 350 325 1500 400 792> + , <&key_physical_attrs 100 100 350 325 3000 400 792> + , <&key_physical_attrs 100 100 350 325 4500 400 792> + , <&key_physical_attrs 100 100 1250 325 (-4500) 1300 792> + , <&key_physical_attrs 100 100 1250 325 (-3000) 1300 792> + , <&key_physical_attrs 100 100 1250 325 (-1500) 1300 792> + , <&key_physical_attrs 100 100 1250 325 0 0 0> + , <&key_physical_attrs 100 100 1350 325 0 0 0> + ; + }; + + splitkb_kyria_5col_layout: splitkb_kyria_5col_layout { + compatible = "zmk,physical-layout"; + display-name = "5-column"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 75 0 0 0> + , <&key_physical_attrs 100 100 100 25 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 25 0 0 0> + , <&key_physical_attrs 100 100 400 37 0 0 0> + , <&key_physical_attrs 100 100 1000 37 0 0 0> + , <&key_physical_attrs 100 100 1100 25 0 0 0> + , <&key_physical_attrs 100 100 1200 0 0 0 0> + , <&key_physical_attrs 100 100 1300 25 0 0 0> + , <&key_physical_attrs 100 100 1400 75 0 0 0> + , <&key_physical_attrs 100 100 0 175 0 0 0> + , <&key_physical_attrs 100 100 100 125 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 125 0 0 0> + , <&key_physical_attrs 100 100 400 137 0 0 0> + , <&key_physical_attrs 100 100 1000 137 0 0 0> + , <&key_physical_attrs 100 100 1100 125 0 0 0> + , <&key_physical_attrs 100 100 1200 100 0 0 0> + , <&key_physical_attrs 100 100 1300 125 0 0 0> + , <&key_physical_attrs 100 100 1400 175 0 0 0> + , <&key_physical_attrs 100 100 0 275 0 0 0> + , <&key_physical_attrs 100 100 100 225 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 225 0 0 0> + , <&key_physical_attrs 100 100 400 237 0 0 0> + , <&key_physical_attrs 100 100 250 225 3000 300 792> + , <&key_physical_attrs 100 100 250 225 4500 300 792> + , <&key_physical_attrs 100 100 1150 225 (-4500) 1200 792> + , <&key_physical_attrs 100 100 1150 225 (-3000) 1200 792> + , <&key_physical_attrs 100 100 1000 237 0 0 0> + , <&key_physical_attrs 100 100 1100 225 0 0 0> + , <&key_physical_attrs 100 100 1200 200 0 0 0> + , <&key_physical_attrs 100 100 1300 225 0 0 0> + , <&key_physical_attrs 100 100 1400 275 0 0 0> + , <&key_physical_attrs 100 100 150 325 0 0 0> + , <&key_physical_attrs 100 100 250 325 0 0 0> + , <&key_physical_attrs 100 100 250 325 1500 300 792> + , <&key_physical_attrs 100 100 250 325 3000 300 792> + , <&key_physical_attrs 100 100 250 325 4500 300 792> + , <&key_physical_attrs 100 100 1150 325 (-4500) 1200 792> + , <&key_physical_attrs 100 100 1150 325 (-3000) 1200 792> + , <&key_physical_attrs 100 100 1150 325 (-1500) 1200 792> + , <&key_physical_attrs 100 100 1150 325 0 0 0> + , <&key_physical_attrs 100 100 1250 325 0 0 0> + ; + }; + + splitkb_kyria_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + + twelve { + physical-layout = <&splitkb_kyria_6col_layout>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39> + , < 40 41 42 43 44 45 46 47 48 49 >; + }; + + ten { + physical-layout = <&splitkb_kyria_5col_layout>; + positions + = <44 0 1 2 3 4 5 6 7 8 9 47> + , <45 10 11 12 13 14 15 16 17 18 19 48> + , <46 20 21 22 23 24 25 26 27 28 29 30 31 32 33 49> + , < 34 35 36 37 38 39 40 41 42 43 >; + }; + }; +}; diff --git a/app/dts/layouts/kata0510/lily58.dtsi b/app/dts/layouts/kata0510/lily58.dtsi new file mode 100644 index 00000000000..7cb1f25eaf1 --- /dev/null +++ b/app/dts/layouts/kata0510/lily58.dtsi @@ -0,0 +1,69 @@ +#include + +/ { + kata0510_lily58_layout: kata0510_lily58_layout { + compatible = "zmk,physical-layout"; + display-name = "Default"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 50 0 0 0> + , <&key_physical_attrs 100 100 100 37 0 0 0> + , <&key_physical_attrs 100 100 200 12 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 12 0 0 0> + , <&key_physical_attrs 100 100 500 25 0 0 0> + , <&key_physical_attrs 100 100 1050 25 0 0 0> + , <&key_physical_attrs 100 100 1150 12 0 0 0> + , <&key_physical_attrs 100 100 1250 0 0 0 0> + , <&key_physical_attrs 100 100 1350 12 0 0 0> + , <&key_physical_attrs 100 100 1450 37 0 0 0> + , <&key_physical_attrs 100 100 1550 50 0 0 0> + , <&key_physical_attrs 100 100 0 150 0 0 0> + , <&key_physical_attrs 100 100 100 137 0 0 0> + , <&key_physical_attrs 100 100 200 112 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 112 0 0 0> + , <&key_physical_attrs 100 100 500 125 0 0 0> + , <&key_physical_attrs 100 100 1050 125 0 0 0> + , <&key_physical_attrs 100 100 1150 112 0 0 0> + , <&key_physical_attrs 100 100 1250 100 0 0 0> + , <&key_physical_attrs 100 100 1350 112 0 0 0> + , <&key_physical_attrs 100 100 1450 137 0 0 0> + , <&key_physical_attrs 100 100 1550 150 0 0 0> + , <&key_physical_attrs 100 100 0 250 0 0 0> + , <&key_physical_attrs 100 100 100 237 0 0 0> + , <&key_physical_attrs 100 100 200 212 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 212 0 0 0> + , <&key_physical_attrs 100 100 500 225 0 0 0> + , <&key_physical_attrs 100 100 1050 225 0 0 0> + , <&key_physical_attrs 100 100 1150 212 0 0 0> + , <&key_physical_attrs 100 100 1250 200 0 0 0> + , <&key_physical_attrs 100 100 1350 212 0 0 0> + , <&key_physical_attrs 100 100 1450 237 0 0 0> + , <&key_physical_attrs 100 100 1550 250 0 0 0> + , <&key_physical_attrs 100 100 0 350 0 0 0> + , <&key_physical_attrs 100 100 100 337 0 0 0> + , <&key_physical_attrs 100 100 200 312 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 312 0 0 0> + , <&key_physical_attrs 100 100 500 325 0 0 0> + , <&key_physical_attrs 100 100 600 275 0 0 0> + , <&key_physical_attrs 100 100 950 275 0 0 0> + , <&key_physical_attrs 100 100 1050 325 0 0 0> + , <&key_physical_attrs 100 100 1150 312 0 0 0> + , <&key_physical_attrs 100 100 1250 300 0 0 0> + , <&key_physical_attrs 100 100 1350 312 0 0 0> + , <&key_physical_attrs 100 100 1450 337 0 0 0> + , <&key_physical_attrs 100 100 1550 350 0 0 0> + , <&key_physical_attrs 100 100 250 412 0 0 0> + , <&key_physical_attrs 100 100 350 415 0 0 0> + , <&key_physical_attrs 100 100 450 425 0 0 0> + , <&key_physical_attrs 100 150 575 400 3000 625 475> + , <&key_physical_attrs 100 150 975 400 (-3000) 1025 475> + , <&key_physical_attrs 100 100 1100 425 0 0 0> + , <&key_physical_attrs 100 100 1200 415 0 0 0> + , <&key_physical_attrs 100 100 1300 415 0 0 0> + ; + }; +}; From dafdc44b223c9d9a62dc640e02af169083318af4 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Wed, 28 Aug 2024 22:10:26 -0700 Subject: [PATCH 27/42] feat(shields): Use new shared layouts --- app/boards/shields/kyria/kyria.dtsi | 12 ++++++++---- app/boards/shields/kyria/kyria_common.dtsi | 4 +++- app/boards/shields/kyria/kyria_rev2.dtsi | 12 ++++++++---- app/boards/shields/kyria/kyria_rev3.dtsi | 12 ++++++++---- app/boards/shields/lily58/lily58.dtsi | 8 +++++++- .../splitkb_aurora_lily58/splitkb_aurora_lily58.dtsi | 8 +++++++- 6 files changed, 41 insertions(+), 15 deletions(-) diff --git a/app/boards/shields/kyria/kyria.dtsi b/app/boards/shields/kyria/kyria.dtsi index 8934776facb..72814a9e557 100644 --- a/app/boards/shields/kyria/kyria.dtsi +++ b/app/boards/shields/kyria/kyria.dtsi @@ -6,11 +6,15 @@ #include "kyria_common.dtsi" -/ { - chosen { - zmk,matrix-transform = &default_transform; - }; +&splitkb_kyria_6col_layout { + transform = <&default_transform>; +}; +&splitkb_kyria_5col_layout { + transform = <&five_column_transform>; +}; + +/ { default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <16>; diff --git a/app/boards/shields/kyria/kyria_common.dtsi b/app/boards/shields/kyria/kyria_common.dtsi index f662fa1c402..661d1ff506e 100644 --- a/app/boards/shields/kyria/kyria_common.dtsi +++ b/app/boards/shields/kyria/kyria_common.dtsi @@ -6,11 +6,13 @@ #include +#include "kyria-layout.dtsi" + / { chosen { zephyr,display = &oled; zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &splitkb_kyria_6col_layout; }; kscan0: kscan { diff --git a/app/boards/shields/kyria/kyria_rev2.dtsi b/app/boards/shields/kyria/kyria_rev2.dtsi index c2586faf997..c1c46bd1a1f 100644 --- a/app/boards/shields/kyria/kyria_rev2.dtsi +++ b/app/boards/shields/kyria/kyria_rev2.dtsi @@ -6,11 +6,15 @@ #include "kyria_common.dtsi" -/ { - chosen { - zmk,matrix-transform = &default_transform; - }; +&splitkb_kyria_6col_layout { + transform = <&default_transform>; +}; +&splitkb_kyria_5col_layout { + transform = <&five_column_transform>; +}; + +/ { default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <16>; diff --git a/app/boards/shields/kyria/kyria_rev3.dtsi b/app/boards/shields/kyria/kyria_rev3.dtsi index c8cd8df910b..33395871169 100644 --- a/app/boards/shields/kyria/kyria_rev3.dtsi +++ b/app/boards/shields/kyria/kyria_rev3.dtsi @@ -6,11 +6,15 @@ #include "kyria_common.dtsi" -/ { - chosen { - zmk,matrix-transform = &default_transform; - }; +&splitkb_kyria_6col_layout { + transform = <&default_transform>; +}; +&splitkb_kyria_5col_layout { + status = "disabled"; +}; + +/ { default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <14>; diff --git a/app/boards/shields/lily58/lily58.dtsi b/app/boards/shields/lily58/lily58.dtsi index c82b197cc51..195ab2b73b5 100644 --- a/app/boards/shields/lily58/lily58.dtsi +++ b/app/boards/shields/lily58/lily58.dtsi @@ -6,11 +6,13 @@ #include +#include + / { chosen { zephyr,display = &oled; zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &kata0510_lily58_layout; }; default_transform: keymap_transform_0 { @@ -60,6 +62,10 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) }; }; +&kata0510_lily58_layout { + transform = <&default_transform>; +}; + &pro_micro_i2c { status = "okay"; diff --git a/app/boards/shields/splitkb_aurora_lily58/splitkb_aurora_lily58.dtsi b/app/boards/shields/splitkb_aurora_lily58/splitkb_aurora_lily58.dtsi index 93625d28c97..b270890d222 100644 --- a/app/boards/shields/splitkb_aurora_lily58/splitkb_aurora_lily58.dtsi +++ b/app/boards/shields/splitkb_aurora_lily58/splitkb_aurora_lily58.dtsi @@ -6,11 +6,13 @@ #include +#include + / { chosen { zephyr,display = &oled; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &kata0510_lily58_layout; }; default_transform: keymap_transform_0 { @@ -56,6 +58,10 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,1) RC(4,10) RC(3,6) RC(3,7) }; }; +&kata0510_lily58_layout { + transform = <&default_transform>; +}; + &pro_micro_i2c { status = "okay"; From 552d665f58e4f79d1497b977be679fc3fd1a70d2 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Wed, 28 Aug 2024 22:16:29 -0700 Subject: [PATCH 28/42] feat(boards): Add glove80 and adv360pro layouts --- app/boards/arm/adv360pro/adv360pro.dtsi | 90 +++++++++++++++++++++++- app/boards/arm/glove80/glove80.dtsi | 93 ++++++++++++++++++++++++- 2 files changed, 181 insertions(+), 2 deletions(-) diff --git a/app/boards/arm/adv360pro/adv360pro.dtsi b/app/boards/arm/adv360pro/adv360pro.dtsi index ea68624b981..b979e9a5736 100644 --- a/app/boards/arm/adv360pro/adv360pro.dtsi +++ b/app/boards/arm/adv360pro/adv360pro.dtsi @@ -11,6 +11,8 @@ #include #include +#include + #include "adv360pro-pinctrl.dtsi" / { @@ -24,7 +26,7 @@ zmk,kscan = &kscan0; zmk,backlight = &backlight; zmk,battery = &vbatt; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &default_layout; zmk,underglow = &led_strip; }; @@ -44,6 +46,92 @@ >; }; + default_layout: default_layout { + compatible = "zmk,physical-layout"; + display-name = "Default"; + + transform = <&default_transform>; + + keys // w h x y rot rx ry + = <&key_physical_attrs 125 100 0 25 0 0 0> + , <&key_physical_attrs 100 100 125 25 0 0 0> + , <&key_physical_attrs 100 100 225 0 0 0 0> + , <&key_physical_attrs 100 100 325 0 0 0 0> + , <&key_physical_attrs 100 100 425 0 0 0 0> + , <&key_physical_attrs 100 100 525 0 0 0 0> + , <&key_physical_attrs 100 100 625 0 0 0 0> + , <&key_physical_attrs 100 100 1075 0 0 0 0> + , <&key_physical_attrs 100 100 1175 0 0 0 0> + , <&key_physical_attrs 100 100 1275 0 0 0 0> + , <&key_physical_attrs 100 100 1375 0 0 0 0> + , <&key_physical_attrs 100 100 1475 0 0 0 0> + , <&key_physical_attrs 100 100 1575 25 0 0 0> + , <&key_physical_attrs 125 100 1675 25 0 0 0> + , <&key_physical_attrs 125 100 0 125 0 0 0> + , <&key_physical_attrs 100 100 125 125 0 0 0> + , <&key_physical_attrs 100 100 225 100 0 0 0> + , <&key_physical_attrs 100 100 325 100 0 0 0> + , <&key_physical_attrs 100 100 425 100 0 0 0> + , <&key_physical_attrs 100 100 525 100 0 0 0> + , <&key_physical_attrs 100 100 625 100 0 0 0> + , <&key_physical_attrs 100 100 1075 100 0 0 0> + , <&key_physical_attrs 100 100 1175 100 0 0 0> + , <&key_physical_attrs 100 100 1275 100 0 0 0> + , <&key_physical_attrs 100 100 1375 100 0 0 0> + , <&key_physical_attrs 100 100 1475 100 0 0 0> + , <&key_physical_attrs 100 100 1575 125 0 0 0> + , <&key_physical_attrs 125 100 1675 125 0 0 0> + , <&key_physical_attrs 125 100 0 225 0 0 0> + , <&key_physical_attrs 100 100 125 225 0 0 0> + , <&key_physical_attrs 100 100 225 200 0 0 0> + , <&key_physical_attrs 100 100 325 200 0 0 0> + , <&key_physical_attrs 100 100 425 200 0 0 0> + , <&key_physical_attrs 100 100 525 200 0 0 0> + , <&key_physical_attrs 100 100 625 200 0 0 0> + , <&key_physical_attrs 100 100 675 400 1500 525 400> + , <&key_physical_attrs 100 100 775 400 1500 525 400> + , <&key_physical_attrs 100 100 925 400 (-1500) 1275 400> + , <&key_physical_attrs 100 100 1025 400 (-1500) 1275 400> + , <&key_physical_attrs 100 100 1075 200 0 0 0> + , <&key_physical_attrs 100 100 1175 200 0 0 0> + , <&key_physical_attrs 100 100 1275 200 0 0 0> + , <&key_physical_attrs 100 100 1375 200 0 0 0> + , <&key_physical_attrs 100 100 1475 200 0 0 0> + , <&key_physical_attrs 100 100 1575 225 0 0 0> + , <&key_physical_attrs 125 100 1675 225 0 0 0> + , <&key_physical_attrs 125 100 0 325 0 0 0> + , <&key_physical_attrs 100 100 125 325 0 0 0> + , <&key_physical_attrs 100 100 225 300 0 0 0> + , <&key_physical_attrs 100 100 325 300 0 0 0> + , <&key_physical_attrs 100 100 425 300 0 0 0> + , <&key_physical_attrs 100 100 525 300 0 0 0> + , <&key_physical_attrs 100 100 775 500 1500 525 400> + , <&key_physical_attrs 100 100 925 500 (-1500) 1275 400> + , <&key_physical_attrs 100 100 1175 300 0 0 0> + , <&key_physical_attrs 100 100 1275 300 0 0 0> + , <&key_physical_attrs 100 100 1375 300 0 0 0> + , <&key_physical_attrs 100 100 1475 300 0 0 0> + , <&key_physical_attrs 100 100 1575 325 0 0 0> + , <&key_physical_attrs 125 100 1675 325 0 0 0> + , <&key_physical_attrs 125 100 0 425 0 0 0> + , <&key_physical_attrs 100 100 125 425 0 0 0> + , <&key_physical_attrs 100 100 225 400 0 0 0> + , <&key_physical_attrs 100 100 325 400 0 0 0> + , <&key_physical_attrs 100 100 425 400 0 0 0> + , <&key_physical_attrs 100 200 575 500 1500 525 400> + , <&key_physical_attrs 100 200 675 500 1500 525 400> + , <&key_physical_attrs 100 100 775 600 1500 525 400> + , <&key_physical_attrs 100 100 925 600 (-1500) 1275 400> + , <&key_physical_attrs 100 200 1025 500 (-1500) 1275 400> + , <&key_physical_attrs 100 200 1125 500 (-1500) 1275 400> + , <&key_physical_attrs 100 100 1275 400 0 0 0> + , <&key_physical_attrs 100 100 1375 400 0 0 0> + , <&key_physical_attrs 100 100 1475 400 0 0 0> + , <&key_physical_attrs 100 100 1575 425 0 0 0> + , <&key_physical_attrs 125 100 1675 425 0 0 0> + ; + }; + // Node name must match original "EXT_POWER" label to preserve user settings. EXT_POWER { compatible = "zmk,ext-power-generic"; diff --git a/app/boards/arm/glove80/glove80.dtsi b/app/boards/arm/glove80/glove80.dtsi index d51a73ac066..fdf890adc51 100644 --- a/app/boards/arm/glove80/glove80.dtsi +++ b/app/boards/arm/glove80/glove80.dtsi @@ -8,10 +8,12 @@ #include +#include + / { chosen { zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &default_layout; zephyr,code-partition = &code_partition; zephyr,sram = &sram0; zephyr,flash = &flash0; @@ -40,6 +42,95 @@ debounce-release-ms = <20>; }; + default_layout: default_layout { + compatible = "zmk,physical-layout"; + display-name = "Default"; + + transform = <&default_transform>; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 50 0 0 0> + , <&key_physical_attrs 100 100 100 50 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 0 0 0 0> + , <&key_physical_attrs 100 100 1300 0 0 0 0> + , <&key_physical_attrs 100 100 1400 0 0 0 0> + , <&key_physical_attrs 100 100 1500 0 0 0 0> + , <&key_physical_attrs 100 100 1600 50 0 0 0> + , <&key_physical_attrs 100 100 1700 50 0 0 0> + , <&key_physical_attrs 100 100 0 150 0 0 0> + , <&key_physical_attrs 100 100 100 150 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 100 0 0 0> + , <&key_physical_attrs 100 100 500 100 0 0 0> + , <&key_physical_attrs 100 100 1200 100 0 0 0> + , <&key_physical_attrs 100 100 1300 100 0 0 0> + , <&key_physical_attrs 100 100 1400 100 0 0 0> + , <&key_physical_attrs 100 100 1500 100 0 0 0> + , <&key_physical_attrs 100 100 1600 150 0 0 0> + , <&key_physical_attrs 100 100 1700 150 0 0 0> + , <&key_physical_attrs 100 100 0 250 0 0 0> + , <&key_physical_attrs 100 100 100 250 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 200 0 0 0> + , <&key_physical_attrs 100 100 500 200 0 0 0> + , <&key_physical_attrs 100 100 1200 200 0 0 0> + , <&key_physical_attrs 100 100 1300 200 0 0 0> + , <&key_physical_attrs 100 100 1400 200 0 0 0> + , <&key_physical_attrs 100 100 1500 200 0 0 0> + , <&key_physical_attrs 100 100 1600 250 0 0 0> + , <&key_physical_attrs 100 100 1700 250 0 0 0> + , <&key_physical_attrs 100 100 0 350 0 0 0> + , <&key_physical_attrs 100 100 100 350 0 0 0> + , <&key_physical_attrs 100 100 200 300 0 0 0> + , <&key_physical_attrs 100 100 300 300 0 0 0> + , <&key_physical_attrs 100 100 400 300 0 0 0> + , <&key_physical_attrs 100 100 500 300 0 0 0> + , <&key_physical_attrs 100 100 1200 300 0 0 0> + , <&key_physical_attrs 100 100 1300 300 0 0 0> + , <&key_physical_attrs 100 100 1400 300 0 0 0> + , <&key_physical_attrs 100 100 1500 300 0 0 0> + , <&key_physical_attrs 100 100 1600 350 0 0 0> + , <&key_physical_attrs 100 100 1700 350 0 0 0> + , <&key_physical_attrs 100 100 0 450 0 0 0> + , <&key_physical_attrs 100 100 100 450 0 0 0> + , <&key_physical_attrs 100 100 200 400 0 0 0> + , <&key_physical_attrs 100 100 300 400 0 0 0> + , <&key_physical_attrs 100 100 400 400 0 0 0> + , <&key_physical_attrs 100 100 500 400 0 0 0> + , <&key_physical_attrs 100 100 400 450 3000 450 925> + , <&key_physical_attrs 100 100 400 450 4500 450 925> + , <&key_physical_attrs 100 100 400 450 6000 450 925> + , <&key_physical_attrs 100 100 1300 450 (-6000) 1350 925> + , <&key_physical_attrs 100 100 1300 450 (-4500) 1350 925> + , <&key_physical_attrs 100 100 1300 450 (-3000) 1350 925> + , <&key_physical_attrs 100 100 1200 400 0 0 0> + , <&key_physical_attrs 100 100 1300 400 0 0 0> + , <&key_physical_attrs 100 100 1400 400 0 0 0> + , <&key_physical_attrs 100 100 1500 400 0 0 0> + , <&key_physical_attrs 100 100 1600 450 0 0 0> + , <&key_physical_attrs 100 100 1700 450 0 0 0> + , <&key_physical_attrs 100 100 0 550 0 0 0> + , <&key_physical_attrs 100 100 100 550 0 0 0> + , <&key_physical_attrs 100 100 200 500 0 0 0> + , <&key_physical_attrs 100 100 300 500 0 0 0> + , <&key_physical_attrs 100 100 400 500 0 0 0> + , <&key_physical_attrs 100 100 400 550 2000 450 925> + , <&key_physical_attrs 100 100 400 550 4000 450 925> + , <&key_physical_attrs 100 100 400 550 6000 450 925> + , <&key_physical_attrs 100 100 1300 550 (-6000) 1350 925> + , <&key_physical_attrs 100 100 1300 550 (-4000) 1350 925> + , <&key_physical_attrs 100 100 1300 550 (-2000) 1350 925> + , <&key_physical_attrs 100 100 1300 500 0 0 0> + , <&key_physical_attrs 100 100 1400 500 0 0 0> + , <&key_physical_attrs 100 100 1500 500 0 0 0> + , <&key_physical_attrs 100 100 1600 550 0 0 0> + , <&key_physical_attrs 100 100 1700 550 0 0 0> + ; + }; }; &adc { From 907b1caaa69b63db874767bf1728f068989d9f46 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Sat, 28 Sep 2024 14:45:34 -0700 Subject: [PATCH 29/42] refactor(shields): Add physical layout chosen nodes for consistency --- .../shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi | 1 + .../shields/splitkb_aurora_sofle/splitkb_aurora_sofle.dtsi | 1 + .../shields/splitkb_aurora_sweep/splitkb_aurora_sweep.dtsi | 1 + 3 files changed, 3 insertions(+) diff --git a/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi b/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi index d63cdf21406..0b0ffdf357b 100644 --- a/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi +++ b/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi @@ -20,6 +20,7 @@ chosen { zephyr,display = &oled; + zmk,physical-layout = &foostan_corne_6col_layout; }; default_transform: keymap_transform_0 { diff --git a/app/boards/shields/splitkb_aurora_sofle/splitkb_aurora_sofle.dtsi b/app/boards/shields/splitkb_aurora_sofle/splitkb_aurora_sofle.dtsi index e360528f340..a40d29ae58b 100644 --- a/app/boards/shields/splitkb_aurora_sofle/splitkb_aurora_sofle.dtsi +++ b/app/boards/shields/splitkb_aurora_sofle/splitkb_aurora_sofle.dtsi @@ -16,6 +16,7 @@ chosen { zephyr,display = &oled; + zmk,physical-layout = &josefadamcik_sofle_layout; }; default_transform: keymap_transform_0 { diff --git a/app/boards/shields/splitkb_aurora_sweep/splitkb_aurora_sweep.dtsi b/app/boards/shields/splitkb_aurora_sweep/splitkb_aurora_sweep.dtsi index 4e1a0a97df6..c00b73f9ca9 100644 --- a/app/boards/shields/splitkb_aurora_sweep/splitkb_aurora_sweep.dtsi +++ b/app/boards/shields/splitkb_aurora_sweep/splitkb_aurora_sweep.dtsi @@ -15,6 +15,7 @@ / { chosen { zephyr,display = &oled; + zmk,physical-layout = &cuddlykeyboards_ferris_layout; }; default_transform: keymap_transform_0 { From 608b6458a9a158d51179b6b22b34a5a9b5d2d137 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Sat, 28 Sep 2024 15:04:47 -0700 Subject: [PATCH 30/42] feat(boards): Add physical layout to Corne-ish Zen --- app/boards/arm/corneish_zen/corneish_zen.dtsi | 12 +++++++++++- app/boards/arm/corneish_zen/corneish_zen.keymap | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/boards/arm/corneish_zen/corneish_zen.dtsi b/app/boards/arm/corneish_zen/corneish_zen.dtsi index dbd6f93e805..119781a29d5 100644 --- a/app/boards/arm/corneish_zen/corneish_zen.dtsi +++ b/app/boards/arm/corneish_zen/corneish_zen.dtsi @@ -10,6 +10,16 @@ #include +#include + +&foostan_corne_6col_layout { + transform = <&default_transform>; +}; + +&foostan_corne_5col_layout { + transform = <&five_column_transform>; +}; + / { model = "Corne-ish Zen"; compatible = "corneish_zen"; @@ -20,7 +30,7 @@ zephyr,flash = &flash0; zmk,kscan = &kscan0; zmk,display = &epd; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = &foostan_corne_6col_layout; }; default_transform: keymap_transform_0 { diff --git a/app/boards/arm/corneish_zen/corneish_zen.keymap b/app/boards/arm/corneish_zen/corneish_zen.keymap index 8dbb7d3b9af..d53045ebc6f 100644 --- a/app/boards/arm/corneish_zen/corneish_zen.keymap +++ b/app/boards/arm/corneish_zen/corneish_zen.keymap @@ -11,8 +11,8 @@ / { chosen { - zmk,matrix-transform = &default_transform; - // zmk,matrix-transform = &five_column_transform; + zmk,physical-layout = &foostan_corne_6col_layout; + // zmk,physical-layout = &foostan_corne_5col_layout; }; }; From 59c82ef27a6538408117762f0663a12039ce0b55 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Mon, 30 Sep 2024 09:45:06 -0700 Subject: [PATCH 31/42] refactor(shields): Use space not hyphen for layout names --- app/boards/shields/kyria/kyria-layout.dtsi | 4 ++-- app/dts/layouts/foostan/corne.dtsi | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/boards/shields/kyria/kyria-layout.dtsi b/app/boards/shields/kyria/kyria-layout.dtsi index 59079a86485..4c0c37e7c12 100644 --- a/app/boards/shields/kyria/kyria-layout.dtsi +++ b/app/boards/shields/kyria/kyria-layout.dtsi @@ -3,7 +3,7 @@ / { splitkb_kyria_6col_layout: splitkb_kyria_6col_layout { compatible = "zmk,physical-layout"; - display-name = "6-column"; + display-name = "6 Column"; keys // w h x y rot rx ry = <&key_physical_attrs 100 100 0 75 0 0 0> @@ -61,7 +61,7 @@ splitkb_kyria_5col_layout: splitkb_kyria_5col_layout { compatible = "zmk,physical-layout"; - display-name = "5-column"; + display-name = "5 Column"; keys // w h x y rot rx ry = <&key_physical_attrs 100 100 0 75 0 0 0> diff --git a/app/dts/layouts/foostan/corne.dtsi b/app/dts/layouts/foostan/corne.dtsi index ddafc789960..5a644103e04 100644 --- a/app/dts/layouts/foostan/corne.dtsi +++ b/app/dts/layouts/foostan/corne.dtsi @@ -3,7 +3,7 @@ / { foostan_corne_6col_layout: foostan_corne_6col_layout { compatible = "zmk,physical-layout"; - display-name = "6-column"; + display-name = "6 Column"; keys // w h x y rot rx ry = <&key_physical_attrs 100 100 0 37 0 0 0> @@ -53,7 +53,7 @@ foostan_corne_5col_layout: foostan_corne_5col_layout { compatible = "zmk,physical-layout"; - display-name = "5-column"; + display-name = "5 Column"; keys // w h x y rot rx ry = <&key_physical_attrs 100 100 0 37 0 0 0> @@ -118,4 +118,4 @@ , < 30 31 32 33 34 35 >; }; }; -}; \ No newline at end of file +}; From 7276fd525ff90a82444a9c6e8e29906bb124fa53 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 30 Sep 2024 10:21:28 -0600 Subject: [PATCH 32/42] feat: Build asserts for requires studio layout bits. * When building with ZMK Studio, assert that we have physical layouts, and those layouts have key information set. --- app/src/physical_layouts.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/physical_layouts.c b/app/src/physical_layouts.c index 59077ede27e..6e719d29a27 100644 --- a/app/src/physical_layouts.c +++ b/app/src/physical_layouts.c @@ -29,6 +29,11 @@ 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. " + "See https://zmk.dev/docs/development/hardware-integration/studio-setup"); + #if USE_PHY_LAYOUTS #define ZKPA_INIT(i, n) \ @@ -43,6 +48,9 @@ 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. See " \ + "https://zmk.dev/docs/development/hardware-integration/studio-setup"); \ 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)}; \ From 8c21e7766df71e465eb10f4962b602836d1ccb00 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 30 Sep 2024 10:39:13 -0600 Subject: [PATCH 33/42] feat: Add physical layout to BDN9 rev2. --- app/boards/arm/bdn9/bdn9_rev2.dts | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/boards/arm/bdn9/bdn9_rev2.dts b/app/boards/arm/bdn9/bdn9_rev2.dts index 12059c418a4..6274b834166 100644 --- a/app/boards/arm/bdn9/bdn9_rev2.dts +++ b/app/boards/arm/bdn9/bdn9_rev2.dts @@ -9,6 +9,10 @@ #include #include +#include + +#include + / { model = "Keeb.io BDN9 rev2"; compatible = "keebio,bdn9", "st,stm32f072"; @@ -20,6 +24,38 @@ zmk,underglow = &led_strip; }; + matrix_transform: matrix_transform { + compatible = "zmk,matrix-transform"; + + compatible = "zmk,matrix-transform"; + columns = <3>; + rows = <3>; + map = < + RC(0,0) RC(0,1) RC(0,2) + RC(0,3) RC(0,4) RC(0,5) + RC(0,6) RC(0,7) RC(0,8) + >; + }; + + physical_layout { + compatible = "zmk,physical-layout"; + + display-name = "BDN9"; + transform = <&matrix_transform>; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + ; + }; + kscan: kscan { compatible = "zmk,kscan-gpio-direct"; From ce04352e2f0c3ac7a2e0c51fe80439059bdee432 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 30 Sep 2024 11:23:15 -0600 Subject: [PATCH 34/42] feat: Add reviung41 physical layout. --- .../shields/reviung41/reviung41.overlay | 8 ++- app/dts/layouts/gtips/reviung41.dtsi | 55 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 app/dts/layouts/gtips/reviung41.dtsi diff --git a/app/boards/shields/reviung41/reviung41.overlay b/app/boards/shields/reviung41/reviung41.overlay index f8503fc35a8..b8a499e9762 100644 --- a/app/boards/shields/reviung41/reviung41.overlay +++ b/app/boards/shields/reviung41/reviung41.overlay @@ -6,10 +6,16 @@ #include +#include + +>ips_reviung41_layout { + transform = <&default_transform>; +}; + / { chosen { zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; + zmk,physical-layout = >ips_reviung41_layout; }; default_transform: keymap_transform_0 { diff --git a/app/dts/layouts/gtips/reviung41.dtsi b/app/dts/layouts/gtips/reviung41.dtsi new file mode 100644 index 00000000000..08f45b3c1c5 --- /dev/null +++ b/app/dts/layouts/gtips/reviung41.dtsi @@ -0,0 +1,55 @@ +#include + +/ { + gtips_reviung41_layout: gtips_reviung41_layout { + compatible = "zmk,physical-layout"; + display-name = "reviung41"; + + keys + = <&key_physical_attrs 100 100 000 53 700 400 338> + , <&key_physical_attrs 100 100 100 53 700 400 338> + , <&key_physical_attrs 100 100 200 28 700 400 338> + , <&key_physical_attrs 100 100 300 03 700 400 338> + , <&key_physical_attrs 100 100 400 28 700 400 338> + , <&key_physical_attrs 100 100 500 38 700 400 338> + , <&key_physical_attrs 100 100 700 38 (-700) 900 338> + , <&key_physical_attrs 100 100 800 28 (-700) 900 338> + , <&key_physical_attrs 100 100 900 03 (-700) 900 338> + , <&key_physical_attrs 100 100 1000 28 (-700) 900 338> + , <&key_physical_attrs 100 100 1100 53 (-700) 900 338> + , <&key_physical_attrs 100 100 1200 53 (-700) 900 338> + + , <&key_physical_attrs 100 100 000 153 700 400 338> + , <&key_physical_attrs 100 100 100 153 700 400 338> + , <&key_physical_attrs 100 100 200 128 700 400 338> + , <&key_physical_attrs 100 100 300 103 700 400 338> + , <&key_physical_attrs 100 100 400 128 700 400 338> + , <&key_physical_attrs 100 100 500 138 700 400 338> + , <&key_physical_attrs 100 100 700 138 (-700) 900 338> + , <&key_physical_attrs 100 100 800 128 (-700) 900 338> + , <&key_physical_attrs 100 100 900 103 (-700) 900 338> + , <&key_physical_attrs 100 100 1000 128 (-700) 900 338> + , <&key_physical_attrs 100 100 1100 153 (-700) 900 338> + , <&key_physical_attrs 100 100 1200 153 (-700) 900 338> + + , <&key_physical_attrs 100 100 000 253 700 400 338> + , <&key_physical_attrs 100 100 100 253 700 400 338> + , <&key_physical_attrs 100 100 200 228 700 400 338> + , <&key_physical_attrs 100 100 300 203 700 400 338> + , <&key_physical_attrs 100 100 400 228 700 400 338> + , <&key_physical_attrs 100 100 500 238 700 400 338> + , <&key_physical_attrs 100 100 700 238 (-700) 900 338> + , <&key_physical_attrs 100 100 800 228 (-700) 900 338> + , <&key_physical_attrs 100 100 900 203 (-700) 900 338> + , <&key_physical_attrs 100 100 1000 228 (-700) 900 338> + , <&key_physical_attrs 100 100 1100 253 (-700) 900 338> + , <&key_physical_attrs 100 100 1200 253 (-700) 900 338> + + , <&key_physical_attrs 100 100 339 338 0 0 0> + , <&key_physical_attrs 100 100 450 365 700 500 415> + , <&key_physical_attrs 200 100 555 394 0 0 0> + , <&key_physical_attrs 100 100 760 365 (-700) 710 415> + , <&key_physical_attrs 100 100 871 338 0 0 0> + ; + }; +}; \ No newline at end of file From 99b424bb4b53af922f50bd0e483d722c6b401660 Mon Sep 17 00:00:00 2001 From: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com> Date: Tue, 1 Oct 2024 00:00:55 +0200 Subject: [PATCH 35/42] docs: Streamlined the new shield guide (#2515) * docs: Streamlined the new shield guide --------- Co-authored-by: Cem Aksoylar --- .../hardware-integration/new-shield.mdx | 622 ++++++++++-------- docs/docs/keymap-example-file.md | 26 - 2 files changed, 331 insertions(+), 317 deletions(-) delete mode 100644 docs/docs/keymap-example-file.md diff --git a/docs/docs/development/hardware-integration/new-shield.mdx b/docs/docs/development/hardware-integration/new-shield.mdx index 7a74f1bec83..1587cbc56ed 100644 --- a/docs/docs/development/hardware-integration/new-shield.mdx +++ b/docs/docs/development/hardware-integration/new-shield.mdx @@ -4,36 +4,62 @@ title: New Keyboard Shield import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -import KeymapExampleFile from "../../keymap-example-file.md"; - import InterconnectTabs from "@site/src/components/interconnect-tabs"; import Metadata from "@site/src/data/hardware-metadata.json"; +export const SplitTabs = (props) => ( + + {/* eslint-disable-next-line */} + {props.children} + + +); + +export const SplitInvisTabs = (props) => ( + + {/* eslint-disable-next-line */} + {props.children} + + +); + :::danger Before reading this section, it is **vital** that you read through our [clean room policy](../contributing/clean-room.md). ::: -## Overview - This guide will walk through the steps necessary to add ZMK support for a keyboard that uses an add-on MCU board (e.g. Pro Micro compatible) to provide the microprocessor. The high level steps are: -- From a template, create a new [Zephyr module](https://docs.zephyrproject.org/3.5.0/develop/modules.html) housed in a git repository containing one or more custom shields. +- Create a new [Zephyr module](https://docs.zephyrproject.org/3.5.0/develop/modules.html) to contain your shield. - Create a new shield directory. - Add the base Kconfig files. -- Add the shield overlay file to define the KSCAN driver for detecting key press/release. -- Add the matrix transform for mapping KSCAN row/column values to key positions in the keymap. -- Add a physical layout definition to select the matrix transform and KSCAN instance. +- Add the shield overlay file defining: + - The keyboard scan driver for detecting key press/release. + - The matrix transform for mapping keyboard scan row/column values to key positions in the keymap. + - The physical layout definition to select the matrix transform and keyboard scan instance. - Add a default keymap, which users can override in their own configs as needed. - Add a `.zmk.yml` metadata file to document the high level details of your shield, and the features it supports. -- Update the `build.yaml` file from the repository template to have some sample builds of the firmware to test. -After adding ZMK support for a basic shield using this guide, check the sidebar for guides on adding any additional features (such as encoders) that your keyboard has. It may be helpful to review the upstream [shields documentation](https://docs.zephyrproject.org/3.5.0/hardware/porting/shields.html#shields) to get a proper understanding of the underlying system before continuing. +Many of the above files will differ depending on whether your keyboard is a unibody or is [split into multiple parts](../../features/split-keyboards.md). -:::note -ZMK support for [split keyboards](../../features/split-keyboards.md) requires a few more files than single boards to ensure proper connectivity between the central and peripheral units. Check the following guides thoroughly to ensure that all the files are in place. -::: +After adding ZMK support for a basic shield using this guide, check the sidebar for guides on adding any additional features (such as encoders) that your keyboard has. +It may be helpful to review the upstream [shields documentation](https://docs.zephyrproject.org/3.5.0/hardware/porting/shields.html#shields) to get a proper understanding of the underlying system before continuing. ## New Zephyr Module Repository @@ -54,12 +80,14 @@ Follow these steps to create your new repository: - Select Public or Private, depending on your preference. - Click the green "Create repository" button -The repository is a combination of the directories and files required of a ZMK config, and those required of a shield module. To create a shield module, the following components are needed: +The repository is a combination of the directories and files required of a ZMK config, and those required of a shield module. +To create a shield module, the following components are needed: - The `boards/shields` directory, where the keyboard's files will go - The `zephyr/module.yml` file, which identifies and describes the module. See the [Zephyr documentation](https://docs.zephyrproject.org/3.5.0/develop/modules.html#module-yaml-file-description) for details on customising this file. For the purposes of creating a shield module, the default found in the template can be left untouched. -Neither of these should be moved out of their parent directory. The other files and directories such as `config` are not necessary for the purposes of a shield module, but rather intended to be used for user configuration and testing. +Neither of these should be moved out of their parent directory. +The other files and directories such as `config` are not necessary for the purposes of a shield module, but rather intended to be used for user configuration and testing. ## New Shield Directory @@ -75,74 +103,90 @@ mkdir boards/shields/ You can check out the [`shields` folder](https://github.com/zmkfirmware/zmk/tree/main/app/boards/shields) in the ZMK repo that houses [the in-tree supported shields](../../hardware.mdx) in order to copy and modify as a starting point. ::: -There are two required Kconfig files that need to be created for your new keyboard -shield to get it picked up for ZMK, `Kconfig.shield` and `Kconfig.defconfig`. +There are two required [Kconfig](https://docs.zephyrproject.org/3.5.0/build/kconfig/index.html) files that need to be created for your new keyboard shield to get it picked up for ZMK, `Kconfig.shield` and `Kconfig.defconfig`. + + ### Kconfig.shield -The `Kconfig.shield` file defines any additional Kconfig settings that may be relevant when using this keyboard. For most keyboards, there is just one additional configuration value for the shield itself. +The `Kconfig.shield` file defines the shield name used to build your keyboard. -```kconfig -config SHIELD_MY_BOARD - def_bool $(shields_list_contains,my_board) + + + +```kconfig title="Kconfig.shield" +# No whitespace after the comma or in your keyboard name! +config SHIELD_MY_KEYBOARD + def_bool $(shields_list_contains,my_keyboard) ``` -:::warning -Kconfig uses only commas for delimiters, and keeps all whitespaces in the function call. Therefore do not add a whitespace after the comma when configuring your shield as this would be treated as  my_board (with a leading whitespace) and will cause issues. -::: +This will set the `SHIELD_MY_KEYBOARD` flag to `y` whenever `my_keyboard` is used as the shield name. +The `SHIELD_MY_KEYBOARD` flag will be used in `Kconfig.defconfig` to set other properties about your shield, so make sure that they match. -This will make sure that a new configuration value named `SHIELD_MY_BOARD` is set to true whenever `my_board` is used as the shield name, either as the `SHIELD` variable [in a local build](../local-toolchain/build-flash.mdx) or in your `build.yaml` file [when using Github Actions](../../customization.md). Note that this configuration value will be used in `Kconfig.defconfig` to set other properties about your shield, so make sure that they match. + + -**For split boards**, you will need to add configurations for the left and right sides. For example, if your split halves are named `my_board_left` and `my_board_right`, it would look like this: +Split keyboards have multiple shield names defined, one for each part. +For example, if your keyboard consists of two halves named `my_keyboard_left` and `my_keyboard_right`, it would look like this: -```kconfig -config SHIELD_MY_BOARD_LEFT - def_bool $(shields_list_contains,my_board_left) +```kconfig title="Kconfig.shield" +# No whitespace after the comma or in your part name! +config SHIELD_MY_KEYBOARD_LEFT + def_bool $(shields_list_contains,my_keyboard_left) -config SHIELD_MY_BOARD_RIGHT - def_bool $(shields_list_contains,my_board_right) +# No whitespace after the comma or in your part name! +config SHIELD_MY_KEYBOARD_RIGHT + def_bool $(shields_list_contains,my_keyboard_right) ``` +This will set the `SHIELD_MY_KEYBOARD_LEFT` flag to `y` whenever `my_keyboard_left` is used as the shield name. +Likewise, when `my_keyboard_right` is used as the shield name the `SHIELD_MY_KEYBOARD_RIGHT` flag is set to `y`. +The `SHIELD_MY_KEYBOARD_LEFT` and `SHIELD_MY_KEYBOARD_RIGHT` flags will be used in `Kconfig.defconfig` to set other properties about your shields, so make sure that they match. + + + + ### Kconfig.defconfig -The `Kconfig.defconfig` file is where overrides for various configuration settings -that make sense to have different defaults when this shield is used. One main item -that usually has a new default value set here is the `ZMK_KEYBOARD_NAME` value, -which controls the display name of the device over USB and BLE. +The `Kconfig.defconfig` file is used to set new defaults for configuration settings when this shield is used. +One main item that usually has a new default value set here is the `ZMK_KEYBOARD_NAME` value, which controls the display name of the device over USB and BLE. -The updated new default values should always be wrapped inside a conditional on the shield config name defined in the `Kconfig.shield` file. Here's the simplest example file. +The updated new default values should always be wrapped inside a conditional on the shield config name defined in the `Kconfig.shield` file. -:::danger -The keyboard name must be less than or equal to 16 characters in length, otherwise the bluetooth advertising might fail and you will not be able to find your keyboard from your device. -::: + + -```kconfig -if SHIELD_MY_BOARD +```kconfig title="Kconfig.defconfig" +if SHIELD_MY_KEYBOARD +# Name must be less than 16 characters long! config ZMK_KEYBOARD_NAME - default "My Board" + default "My Keyboard" endif ``` -For split keyboards, `Kconfig.defconfig` needs to specify a few more options. -Which side is central (usually the left) is determined via the configuration in this file. + + + +For split keyboards, a central side (usually the left) is specified via the configuration in this file. For that side, the keyboard name is assigned and the central config is set. -The peripheral side is typically not assigned a name since only the central will be advertising for connections to other devices. +The peripheral side is not assigned a name. Finally, the split config needs to be set for both sides: -```kconfig -if SHIELD_MY_BOARD_LEFT +```kconfig title="Kconfig.defconfig" +if SHIELD_MY_KEYBOARD_LEFT +# Name must be less than 16 characters long! config ZMK_KEYBOARD_NAME - default "My Board" + default "My Keyboard" config ZMK_SPLIT_ROLE_CENTRAL default y endif -if SHIELD_MY_BOARD_LEFT || SHIELD_MY_BOARD_RIGHT +if SHIELD_MY_KEYBOARD_LEFT || SHIELD_MY_KEYBOARD_RIGHT config ZMK_SPLIT default y @@ -150,33 +194,94 @@ config ZMK_SPLIT endif ``` + + + +### User Configuration Files + +In addition to the `Kconfig.shield` and `Kconfig.defconfig` files, many shields will also define a user configuration file called `my_keyboard.conf`. +This file exists to provide "suggestions" of [configuration settings](../../config/index.md) for a user to select, such as enabling deep sleep. +Note that the name should match the shield/part name defined in the [Kconfig.shield file](#Kconfig.shield). + +:::warning +This file can also be used to set configuration options. +However, if a flag is set in this file, **the user can no longer change it**. +Though sometimes necessary, this method of setting configuration options is discouraged. +The case for which this is necessary is due to be eliminated in the future, making this method redundant. +::: + + + + + +Split keyboards can have multiple `.conf` files, one for each part. For example: + +- `my_keyboard.conf` - Configuration elements affect both halves +- `my_keyboard_left.conf` - Configuration elements only affect left half +- `my_keyboard_left.conf` - Configuration elements only affect right half + +In most case you'll only need to use the .conf file that affects both halves of a split board. + +:::note +The shared configuration in `my_keyboard.conf` is only applied when you are building with a [`zmk-config` folder](../local-toolchain/build-flash.mdx#building-from-zmk-config-folder) and it is present at `config/my_keyboard.conf`. +::: + + + + ## Shield Overlays + + +Shield overlay files contain a devicetree description that is merged with the primary board devicetree description during the firmware building process. +There are three main things that need to be defined in this file: + +- Your keyboard scan (kscan) driver, which determines which GPIO pins to scan for key press events +- Your matrix transform, which acts as a "bridge" between the kscan and the keymap +- Your physical layout, which aggregates the above and (optionally) defines physical key positions so that the keyboard can be used with [ZMK Studio](../../features/studio.md). + + + + +A unibody keyboard will have a single overlay file named `my_keyboard.overlay`, where `my_keyboard` is the shield name defined in the [Kconfig.shield file](#Kconfig.shield). + + + + +A split keyboard will have an overlay file defined for each split part. +For example, if the keyboard is split into a left and a right half, these can be named: + +- `my_keyboard_left.overlay` +- `my_keyboard_right.overlay` + +Here `my_keyboard_left` and `my_keyboard_right` are the shield names defined in the [Kconfig.shield file](#Kconfig.shield). + +Split keyboards often share some of their devicetree description. +The standard approach is to have a core `my_keyboard.dtsi` (devicetree include) file, which is included into each of the shield overlays. + + + + +### Kscan + +The kscan node defines the controller GPIO pins that are used to scan for key press and release events. The pins are referred to using the GPIO labels noted in the pinouts below: + To use GPIO pins that are not part of the interconnects as described above, you can use the GPIO labels that are specific to each controller type. For instance, pins numbered `PX.Y` in nRF52840-based boards can be referred to via `&gpioX Y` labels. An example is `&gpio1 7` for the `P1.07` pin that the nice!nano exposes in the middle of the board. - +The [Keyboard Scan configuration documentation](../../config/kscan.md) has the full details on configuring the kscan driver. + -The `.overlay` is the devicetree description of the keyboard shield that is merged with the primary board devicetree description before the build. For ZMK, this file at a minimum should include the chosen node named `zmk,kscan` that references a KSCAN driver instance. For a simple 3x3 macropad matrix, -this might look something like: +For a simple 3x3 macropad matrix, the kscan might look something like: -```dts +```dts title="my_keyboard.overlay" / { - chosen { - zmk,kscan = &kscan0; - }; - - kscan0: kscan_0 { + kscan0: kscan0 { compatible = "zmk,kscan-gpio-matrix"; diode-direction = "col2row"; wakeup-source; @@ -196,190 +301,162 @@ this might look something like: }; ``` -See the [Keyboard Scan configuration documentation](../../config/kscan.md) for details on configuring the KSCAN driver. - - -### .dtsi files and Shield Overlays (Split Shields) - -Unlike unibody keyboards, split keyboards have a core .dtsi file with shield overlays for each half of the keyboard. -It is preferred to define only the `col-gpios` or `row-gpios` in the common shield .dtsi, depending on the `diode-direction` value. -For `col2row` directed boards like the iris, the shared .dtsi file may look like this: - -```dts -#include +For split keyboards you should define your kscan in `my_keyboard.dtsi`. +If your `row-gpios` or your `col-gpios` (or both) are identical between the parts, then they should also be defined in `my_keyboard.dtsi`. +For example, for a `col2row` 2-part split keyboard (18 keys split into a 3x3 macropad on both halves) where the "row" GPIOs used are the same for both halves: +```dts title="my_keyboard.dtsi" / { - chosen { - zmk,kscan = &kscan0; - zmk,matrix-transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <16>; - rows = <4>; -// | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | -// | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | -// | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | -// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | SW25 | | SW25 | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | -// | SW29 | SW28 | SW27 | SW26 | | SW26 | SW27 | SW28 | SW29 | - map = < -RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) -RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) -RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) -RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,2) RC(4,9) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) - RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) - >; - }; - - kscan0: kscan { + kscan0: kscan0 { compatible = "zmk,kscan-gpio-matrix"; diode-direction = "col2row"; wakeup-source; row-gpios - = <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> // Row A from the schematic file - , <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> // Row B from the schematic file - , <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> // Row C from the schematic file - , <&pro_micro 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> // Row D from the schematic file - , <&pro_micro 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> // Row E from the schematic file + = <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; }; }; ``` -:::note -Notice that in addition to the common `row-gpios` that are declared in the kscan, the [matrix transform](#matrix-transform) is defined in the .dtsi. -::: +The missing `col-gpios` would be defined in your `my_keyboard_left.overlay` and `my_keyboard_right.overlay` files. -The missing `col-gpios` would be defined in your `_left.overlay` and `_right.overlay` files. -Keep in mind that the mirrored position of the GPIOs means that the `col-gpios` will appear reversed when the .overlay files are compared to one another. -Furthermore, the column offset for the [matrix transform](#matrix-transform) should be added to the right half of the keyboard's overlay -because the keyboard's switch matrix is read from left to right, top to bottom. -This is exemplified with the iris .overlay files. - -```dts title=iris_left.overlay -#include "iris.dtsi" // Notice that the main dtsi files are included in the overlay. +```dts title="my_keyboard_left.overlay" +#include "my_keyboard.dtsi" // The shared dtsi file is included in the overlay +// Label of the kscan node in the dtsi &kscan0 { col-gpios - = <&pro_micro 19 GPIO_ACTIVE_HIGH> // col1 in the schematic - , <&pro_micro 18 GPIO_ACTIVE_HIGH> // col2 in the schematic - , <&pro_micro 15 GPIO_ACTIVE_HIGH> // col3 in the schematic - , <&pro_micro 14 GPIO_ACTIVE_HIGH> // col4 in the schematic - , <&pro_micro 16 GPIO_ACTIVE_HIGH> // col5 in the schematic - , <&pro_micro 10 GPIO_ACTIVE_HIGH> // col6 in the schematic + = <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> ; }; ``` -```dts title=iris_right.overlay -#include "iris.dtsi" - -&default_transform { // The matrix transform for this board is 6 columns over because the left half is 6 columns wide according to the matrix. - col-offset = <6>; -}; +```dts title="my_keyboard_right.overlay" +#include "my_keyboard.dtsi" // The shared dtsi file is included in the overlay +// Label of the kscan node in the dtsi &kscan0 { col-gpios - = <&pro_micro 10 GPIO_ACTIVE_HIGH> // col6 in the schematic - , <&pro_micro 16 GPIO_ACTIVE_HIGH> // col5 in the schematic - , <&pro_micro 14 GPIO_ACTIVE_HIGH> // col4 in the schematic - , <&pro_micro 15 GPIO_ACTIVE_HIGH> // col3 in the schematic - , <&pro_micro 18 GPIO_ACTIVE_HIGH> // col2 in the schematic - , <&pro_micro 19 GPIO_ACTIVE_HIGH> // col1 in the schematic + = <&pro_micro 10 GPIO_ACTIVE_HIGH> + , <&pro_micro 11 GPIO_ACTIVE_HIGH> + , <&pro_micro 13 GPIO_ACTIVE_HIGH> ; }; - ``` -See the [Keyboard Scan configuration documentation](../../config/kscan.md) for details on configuring the KSCAN driver. - -### .conf files (Split Shields) - -While unibody boards only have one .conf file that applies configuration characteristics to the entire keyboard, -split keyboards are unique in that they contain multiple .conf files with different scopes. -For example, a split board called `my_awesome_split_board` would have the following files: + + -- `my_awesome_split_board.conf` - Configuration elements affect both halves -- `my_awesome_split_board_left.conf` - Configuration elements only affect left half -- `my_awesome_split_board_right.conf` - Configuration elements only affect right half +### Matrix Transform -In most case you'll only need to use the .conf file that affects both halves of a split board. It's used for adding features like deep-sleep or rotary encoders. +The matrix transform is used to transform row/column events into "key position" events. -```ini title=my_awesome_split_board.conf -CONFIG_ZMK_SLEEP=y -``` +When a key is pressed, a kscan event is generated from it with a `row` and a `column` value corresponding to the zero-based indices of the `row-gpios` and `col-gpios` pins that triggered the event, respectively. +Then, the "key position" triggered is the index of the `RC(row, column)` in the matrix transform where `row` and `column` are the indices as mentioned above. +This key position will in turn have a behavior binding associated with it in the keymap. -:::note -The shared configuration in `my_awesome_split_board.conf` is only applied when you are building with a [`zmk-config` folder](../local-toolchain/build-flash.mdx#building-from-zmk-config-folder) and when it is present at `config/my_awesome_split_board.conf`. If you are not using a `zmk-config` folder, you will need to include the shared configuration in both `my_awesome_split_board_left.conf` and `my_awesome_split_board_right.conf` files. -::: + + - - +The `my_keyboard.overlay` must include a matrix transform that defines this mapping from row/column values to key positions. +Add `#include ` to the top of the file. -## Matrix Transform +Here is an example of a matrix transform for the previous 3x3 macropad: -Internally ZMK translates all row/column events into "key position" events to maintain a consistent model that works no matter what any possible GPIO matrix may look like for a certain keyboard. This is particularly helpful when: +```dts title="my_keyboard.overlay" +#include // Put this with the other includes at the top of your overlay -1. To reduce the used pins, an "efficient" number of rows/columns for the GPIO matrix is used, that does _not_ match the physical layout of rows/columns of the actual key switches. -1. For non rectangular keyboards with thumb clusters, non `1u` locations, etc. +/ { + default_transform: keymap_transform0 { + compatible = "zmk,matrix-transform"; + columns = <3>; // Length of the "col-gpios" array + rows = <3>; // Length of the "row-gpios" array + map = < + // Key 1 | Key 2 | Key 3 + RC(0,0) RC(0,1) RC(0,2) + // Key 4 | Key 5 | Key 6 + RC(1,0) RC(1,1) RC(1,2) + // Key 7 | Key 8 | Key 9 + RC(2,0) RC(2,1) RC(2,2) + >; + }; +}; +``` -A "key position" is the numeric index (zero-based) of a given key, which identifies -the logical key location as perceived by the end user. All _keymap_ mappings actually bind behaviors to _key positions_, not to row/column values. + + -The `.overlay` must include a matrix transform that defines this mapping from row/column values to key positions. +Split keyboards should define their matrix transform in the shared `my_keyboard.dtsi`. Add `#include ` to the top of the file. -Here is an example for the [nice60](https://github.com/Nicell/nice60), which uses an efficient 8x8 GPIO matrix, and uses a transform: +Here is an example of a matrix transform for the previous example (18-key double macropad): -```dts -#include +```dts title="my_keyboard.dtsi" +#include // Put this with the other includes at the top of your dtsi / { - /* define kscan node with label `kscan0`... */ - - default_transform: keymap_transform_0 { + default_transform: keymap_transform0 { compatible = "zmk,matrix-transform"; - columns = <8>; - rows = <8>; -// | MX1 | MX2 | MX3 | MX4 | MX5 | MX6 | MX7 | MX8 | MX9 | MX10 | MX11 | MX12 | MX13 | MX14 | -// | MX15 | MX16 | MX17 | MX18 | MX19 | MX20 | MX21 | MX22 | MX23 | MX34 | MX25 | MX26 | MX27 | MX28 | -// | MX29 | MX30 | MX31 | MX32 | MX33 | MX34 | MX35 | MX36 | MX37 | MX38 | MX39 | MX40 | MX41 | -// | MX42 | MX43 | MX44 | MX45 | MX46 | MX47 | MX48 | MX49 | MX50 | MX51 | MX52 | MX53 | -// | MX54 | MX55 | MX56 | MX57 | MX58 | MX59 | MX60 | MX61 | + columns = <6>; + rows = <3>; map = < -RC(3,0) RC(2,0) RC(1,0) RC(0,0) RC(1,1) RC(0,1) RC(0,2) RC(1,3) RC(0,3) RC(1,4) RC(0,4) RC(0,5) RC(1,6) RC(1,7) -RC(4,0) RC(4,1) RC(3,1) RC(2,1) RC(2,2) RC(1,2) RC(2,3) RC(3,4) RC(2,4) RC(2,5) RC(1,5) RC(2,6) RC(2,7) RC(3,7) -RC(5,0) RC(5,1) RC(5,2) RC(4,2) RC(3,2) RC(4,3) RC(3,3) RC(4,4) RC(4,5) RC(3,5) RC(4,6) RC(3,6) RC(4,7) -RC(6,0) RC(6,1) RC(6,2) RC(6,3) RC(5,3) RC(6,4) RC(5,4) RC(6,5) RC(5,5) RC(6,6) RC(5,6) RC(5,7) -RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,5) RC(7,6) RC(6,7) RC(7,7) + // LKey 1 |LKey 2 |LKey 3 RKey 1 |RKey 2 |RKey 3 + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) + // LKey 4 |LKey 5 |LKey 6 RKey 4 |RKey 5 |RKey 6 + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) + // LKey 7 |LKey 8 |LKey 9 RKey 7 |RKey 8 |RKey 9 + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) >; }; +}; +``` + +The above transform has 6 columns and three rows, while each half of the keyboard only has three columns and three rows. +To allow the kscan matrices to be joined in the matrix transform, an offset is applied to the matrix transform of peripherals. - /* potentially other overlay nodes... */ +```dts title="my_keyboard_right.overlay" +&default_transform { // Offset of 3 because the left side has 3 columns + col-offset = <3>; }; ``` -Some important things to note: +This offset means that when the right half of the keyboard has a key event triggered by the GPIO pins at the indices `0,0` of its `row-gpios` and `col-gpios` arrays respectively, it will interpret it as an `RC(0,3)` event rather than an `RC(0,0)` event. +Additional peripherals would need their columns to be offset by an ever increasing number equal to the sum of the columns in the central + any peripherals that came before it. +You can also apply row offsets with `row-offset`. + + + + +The matrix transform is also used to "correct" pin orderings into something that more closely matches the physical order of keys. Causes of abnormal pin orderings include: + +- To reduce the used pins, an "efficient" number of rows/columns for the GPIO matrix is used, that does _not_ match the physical layout of rows/columns of the actual key switches. +- For non-rectangular keyboards with thumb clusters, non `1u` locations, etc. + +See the [in-tree keyboards](https://github.com/zmkfirmware/zmk/tree/main/app/boards/shields) that ZMK defines for examples of more complex matrix transformations. + +Also see the [matrix transform section](../../config/kscan.md#matrix-transform) in the Keyboard Scan configuration documentation for further details and examples of matrix transforms. -- The `#include ` is critical. The `RC` macro is used to generate the internal storage in the matrix transform, and is actually replaced by a C preprocessor before the final devicetree is compiled into ZMK. -- `RC(row, column)` is placed sequentially to define what row and column values that position corresponds to. -- If you have a keyboard with options for `2u` keys in certain positions, ANSI vs. ISO layouts, or break away portions, define one matrix transform for each possible arrangement to be used in the physical layouts. This will allow the users to select the right layout in their keymap files. +### Physical Layout -See the [matrix transform section](../../config/kscan.md#matrix-transform) in the Keyboard Scan configuration documentation for details and more examples of matrix transforms. +The physical layout is the top level entity that aggregates all details about a certain possible layout: -## Physical Layout +- Your keyboard scan (kscan) driver +- Your matrix transform +- (Optional) Physical key positions -The physical layout is the top level entity that aggregates all details about a certain possible layout for a keyboard: the matrix transform that defines the set of key positions and what row/column they correspond to, what kscan driver is used for that layout, etc. -For keyboards that support multiple layouts, setting a `chosen` node to a defined physical layout in your keymap will allow selecting the specific layout that you've built. +The physical layout should be placed in the same file as the matrix transform, i.e. `my_keyboard.overlay` for unibodies and `my_keyboard.dtsi` for split keyboards. A physical layout is very basic, e.g.: -``` +```dts / { default_layout: default_layout { compatible = "zmk,physical-layout"; @@ -390,15 +467,11 @@ A physical layout is very basic, e.g.: }; ``` -When supporting multiple layouts, define the multiple layout nodes and then set a `chosen` for the default: +If a keyboard has multiple possible layouts (ex. you can snap off an outer column), then you should define multiple matrix transformations and multiple physical layouts. +If necessary, you can also define multiple kscan instances. -``` +```dts / { - chosen { - zmk,physical-layout = &default_layout; - ... - }; - default_layout: default_layout { compatible = "zmk,physical-layout"; display-name = "Default Layout"; @@ -415,38 +488,73 @@ When supporting multiple layouts, define the multiple layout nodes and then set }; ``` -This way, users can select a different layout by overriding the `zmk,physical-layout` chosen node in their keymap file. +See [ZMK Studio Setup](./studio-setup.md) for information on defining the `keys` property for physical key positions that lets you enable [ZMK Studio](../../features/studio.md) for your keyboard. -:::note -Some keyboards use different GPIO pins for different layouts, and need different kscan nodes created for each layout. -However, if all of your physical layouts use the same `kscan` node under the hood, you can skip setting the `kscan` property on each -layout and instead assign the `zmk,kscan` chosen node to your single kscan instance. -::: +### Chosen Node -## Default Keymap +Set the `chosen` node to a defined "default" physical layout. This should also be placed in the same file as the physical layout, i.e. `my_keyboard.overlay` for unibodies and `my_keyboard.dtsi` for split keyboards. -Each keyboard should provide a default keymap to be used when building the firmware, which can be overridden and customized by user configs. For "shield keyboards", this should be placed in the `boards/shields//.keymap` file. The keymap is configured as an additional devicetree overlay that includes the following: +```dts +/ { + chosen { + zmk,physical-layout = &default_layout; + // Other chosen items + }; +}; +``` -- A node with `compatible = "zmk,keymap"` where each child node is a layer with a `bindings` array that binds each key position to a given behavior (e.g. key press, momentary layer, etc). +If you define multiple physical layouts, users can select a different layout by overriding the `zmk,physical-layout` chosen node in their keymap file. -Here is an example simple keymap for the Kyria, with only one layer: +:::note +If all of your physical layouts use the same `kscan` node under the hood, you can skip setting the `kscan` property on each layout and instead assign the `zmk,kscan` chosen node to your single kscan instance: - +```dts +/ { + chosen { + zmk,kscan = &kscan0; + zmk,physical-layout = &default_layout; + // Other chosen items + }; +}; +``` -:::note -The two `#include` lines at the top of the keymap are required in order to bring in the default set of behaviors to make them available to bind, and to import a set of defines for the key codes, so keymaps can use parameters like `N2` or `K` instead of the raw keycode numeric values. ::: -### Keymap Behaviors +## Default Keymap + +Each keyboard should provide a default keymap to be used when building the firmware, which can be overridden and customized by user configs. +For "shield keyboards", this should be placed in the `boards/shields/my_keyboard/my_keyboard.keymap` file. +The keymap is configured as an additional devicetree overlay that includes the following: -For documentation on the available behaviors for use in keymaps, see the [overview page for behaviors](../../keymaps/behaviors/index.mdx). +Here is an example simple keymap for a 3x3 macropad, with only one layer: + +```dts title="my_keyboard.keymap" +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { // Layer 0 + // ------------------------------------- + // | Z | M | K | + // | A | B | C | + // | D | E | F | + bindings = < + &kp Z &kp M &kp K + &kp A &kp B &kp C + &kp D &kp E &kp F + >; + }; + }; + }; +``` + +The keymap should match the order of the keys in the [matrix transform](#matrix-transform) exactly, left to right, top to bottom (they are both 1 dimensional arrays rearranged with newline characters for better legibility). +See [Keymaps](../../keymaps/index.mdx) for information on defining keymaps in ZMK. ## Metadata ZMK makes use of an additional metadata YAML file for all boards and shields to provide high level information about the hardware to be incorporated into setup scripts/utilities, website hardware list, etc. -The naming convention for metadata files is `{item_id}.zmk.yml`, where the `item_id` is the board/shield identifier, including version information but excluding any optional split `_left`/`_right` suffix, e.g. `corne.zmk.yml` or `nrfmicro_11.zmk.yml`. - Here is a sample `corne.zmk.yml` file from the repository: ```yaml @@ -465,91 +573,23 @@ siblings: - corne_right ``` -You should place a properly named `foo.zmk.yml` file in the directory next to your other shield values, and fill it out completely and accurately. See [Hardware Metadata Files](hardware-metadata-files.md) for the full details. - -## Build File - -To help you test/verify your firmware, update the `build.yaml` to list your particular board/shield combinations you want built whenever changes are published to GitHub. Open `build.yaml` with your editor and add a combination, e.g.: - -```yaml -# This file generates the GitHub Actions matrix -# For simple board + shield combinations, add them -# to the top level board and shield arrays, for more -# control, add individual board + shield combinations to -# the `include` property, e.g: -# -# board: [ "nice_nano_v2" ] -# shield: [ "corne_left", "corne_right" ] -# include: -# - board: bdn9_rev2 -# - board: nice_nano_v2 -# shield: reviung41 -# ---- -include: - - board: nice_nano_v2 - shield: -``` - -For split keyboards, you will need to specify the halves/siblings separately, e.g.: - -```yaml -include: - - board: mikoto_520 - shield: _left - - board: mikoto_520 - shield: _right -``` +You should place a properly named `my_keyboard.zmk.yml` file in the directory next to your other shield values, and fill it out completely and accurately. +See [Hardware Metadata Files](hardware-metadata-files.md) for the full details. ## Testing -### GitHub Actions - -Using GitHub Actions to build your new firmware can save you from doing any local [development setup](../local-toolchain/setup/index.md), -at the expense of a longer feedback loop if there are issues. To push your changes and trigger a build: +Once you've defined everything as described above, you can build your firmware to make sure everything is working. -- Add all your pending changes with `git add .` -- Commit your changes with `git commit -m "Initial shield"` -- Push the changes to GitHub with `git push` - -Once pushed, click on the "Actions" tab of the repo you created in the first step, and you should see a new build running. If the build is successful, there will be a new `firmware.zip` artifact shown on the summary screen you can download that will contain the new `.uf2` files that can be flashed to the device. - -### Local Build - -:::note -To build locally, be sure you've followed the [development setup](../local-toolchain/setup/index.md) guide first. -::: - -Once you've fully created the new keyboard shield definition, -you should be able to test with a build command like: - -```sh -west build --pristine -b nice_nano_v2 -- -DSHIELD= -DZMK_EXTRA_MODULES=/full/path/to/your/module -# replace with e.g. _left for split keyboards, then repeat for _right -``` - -The above build command generates a `build/zephyr/zmk.uf2` file that you can flash using the steps from the following section. See the dedicated [building and flashing page](../local-toolchain/build-flash.mdx) for more details. - -### Flashing - -If your board -supports USB Flashing Format (UF2), copy that file onto the root of the USB mass -storage device for your board. The controller should flash your built firmware -and automatically restart once flashing is complete. If you need to flash an updated -UF2 file with fixes, you can re-enter the bootloader by double tapping the reset button. +### GitHub Actions -Alternatively, if your board supports flashing and you're not developing from -within a Dockerized environment, enable Device Firmware Upgrade (DFU) mode on -your board and run the following command to test your build: +To use GitHub Actions to test, push the files defining the keyboard to GitHub. +Next, [update the `build.yaml`](../../customization.md#building-additional-keyboards) of your `zmk-config` to build your keyboard. -```sh -west flash -``` +- If your shield is defined in your `zmk-config`, then the shield should start building. +- If the shield is defined in a separate module, you will need to [adjust your `west.yml` to reference the module](https://zmk.dev/docs/features/modules#building-with-modules). -Please have a look at documentation specific to -[building and flashing](../local-toolchain/build-flash.mdx) for additional information. +### Local Toolchain -:::note -Further testing your keyboard shield without altering the root keymap file can be done with the use of `-DZMK_CONFIG` in your `west build` command, -shown [here](../local-toolchain/build-flash.mdx#building-from-zmk-config-folder) -::: +You can also use a local toolchain setup to test your keyboard. +Follow [our guide for getting set up](../local-toolchain/setup/index.md), then follow the [instructions for building and flashing locally](../local-toolchain/build-flash.mdx). +You will need to specify the module of your keyboard when building. diff --git a/docs/docs/keymap-example-file.md b/docs/docs/keymap-example-file.md deleted file mode 100644 index 91213f1510b..00000000000 --- a/docs/docs/keymap-example-file.md +++ /dev/null @@ -1,26 +0,0 @@ -```dts -#include -#include - -/ { - keymap { - compatible = "zmk,keymap"; - - default_layer { -// -------------------------------------------------------------------------------------------------------------------------------------------------------------------- -// | ESC | Q | W | E | R | T | | Y | U | I | O | P | \ | -// | TAB | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHIFT | Z | X | C | V | B | CTRL+A | CTRL+C | | CTRL+V | CTRL+X | N | M | , | . | / | R CTRL | -// | GUI | DEL | RETURN | SPACE | ESCAPE | | RETURN | SPACE | TAB | BSPC | R ALT | - bindings = < - &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH - &kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT - &kp LSHIFT &kp Z &kp X &kp C &kp V &kp B &kp LC(A) &kp LC(C) &kp LC(V) &kp LC(X) &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL - &kp LGUI &kp DEL &kp RET &kp SPACE &kp ESC &kp RET &kp SPACE &kp TAB &kp BSPC &kp RALT - >; - - sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>; - }; - }; -}; -``` From e1958225593d89e575ef4a82a7d346d64c760fda Mon Sep 17 00:00:00 2001 From: Nicolas Munnich Date: Tue, 1 Oct 2024 01:31:17 +0200 Subject: [PATCH 36/42] docs: fixed broken anchors --- docs/docs/development/hardware-integration/new-shield.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/development/hardware-integration/new-shield.mdx b/docs/docs/development/hardware-integration/new-shield.mdx index 1587cbc56ed..f2be494638d 100644 --- a/docs/docs/development/hardware-integration/new-shield.mdx +++ b/docs/docs/development/hardware-integration/new-shield.mdx @@ -201,7 +201,7 @@ endif In addition to the `Kconfig.shield` and `Kconfig.defconfig` files, many shields will also define a user configuration file called `my_keyboard.conf`. This file exists to provide "suggestions" of [configuration settings](../../config/index.md) for a user to select, such as enabling deep sleep. -Note that the name should match the shield/part name defined in the [Kconfig.shield file](#Kconfig.shield). +Note that the name should match the shield/part name defined in the [Kconfig.shield file](#kconfigshield). :::warning This file can also be used to set configuration options. @@ -243,7 +243,7 @@ There are three main things that need to be defined in this file: -A unibody keyboard will have a single overlay file named `my_keyboard.overlay`, where `my_keyboard` is the shield name defined in the [Kconfig.shield file](#Kconfig.shield). +A unibody keyboard will have a single overlay file named `my_keyboard.overlay`, where `my_keyboard` is the shield name defined in the [Kconfig.shield file](#kconfigshield). @@ -254,7 +254,7 @@ For example, if the keyboard is split into a left and a right half, these can be - `my_keyboard_left.overlay` - `my_keyboard_right.overlay` -Here `my_keyboard_left` and `my_keyboard_right` are the shield names defined in the [Kconfig.shield file](#Kconfig.shield). +Here `my_keyboard_left` and `my_keyboard_right` are the shield names defined in the [Kconfig.shield file](#kconfigshield). Split keyboards often share some of their devicetree description. The standard approach is to have a core `my_keyboard.dtsi` (devicetree include) file, which is included into each of the shield overlays. From 90d6285d98692900bb14a6e56befc844d357c18c Mon Sep 17 00:00:00 2001 From: LostQuasar Date: Mon, 30 Sep 2024 22:43:58 -0400 Subject: [PATCH 37/42] blog: Remove reference to spaceman (#2520) --- docs/blog/2023-10-05-zmk-sotf-6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/blog/2023-10-05-zmk-sotf-6.md b/docs/blog/2023-10-05-zmk-sotf-6.md index 609425ee137..b0c8c4d894e 100644 --- a/docs/blog/2023-10-05-zmk-sotf-6.md +++ b/docs/blog/2023-10-05-zmk-sotf-6.md @@ -214,7 +214,7 @@ USB HID polling interval now defaults to 1 ms, i.e. a 1000Hz polling rate, thank - Waterfowl [#1554](https://github.com/zmkfirmware/zmk/pull/1554) - [JW2586](https://github.com/JW2586) - Kyria Rev 3 [#1627](https://github.com/zmkfirmware/zmk/pull/1627) - [petejohanson] - Leeloo v2 and Leeloo-Micro [#1762](https://github.com/zmkfirmware/zmk/pull/1762) - [ClicketySplit](https://github.com/ClicketySplit) -- Spaceman Pancake [#1400](https://github.com/zmkfirmware/zmk/pull/1400) - [jasonhazel](https://github.com/jasonhazel) +- Spaceboards Pancake [#1400](https://github.com/zmkfirmware/zmk/pull/1400) - [jasonhazel](https://github.com/jasonhazel) - Reviung5 [#1548](https://github.com/zmkfirmware/zmk/pull/1548) - [zblesk](https://github.com/zblesk) ## New Boards From 73ca365530bc79d03dc64d89adc03b4ccbeeb14e Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Tue, 1 Oct 2024 01:14:44 -0600 Subject: [PATCH 38/42] feat(boards): PM RP2040 flash settings support. --- app/boards/sparkfun_pro_micro_rp2040.conf | 7 +++++++ app/boards/sparkfun_pro_micro_rp2040.overlay | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/boards/sparkfun_pro_micro_rp2040.conf b/app/boards/sparkfun_pro_micro_rp2040.conf index 21c1893d91f..354d7007447 100644 --- a/app/boards/sparkfun_pro_micro_rp2040.conf +++ b/app/boards/sparkfun_pro_micro_rp2040.conf @@ -2,3 +2,10 @@ CONFIG_CONSOLE=n CONFIG_SERIAL=n CONFIG_UART_CONSOLE=n CONFIG_ZMK_USB=y + +CONFIG_MPU_ALLOW_FLASH_WRITE=y +CONFIG_NVS=y +CONFIG_SETTINGS_NVS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y \ No newline at end of file diff --git a/app/boards/sparkfun_pro_micro_rp2040.overlay b/app/boards/sparkfun_pro_micro_rp2040.overlay index 72b3adcaf41..21aa7dff7c6 100644 --- a/app/boards/sparkfun_pro_micro_rp2040.overlay +++ b/app/boards/sparkfun_pro_micro_rp2040.overlay @@ -5,3 +5,19 @@ */ &pro_micro_serial { status = "disabled"; }; + +// We override to 2MB for maximum compatibility +&code_partition { + reg = <0x100 (DT_SIZE_M(2) - 0x100 - DT_SIZE_K(512))>; +}; + +&flash0 { + reg = <0x10000000 DT_SIZE_M(2)>; + + partitions { + storage_partition: partition@180000 { + reg = <0x180000 DT_SIZE_K(512)>; + read-only; + }; + }; +}; From 36f146226e598c788a76367686aac3af7c4deccb Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Mon, 30 Sep 2024 00:16:01 -0500 Subject: [PATCH 39/42] feat(boards)!: refactor common layouts Removed the combined .dtsi file for each group of common layouts, and split the position map across the files in each group. This makes reading the position maps slightly more difficult, but it aligns the common layouts with the keyboard-specific ones such as foostan/corne.dtsi in that simply including each header adds the layout, with no need to set status = "okay". --- app/boards/arm/bt60/bt60_v1.dts | 9 ++- app/boards/arm/ckp/bt60_v2.dts | 9 ++- app/boards/arm/ckp/bt65_v1.dts | 9 ++- app/boards/arm/ckp/bt75_v1.dts | 7 +- app/boards/arm/planck/planck_rev6.dts | 7 +- app/boards/arm/preonic/preonic_rev3.dts | 7 +- .../layouts/common/60percent/60percent.dtsi | 72 ------------------- app/dts/layouts/common/60percent/all1u.dtsi | 16 ++++- app/dts/layouts/common/60percent/ansi.dtsi | 16 ++++- app/dts/layouts/common/60percent/hhkb.dtsi | 16 ++++- app/dts/layouts/common/60percent/iso.dtsi | 16 ++++- .../common/60percent/position_map.dtsi | 7 ++ .../layouts/common/65percent/65percent.dtsi | 72 ------------------- app/dts/layouts/common/65percent/all1u.dtsi | 16 ++++- app/dts/layouts/common/65percent/ansi.dtsi | 16 ++++- app/dts/layouts/common/65percent/hhkb.dtsi | 16 ++++- app/dts/layouts/common/65percent/iso.dtsi | 16 ++++- .../common/65percent/position_map.dtsi | 7 ++ .../layouts/common/75percent/75percent.dtsi | 59 --------------- app/dts/layouts/common/75percent/all1u.dtsi | 17 ++++- app/dts/layouts/common/75percent/ansi.dtsi | 17 ++++- app/dts/layouts/common/75percent/iso.dtsi | 17 ++++- .../common/75percent/position_map.dtsi | 7 ++ app/dts/layouts/common/ortho_4x12/1x2u.dtsi | 15 +++- app/dts/layouts/common/ortho_4x12/2x2u.dtsi | 15 +++- app/dts/layouts/common/ortho_4x12/all1u.dtsi | 15 +++- .../layouts/common/ortho_4x12/ortho_4x12.dtsi | 53 -------------- .../common/ortho_4x12/position_map.dtsi | 7 ++ app/dts/layouts/common/ortho_5x12/1x2u.dtsi | 16 ++++- app/dts/layouts/common/ortho_5x12/2x2u.dtsi | 16 ++++- app/dts/layouts/common/ortho_5x12/all1u.dtsi | 14 ++++ .../layouts/common/ortho_5x12/ortho_5x12.dtsi | 56 --------------- .../common/ortho_5x12/position_map.dtsi | 7 ++ app/dts/layouts/common/tkl/ansi.dtsi | 1 + app/dts/layouts/common/tkl/position_map.dtsi | 7 ++ 35 files changed, 318 insertions(+), 355 deletions(-) delete mode 100644 app/dts/layouts/common/60percent/60percent.dtsi create mode 100644 app/dts/layouts/common/60percent/position_map.dtsi delete mode 100644 app/dts/layouts/common/65percent/65percent.dtsi create mode 100644 app/dts/layouts/common/65percent/position_map.dtsi delete mode 100644 app/dts/layouts/common/75percent/75percent.dtsi create mode 100644 app/dts/layouts/common/75percent/position_map.dtsi delete mode 100644 app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi create mode 100644 app/dts/layouts/common/ortho_4x12/position_map.dtsi delete mode 100644 app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi create mode 100644 app/dts/layouts/common/ortho_5x12/position_map.dtsi create mode 100644 app/dts/layouts/common/tkl/position_map.dtsi diff --git a/app/boards/arm/bt60/bt60_v1.dts b/app/boards/arm/bt60/bt60_v1.dts index d7ecb5aeacd..5790458d0d4 100644 --- a/app/boards/arm/bt60/bt60_v1.dts +++ b/app/boards/arm/bt60/bt60_v1.dts @@ -6,7 +6,10 @@ /dts-v1/; #include "bt60.dtsi" -#include +#include +#include +#include +#include / { @@ -102,21 +105,17 @@ }; &layout_60_ansi { - status = "okay"; transform = <&ansi_transform>; }; &layout_60_iso { - status = "okay"; transform = <&iso_transform>; }; &layout_60_all1u { - status = "okay"; transform = <&all_1u_transform>; }; &layout_60_hhkb { - status = "okay"; transform = <&hhkb_transform>; }; diff --git a/app/boards/arm/ckp/bt60_v2.dts b/app/boards/arm/ckp/bt60_v2.dts index 751cad0989c..1cdb0307a2c 100644 --- a/app/boards/arm/ckp/bt60_v2.dts +++ b/app/boards/arm/ckp/bt60_v2.dts @@ -6,7 +6,10 @@ /dts-v1/; #include "ckp.dtsi" -#include +#include +#include +#include +#include / { @@ -72,21 +75,17 @@ }; &layout_60_ansi { - status = "okay"; transform = <&ansi_transform>; }; &layout_60_iso { - status = "okay"; transform = <&iso_transform>; }; &layout_60_all1u { - status = "okay"; transform = <&all_1u_transform>; }; &layout_60_hhkb { - status = "okay"; transform = <&hhkb_transform>; }; diff --git a/app/boards/arm/ckp/bt65_v1.dts b/app/boards/arm/ckp/bt65_v1.dts index cdea235f5ec..77e81289f04 100644 --- a/app/boards/arm/ckp/bt65_v1.dts +++ b/app/boards/arm/ckp/bt65_v1.dts @@ -6,7 +6,10 @@ /dts-v1/; #include "ckp.dtsi" -#include +#include +#include +#include +#include / { @@ -72,21 +75,17 @@ }; &layout_65_ansi { - status = "okay"; transform = <&ansi_transform>; }; &layout_65_iso { - status = "okay"; transform = <&iso_transform>; }; &layout_65_all1u { - status = "okay"; transform = <&all_1u_transform>; }; &layout_65_hhkb { - status = "okay"; transform = <&hhkb_transform>; }; diff --git a/app/boards/arm/ckp/bt75_v1.dts b/app/boards/arm/ckp/bt75_v1.dts index 7077aa1de6c..7c9ab664e3c 100644 --- a/app/boards/arm/ckp/bt75_v1.dts +++ b/app/boards/arm/ckp/bt75_v1.dts @@ -6,7 +6,9 @@ /dts-v1/; #include "ckp.dtsi" -#include +#include +#include +#include / { @@ -62,16 +64,13 @@ }; &layout_75_ansi { - status = "okay"; transform = <&ansi_transform>; }; &layout_75_iso { - status = "okay"; transform = <&iso_transform>; }; &layout_75_all1u { - status = "okay"; transform = <&all_1u_transform>; }; diff --git a/app/boards/arm/planck/planck_rev6.dts b/app/boards/arm/planck/planck_rev6.dts index d3aaf8fed6e..2f34571fab6 100644 --- a/app/boards/arm/planck/planck_rev6.dts +++ b/app/boards/arm/planck/planck_rev6.dts @@ -9,7 +9,9 @@ #include #include -#include +#include +#include +#include / { @@ -142,16 +144,13 @@ zephyr_udc0: &usb { }; &layout_ortho_4x12_all1u { - status = "okay"; transform = <&layout_grid_transform>; }; &layout_ortho_4x12_1x2u { - status = "okay"; transform = <&layout_mit_transform>; }; &layout_ortho_4x12_2x2u { - status = "okay"; transform = <&layout_2x2u_transform>; }; diff --git a/app/boards/arm/preonic/preonic_rev3.dts b/app/boards/arm/preonic/preonic_rev3.dts index 8032e459482..0bb0e2ce32b 100644 --- a/app/boards/arm/preonic/preonic_rev3.dts +++ b/app/boards/arm/preonic/preonic_rev3.dts @@ -9,7 +9,9 @@ #include #include -#include +#include +#include +#include / { model = "Preonic PCD, rev3"; @@ -134,16 +136,13 @@ zephyr_udc0: &usb { }; &layout_ortho_5x12_all1u { - status = "okay"; transform = <&layout_grid_transform>; }; &layout_ortho_5x12_1x2u { - status = "okay"; transform = <&layout_mit_transform>; }; &layout_ortho_5x12_2x2u { - status = "okay"; transform = <&layout_2x2u_transform>; }; diff --git a/app/dts/layouts/common/60percent/60percent.dtsi b/app/dts/layouts/common/60percent/60percent.dtsi deleted file mode 100644 index 03f42e2a1bb..00000000000 --- a/app/dts/layouts/common/60percent/60percent.dtsi +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include - -&layout_60_ansi { - status = "disabled"; -}; - -&layout_60_iso { - status = "disabled"; -}; - -&layout_60_all1u { - status = "disabled"; -}; - -&layout_60_hhkb { - status = "disabled"; -}; - -/ { - layouts_common_60_percent_position_map: layouts_common_60_percent_position_map { - compatible = "zmk,physical-layout-position-map"; - - complete; - - layout_60_all1u { - physical-layout = <&layout_60_all1u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14> - , <15 16 17 18 19 20 21 22 23 24 25 26 27 28> - , <29 30 31 32 33 34 35 36 37 38 39 40 41> - , <42 43 44 45 46 47 48 49 50 51 52 53 54 55 56> - , <57 58 59 60 61 62 64 63 65> - ; - }; - - layout_60_ansi { - physical-layout = <&layout_60_ansi>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 61> - , <14 15 16 17 18 19 20 21 22 23 24 25 26 27> - , <28 29 30 31 32 33 34 35 36 37 38 39 40> - , <41 62 42 43 44 45 46 47 48 49 50 51 52 63 64> - , <53 54 55 56 57 58 60 59 65> - ; - }; - - layout_60_hhkb { - physical-layout = <&layout_60_hhkb>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 60> - , <14 15 16 17 18 19 20 21 22 23 24 25 26 27> - , <28 29 30 31 32 33 34 35 36 37 38 39 40> - , <41 61 42 43 44 45 46 47 48 49 50 51 52 62 63> - , <53 54 55 56 57 58 59 64 65> - ; - }; - - layout_60_iso { - physical-layout = <&layout_60_iso>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 62> - , <14 15 16 17 18 19 20 21 22 23 24 25 26 63> - , <27 28 29 30 31 32 33 34 35 36 37 38 40> - , <41 42 43 44 45 46 47 48 49 50 51 52 53 64 65> - , <54 55 56 57 58 59 61 60 39> - ; - }; - }; -}; \ No newline at end of file diff --git a/app/dts/layouts/common/60percent/all1u.dtsi b/app/dts/layouts/common/60percent/all1u.dtsi index 47e3ad38241..45431689111 100644 --- a/app/dts/layouts/common/60percent/all1u.dtsi +++ b/app/dts/layouts/common/60percent/all1u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -74,4 +75,17 @@ , <&key_physical_attrs 100 100 1400 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_60_percent_position_map { + layout_60_all1u { + physical-layout = <&layout_60_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 28> + , <29 30 31 32 33 34 35 36 37 38 39 40 41> + , <42 43 44 45 46 47 48 49 50 51 52 53 54 55 56> + , <57 58 59 60 61 62 64 63 65> + ; + }; +}; diff --git a/app/dts/layouts/common/60percent/ansi.dtsi b/app/dts/layouts/common/60percent/ansi.dtsi index 2c8074bc72c..b3b870c550f 100644 --- a/app/dts/layouts/common/60percent/ansi.dtsi +++ b/app/dts/layouts/common/60percent/ansi.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -69,4 +70,17 @@ , <&key_physical_attrs 125 100 1375 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_60_percent_position_map { + layout_60_ansi { + physical-layout = <&layout_60_ansi>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 61> + , <14 15 16 17 18 19 20 21 22 23 24 25 26 27> + , <28 29 30 31 32 33 34 35 36 37 38 39 40> + , <41 62 42 43 44 45 46 47 48 49 50 51 52 63 64> + , <53 54 55 56 57 58 60 59 65> + ; + }; +}; diff --git a/app/dts/layouts/common/60percent/hhkb.dtsi b/app/dts/layouts/common/60percent/hhkb.dtsi index f14e72be46c..a3c271e7e5e 100644 --- a/app/dts/layouts/common/60percent/hhkb.dtsi +++ b/app/dts/layouts/common/60percent/hhkb.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -68,4 +69,17 @@ , <&key_physical_attrs 150 100 1350 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_60_percent_position_map { + layout_60_hhkb { + physical-layout = <&layout_60_hhkb>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 60> + , <14 15 16 17 18 19 20 21 22 23 24 25 26 27> + , <28 29 30 31 32 33 34 35 36 37 38 39 40> + , <41 61 42 43 44 45 46 47 48 49 50 51 52 62 63> + , <53 54 55 56 57 58 59 64 65> + ; + }; +}; diff --git a/app/dts/layouts/common/60percent/iso.dtsi b/app/dts/layouts/common/60percent/iso.dtsi index 2e3a00d8208..e1214b58d17 100644 --- a/app/dts/layouts/common/60percent/iso.dtsi +++ b/app/dts/layouts/common/60percent/iso.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -70,4 +71,17 @@ , <&key_physical_attrs 125 100 1375 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_60_percent_position_map { + layout_60_iso { + physical-layout = <&layout_60_iso>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 62> + , <14 15 16 17 18 19 20 21 22 23 24 25 26 63> + , <27 28 29 30 31 32 33 34 35 36 37 38 40> + , <41 42 43 44 45 46 47 48 49 50 51 52 53 64 65> + , <54 55 56 57 58 59 61 60 39> + ; + }; +}; diff --git a/app/dts/layouts/common/60percent/position_map.dtsi b/app/dts/layouts/common/60percent/position_map.dtsi new file mode 100644 index 00000000000..b8db2d01c9f --- /dev/null +++ b/app/dts/layouts/common/60percent/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_common_60_percent_position_map: layouts_common_60_percent_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; diff --git a/app/dts/layouts/common/65percent/65percent.dtsi b/app/dts/layouts/common/65percent/65percent.dtsi deleted file mode 100644 index 9e46d315e93..00000000000 --- a/app/dts/layouts/common/65percent/65percent.dtsi +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include - -&layout_65_ansi { - status = "disabled"; -}; - -&layout_65_iso { - status = "disabled"; -}; - -&layout_65_all1u { - status = "disabled"; -}; - -&layout_65_hhkb { - status = "disabled"; -}; - -/ { - layouts_common_65_percent_position_map: layouts_common_65_percent_position_map { - compatible = "zmk,physical-layout-position-map"; - - complete; - - layout_65_all1u { - physical-layout = <&layout_65_all1u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> - , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 30> - , <31 32 33 34 35 36 37 38 39 40 41 42 43 44> - , <45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60> - , <61 62 63 64 65 66 67 68 69 70> - ; - }; - - layout_65_ansi { - physical-layout = <&layout_65_ansi>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 68 14> - , <15 16 17 18 19 20 21 22 23 24 25 26 27 28 29> - , <30 31 32 33 34 35 36 37 38 39 40 41 42 43> - , <44 69 45 46 47 48 49 50 51 52 53 54 55 70 56 57> - , <58 59 60 61 62 63 64 65 66 67> - ; - }; - - layout_65_hhkb { - physical-layout = <&layout_65_hhkb>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 65 14> - , <15 16 17 18 19 20 21 22 23 24 25 26 27 28 29> - , <30 31 32 33 34 35 36 37 38 39 40 41 42 43> - , <44 66 45 46 47 48 49 50 51 52 53 54 55 67 68 56> - , <57 58 59 60 61 62 63 69 70 64> - ; - }; - - layout_65_iso { - physical-layout = <&layout_65_iso>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 69 14> - , <15 16 17 18 19 20 21 22 23 24 25 26 27 70 28> - , <29 30 31 32 33 34 35 36 37 38 39 40 42 43> - , <44 45 46 47 48 49 50 51 52 53 54 55 56 41 57 58> - , <59 60 61 62 63 64 65 66 67 68> - ; - }; - }; -}; \ No newline at end of file diff --git a/app/dts/layouts/common/65percent/all1u.dtsi b/app/dts/layouts/common/65percent/all1u.dtsi index 8ab62ef2869..7ff70358975 100644 --- a/app/dts/layouts/common/65percent/all1u.dtsi +++ b/app/dts/layouts/common/65percent/all1u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -82,4 +83,17 @@ , <&key_physical_attrs 100 100 1500 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_65_percent_position_map { + layout_65_all1u { + physical-layout = <&layout_65_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 30> + , <31 32 33 34 35 36 37 38 39 40 41 42 43 44> + , <45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60> + , <61 62 63 64 65 66 67 68 69 70> + ; + }; +}; diff --git a/app/dts/layouts/common/65percent/ansi.dtsi b/app/dts/layouts/common/65percent/ansi.dtsi index 9685515c4b7..991a672c5e7 100644 --- a/app/dts/layouts/common/65percent/ansi.dtsi +++ b/app/dts/layouts/common/65percent/ansi.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -76,4 +77,17 @@ , <&key_physical_attrs 100 100 1500 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_65_percent_position_map { + layout_65_ansi { + physical-layout = <&layout_65_ansi>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 68 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 28 29> + , <30 31 32 33 34 35 36 37 38 39 40 41 42 43> + , <44 69 45 46 47 48 49 50 51 52 53 54 55 70 56 57> + , <58 59 60 61 62 63 64 65 66 67> + ; + }; +}; diff --git a/app/dts/layouts/common/65percent/hhkb.dtsi b/app/dts/layouts/common/65percent/hhkb.dtsi index cbadad96e5d..d0684f3c61d 100644 --- a/app/dts/layouts/common/65percent/hhkb.dtsi +++ b/app/dts/layouts/common/65percent/hhkb.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -73,4 +74,17 @@ , <&key_physical_attrs 100 100 1500 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_65_percent_position_map { + layout_65_hhkb { + physical-layout = <&layout_65_hhkb>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 65 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 28 29> + , <30 31 32 33 34 35 36 37 38 39 40 41 42 43> + , <44 66 45 46 47 48 49 50 51 52 53 54 55 67 68 56> + , <57 58 59 60 61 62 63 69 70 64> + ; + }; +}; diff --git a/app/dts/layouts/common/65percent/iso.dtsi b/app/dts/layouts/common/65percent/iso.dtsi index 3395c614e34..c94ee1d6a44 100644 --- a/app/dts/layouts/common/65percent/iso.dtsi +++ b/app/dts/layouts/common/65percent/iso.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -77,4 +78,17 @@ , <&key_physical_attrs 100 100 1500 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_65_percent_position_map { + layout_65_iso { + physical-layout = <&layout_65_iso>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 69 14> + , <15 16 17 18 19 20 21 22 23 24 25 26 27 70 28> + , <29 30 31 32 33 34 35 36 37 38 39 40 42 43> + , <44 45 46 47 48 49 50 51 52 53 54 55 56 41 57 58> + , <59 60 61 62 63 64 65 66 67 68> + ; + }; +}; diff --git a/app/dts/layouts/common/65percent/position_map.dtsi b/app/dts/layouts/common/65percent/position_map.dtsi new file mode 100644 index 00000000000..b761b8580cc --- /dev/null +++ b/app/dts/layouts/common/65percent/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_common_65_percent_position_map: layouts_common_65_percent_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; diff --git a/app/dts/layouts/common/75percent/75percent.dtsi b/app/dts/layouts/common/75percent/75percent.dtsi deleted file mode 100644 index 1781fbd3ba0..00000000000 --- a/app/dts/layouts/common/75percent/75percent.dtsi +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -&layout_75_ansi { - status = "disabled"; -}; - -&layout_75_iso { - status = "disabled"; -}; - -&layout_75_all1u { - status = "disabled"; -}; - -/ { - layouts_common_75_percent_position_map: layouts_common_75_percent_position_map { - compatible = "zmk,physical-layout-position-map"; - - complete; - - layout_75_all1u { - physical-layout = <&layout_75_all1u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> - , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31> - , <32 33 34 35 36 37 38 39 40 41 42 43 44 45 46> - , <47 48 49 50 51 52 53 54 55 56 57 58 59 60> - , <61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76> - , <77 78 79 80 81 82 83 84 85 86> - ; - }; - - layout_75_ansi { - physical-layout = <&layout_75_ansi>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> - , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 84 30> - , <31 32 33 34 35 36 37 38 39 40 41 42 43 44 45> - , <46 47 48 49 50 51 52 53 54 55 56 57 58 59> - , <60 85 61 62 63 64 65 66 67 68 69 70 71 86 72 73> - , <74 75 76 77 78 79 80 81 82 83> - ; - }; - - layout_75_iso { - physical-layout = <&layout_75_iso>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> - , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 85 30> - , <31 32 33 34 35 36 37 38 39 40 41 42 43 86 44> - , <45 46 47 48 49 50 51 52 53 54 55 56 58 59> - , <60 61 62 63 64 65 66 67 68 69 70 71 72 57 73 74> - , <75 76 77 78 79 80 81 82 83 84> - ; - }; - }; -}; \ No newline at end of file diff --git a/app/dts/layouts/common/75percent/all1u.dtsi b/app/dts/layouts/common/75percent/all1u.dtsi index 04c12bdbb14..fbba5df691e 100644 --- a/app/dts/layouts/common/75percent/all1u.dtsi +++ b/app/dts/layouts/common/75percent/all1u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -95,4 +96,18 @@ , <&key_physical_attrs 100 100 1500 500 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_75_percent_position_map { + layout_75_all1u { + physical-layout = <&layout_75_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31> + , <32 33 34 35 36 37 38 39 40 41 42 43 44 45 46> + , <47 48 49 50 51 52 53 54 55 56 57 58 59 60> + , <61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76> + , <77 78 79 80 81 82 83 84 85 86> + ; + }; +}; diff --git a/app/dts/layouts/common/75percent/ansi.dtsi b/app/dts/layouts/common/75percent/ansi.dtsi index 6c9a65c7650..8d949233675 100644 --- a/app/dts/layouts/common/75percent/ansi.dtsi +++ b/app/dts/layouts/common/75percent/ansi.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -92,4 +93,18 @@ , <&key_physical_attrs 100 100 1500 500 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_75_percent_position_map { + layout_75_ansi { + physical-layout = <&layout_75_ansi>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 84 30> + , <31 32 33 34 35 36 37 38 39 40 41 42 43 44 45> + , <46 47 48 49 50 51 52 53 54 55 56 57 58 59> + , <60 85 61 62 63 64 65 66 67 68 69 70 71 86 72 73> + , <74 75 76 77 78 79 80 81 82 83> + ; + }; +}; diff --git a/app/dts/layouts/common/75percent/iso.dtsi b/app/dts/layouts/common/75percent/iso.dtsi index f3ee0c51073..edbb4b40199 100644 --- a/app/dts/layouts/common/75percent/iso.dtsi +++ b/app/dts/layouts/common/75percent/iso.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -93,4 +94,18 @@ , <&key_physical_attrs 100 100 1500 500 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_75_percent_position_map { + layout_75_iso { + physical-layout = <&layout_75_iso>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15> + , <16 17 18 19 20 21 22 23 24 25 26 27 28 29 85 30> + , <31 32 33 34 35 36 37 38 39 40 41 42 43 86 44> + , <45 46 47 48 49 50 51 52 53 54 55 56 58 59> + , <60 61 62 63 64 65 66 67 68 69 70 71 72 57 73 74> + , <75 76 77 78 79 80 81 82 83 84> + ; + }; +}; diff --git a/app/dts/layouts/common/75percent/position_map.dtsi b/app/dts/layouts/common/75percent/position_map.dtsi new file mode 100644 index 00000000000..d5f9cdbb691 --- /dev/null +++ b/app/dts/layouts/common/75percent/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_common_75_percent_position_map: layouts_common_75_percent_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; diff --git a/app/dts/layouts/common/ortho_4x12/1x2u.dtsi b/app/dts/layouts/common/ortho_4x12/1x2u.dtsi index 23646afc9c7..c3f0c30f467 100644 --- a/app/dts/layouts/common/ortho_4x12/1x2u.dtsi +++ b/app/dts/layouts/common/ortho_4x12/1x2u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -55,4 +56,16 @@ , <&key_physical_attrs 100 100 1100 300 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_ortho_4x12_position_map { + layout_ortho_4x12_1x2u { + physical-layout = <&layout_ortho_4x12_1x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 47 42 43 44 45 46> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_4x12/2x2u.dtsi b/app/dts/layouts/common/ortho_4x12/2x2u.dtsi index d091786938a..5ee5d42321c 100644 --- a/app/dts/layouts/common/ortho_4x12/2x2u.dtsi +++ b/app/dts/layouts/common/ortho_4x12/2x2u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -54,4 +55,16 @@ , <&key_physical_attrs 100 100 1100 300 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_ortho_4x12_position_map { + layout_ortho_4x12_2x2u { + physical-layout = <&layout_ortho_4x12_2x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 46 47 41 42 43 44 45> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_4x12/all1u.dtsi b/app/dts/layouts/common/ortho_4x12/all1u.dtsi index 323821d4662..2829d5e3c62 100644 --- a/app/dts/layouts/common/ortho_4x12/all1u.dtsi +++ b/app/dts/layouts/common/ortho_4x12/all1u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -56,4 +57,16 @@ , <&key_physical_attrs 100 100 1100 300 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_ortho_4x12_position_map { + layout_ortho_4x12_all1u { + physical-layout = <&layout_ortho_4x12_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi b/app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi deleted file mode 100644 index 0c361b109bc..00000000000 --- a/app/dts/layouts/common/ortho_4x12/ortho_4x12.dtsi +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include - -&layout_ortho_4x12_all1u { - status = "disabled"; -}; - -&layout_ortho_4x12_1x2u { - status = "disabled"; -}; - -&layout_ortho_4x12_2x2u { - status = "disabled"; -}; - -/ { - layouts_common_ortho_4x12_position_map: layouts_common_ortho_4x12_position_map { - compatible = "zmk,physical-layout-position-map"; - - complete; - - layout_ortho_4x12_all1u { - physical-layout = <&layout_ortho_4x12_all1u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , <36 37 38 39 40 41 42 43 44 45 46 47> - ; - }; - - layout_ortho_4x12_2x2u { - physical-layout = <&layout_ortho_4x12_2x2u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , <36 37 38 39 40 46 47 41 42 43 44 45> - ; - }; - - layout_ortho_4x12_1x2u { - physical-layout = <&layout_ortho_4x12_1x2u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , <36 37 38 39 40 41 47 42 43 44 45 46> - ; - }; - }; -}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_4x12/position_map.dtsi b/app/dts/layouts/common/ortho_4x12/position_map.dtsi new file mode 100644 index 00000000000..c93a32bdf79 --- /dev/null +++ b/app/dts/layouts/common/ortho_4x12/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_common_ortho_4x12_position_map: layouts_common_ortho_4x12_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; diff --git a/app/dts/layouts/common/ortho_5x12/1x2u.dtsi b/app/dts/layouts/common/ortho_5x12/1x2u.dtsi index 2072cc35dd1..5d12ea45af9 100644 --- a/app/dts/layouts/common/ortho_5x12/1x2u.dtsi +++ b/app/dts/layouts/common/ortho_5x12/1x2u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -67,4 +68,17 @@ , <&key_physical_attrs 100 100 1100 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_ortho_5x12_position_map { + layout_ortho_5x12_1x2u { + physical-layout = <&layout_ortho_5x12_1x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + , <48 49 50 51 52 53 59 54 55 56 57 58> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_5x12/2x2u.dtsi b/app/dts/layouts/common/ortho_5x12/2x2u.dtsi index 5e55f734e19..26079eb8f78 100644 --- a/app/dts/layouts/common/ortho_5x12/2x2u.dtsi +++ b/app/dts/layouts/common/ortho_5x12/2x2u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -66,4 +67,17 @@ , <&key_physical_attrs 100 100 1100 400 0 0 0> ; }; -}; \ No newline at end of file +}; + +&layouts_common_ortho_5x12_position_map { + layout_ortho_5x12_2x2u { + physical-layout = <&layout_ortho_5x12_2x2u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + , <48 49 50 51 52 58 59 53 54 55 56 57> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_5x12/all1u.dtsi b/app/dts/layouts/common/ortho_5x12/all1u.dtsi index 53afb469f85..3b8f7501de3 100644 --- a/app/dts/layouts/common/ortho_5x12/all1u.dtsi +++ b/app/dts/layouts/common/ortho_5x12/all1u.dtsi @@ -1,3 +1,4 @@ +#include #include / { @@ -69,3 +70,16 @@ ; }; }; + +&layouts_common_ortho_5x12_position_map { + layout_ortho_5x12_all1u { + physical-layout = <&layout_ortho_5x12_all1u>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , <36 37 38 39 40 41 42 43 44 45 46 47> + , <48 49 50 51 52 53 54 55 56 57 58 59> + ; + }; +}; diff --git a/app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi b/app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi deleted file mode 100644 index d1a6df7e812..00000000000 --- a/app/dts/layouts/common/ortho_5x12/ortho_5x12.dtsi +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include - -&layout_ortho_5x12_all1u { - status = "disabled"; -}; - -&layout_ortho_5x12_1x2u { - status = "disabled"; -}; - -&layout_ortho_5x12_2x2u { - status = "disabled"; -}; - -/ { - layouts_common_ortho_5x12_position_map: layouts_common_ortho_5x12_position_map { - compatible = "zmk,physical-layout-position-map"; - - complete; - - layout_ortho_5x12_all1u { - physical-layout = <&layout_ortho_5x12_all1u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , <36 37 38 39 40 41 42 43 44 45 46 47> - , <48 49 50 51 52 53 54 55 56 57 58 59> - ; - }; - - layout_ortho_5x12_2x2u { - physical-layout = <&layout_ortho_5x12_2x2u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , <36 37 38 39 40 41 42 43 44 45 46 47> - , <48 49 50 51 52 58 59 53 54 55 56 57> - ; - }; - - layout_ortho_5x12_1x2u { - physical-layout = <&layout_ortho_5x12_1x2u>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , <36 37 38 39 40 41 42 43 44 45 46 47> - , <48 49 50 51 52 53 59 54 55 56 57 58> - ; - }; - }; -}; \ No newline at end of file diff --git a/app/dts/layouts/common/ortho_5x12/position_map.dtsi b/app/dts/layouts/common/ortho_5x12/position_map.dtsi new file mode 100644 index 00000000000..e292b4e7a9e --- /dev/null +++ b/app/dts/layouts/common/ortho_5x12/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_common_ortho_5x12_position_map: layouts_common_ortho_5x12_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; diff --git a/app/dts/layouts/common/tkl/ansi.dtsi b/app/dts/layouts/common/tkl/ansi.dtsi index 639ac471a67..83354c4f551 100644 --- a/app/dts/layouts/common/tkl/ansi.dtsi +++ b/app/dts/layouts/common/tkl/ansi.dtsi @@ -1,3 +1,4 @@ +#include #include / { diff --git a/app/dts/layouts/common/tkl/position_map.dtsi b/app/dts/layouts/common/tkl/position_map.dtsi new file mode 100644 index 00000000000..8ac528e39bd --- /dev/null +++ b/app/dts/layouts/common/tkl/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_common_tkl_position_map: layouts_common_tkl_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; From 60a8f2934043b98a8fabcd1dd7dce1a4de30c2a9 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Tue, 1 Oct 2024 19:07:45 -0500 Subject: [PATCH 40/42] feat(boards)!: refactor Corne layouts Split up the Corne layout files to match the previous commit. --- app/boards/shields/corne/corne.dtsi | 3 +- .../splitkb_aurora_corne.dtsi | 3 +- app/dts/layouts/foostan/corne.dtsi | 121 ------------------ app/dts/layouts/foostan/corne/5column.dtsi | 59 +++++++++ app/dts/layouts/foostan/corne/6column.dtsi | 65 ++++++++++ .../layouts/foostan/corne/position_map.dtsi | 7 + 6 files changed, 135 insertions(+), 123 deletions(-) delete mode 100644 app/dts/layouts/foostan/corne.dtsi create mode 100644 app/dts/layouts/foostan/corne/5column.dtsi create mode 100644 app/dts/layouts/foostan/corne/6column.dtsi create mode 100644 app/dts/layouts/foostan/corne/position_map.dtsi diff --git a/app/boards/shields/corne/corne.dtsi b/app/boards/shields/corne/corne.dtsi index e4339e617d5..e1dcc058b75 100644 --- a/app/boards/shields/corne/corne.dtsi +++ b/app/boards/shields/corne/corne.dtsi @@ -6,7 +6,8 @@ #include -#include +#include +#include &foostan_corne_6col_layout { transform = <&default_transform>; diff --git a/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi b/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi index 0b0ffdf357b..f57cd2355a7 100644 --- a/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi +++ b/app/boards/shields/splitkb_aurora_corne/splitkb_aurora_corne.dtsi @@ -6,7 +6,8 @@ #include -#include +#include +#include &foostan_corne_6col_layout { transform = <&default_transform>; diff --git a/app/dts/layouts/foostan/corne.dtsi b/app/dts/layouts/foostan/corne.dtsi deleted file mode 100644 index 5a644103e04..00000000000 --- a/app/dts/layouts/foostan/corne.dtsi +++ /dev/null @@ -1,121 +0,0 @@ -#include - -/ { - foostan_corne_6col_layout: foostan_corne_6col_layout { - compatible = "zmk,physical-layout"; - display-name = "6 Column"; - - keys // w h x y rot rx ry - = <&key_physical_attrs 100 100 0 37 0 0 0> - , <&key_physical_attrs 100 100 100 37 0 0 0> - , <&key_physical_attrs 100 100 200 12 0 0 0> - , <&key_physical_attrs 100 100 300 0 0 0 0> - , <&key_physical_attrs 100 100 400 12 0 0 0> - , <&key_physical_attrs 100 100 500 24 0 0 0> - , <&key_physical_attrs 100 100 800 24 0 0 0> - , <&key_physical_attrs 100 100 900 12 0 0 0> - , <&key_physical_attrs 100 100 1000 0 0 0 0> - , <&key_physical_attrs 100 100 1100 12 0 0 0> - , <&key_physical_attrs 100 100 1200 37 0 0 0> - , <&key_physical_attrs 100 100 1300 37 0 0 0> - , <&key_physical_attrs 100 100 0 137 0 0 0> - , <&key_physical_attrs 100 100 100 137 0 0 0> - , <&key_physical_attrs 100 100 200 112 0 0 0> - , <&key_physical_attrs 100 100 300 100 0 0 0> - , <&key_physical_attrs 100 100 400 112 0 0 0> - , <&key_physical_attrs 100 100 500 124 0 0 0> - , <&key_physical_attrs 100 100 800 124 0 0 0> - , <&key_physical_attrs 100 100 900 112 0 0 0> - , <&key_physical_attrs 100 100 1000 100 0 0 0> - , <&key_physical_attrs 100 100 1100 112 0 0 0> - , <&key_physical_attrs 100 100 1200 137 0 0 0> - , <&key_physical_attrs 100 100 1300 137 0 0 0> - , <&key_physical_attrs 100 100 0 237 0 0 0> - , <&key_physical_attrs 100 100 100 237 0 0 0> - , <&key_physical_attrs 100 100 200 212 0 0 0> - , <&key_physical_attrs 100 100 300 200 0 0 0> - , <&key_physical_attrs 100 100 400 212 0 0 0> - , <&key_physical_attrs 100 100 500 224 0 0 0> - , <&key_physical_attrs 100 100 800 224 0 0 0> - , <&key_physical_attrs 100 100 900 212 0 0 0> - , <&key_physical_attrs 100 100 1000 200 0 0 0> - , <&key_physical_attrs 100 100 1100 212 0 0 0> - , <&key_physical_attrs 100 100 1200 237 0 0 0> - , <&key_physical_attrs 100 100 1300 237 0 0 0> - , <&key_physical_attrs 100 100 350 312 0 0 0> - , <&key_physical_attrs 100 100 450 312 1200 450 412> - , <&key_physical_attrs 100 150 548 283 2400 548 433> - , <&key_physical_attrs 100 150 752 283 (-2400) 852 433> - , <&key_physical_attrs 100 100 850 312 (-1200) 950 412> - , <&key_physical_attrs 100 100 950 312 0 0 0> - ; - }; - - foostan_corne_5col_layout: foostan_corne_5col_layout { - compatible = "zmk,physical-layout"; - display-name = "5 Column"; - - keys // w h x y rot rx ry - = <&key_physical_attrs 100 100 0 37 0 0 0> - , <&key_physical_attrs 100 100 100 12 0 0 0> - , <&key_physical_attrs 100 100 200 0 0 0 0> - , <&key_physical_attrs 100 100 300 12 0 0 0> - , <&key_physical_attrs 100 100 400 24 0 0 0> - , <&key_physical_attrs 100 100 700 24 0 0 0> - , <&key_physical_attrs 100 100 800 12 0 0 0> - , <&key_physical_attrs 100 100 900 0 0 0 0> - , <&key_physical_attrs 100 100 1000 12 0 0 0> - , <&key_physical_attrs 100 100 1100 37 0 0 0> - , <&key_physical_attrs 100 100 0 137 0 0 0> - , <&key_physical_attrs 100 100 100 112 0 0 0> - , <&key_physical_attrs 100 100 200 100 0 0 0> - , <&key_physical_attrs 100 100 300 112 0 0 0> - , <&key_physical_attrs 100 100 400 124 0 0 0> - , <&key_physical_attrs 100 100 700 124 0 0 0> - , <&key_physical_attrs 100 100 800 112 0 0 0> - , <&key_physical_attrs 100 100 900 100 0 0 0> - , <&key_physical_attrs 100 100 1000 112 0 0 0> - , <&key_physical_attrs 100 100 1100 137 0 0 0> - , <&key_physical_attrs 100 100 0 237 0 0 0> - , <&key_physical_attrs 100 100 100 212 0 0 0> - , <&key_physical_attrs 100 100 200 200 0 0 0> - , <&key_physical_attrs 100 100 300 212 0 0 0> - , <&key_physical_attrs 100 100 400 224 0 0 0> - , <&key_physical_attrs 100 100 700 224 0 0 0> - , <&key_physical_attrs 100 100 800 212 0 0 0> - , <&key_physical_attrs 100 100 900 200 0 0 0> - , <&key_physical_attrs 100 100 1000 212 0 0 0> - , <&key_physical_attrs 100 100 1100 237 0 0 0> - , <&key_physical_attrs 100 100 250 312 0 0 0> - , <&key_physical_attrs 100 100 350 312 1200 350 412> - , <&key_physical_attrs 100 150 448 283 2400 448 433> - , <&key_physical_attrs 100 150 652 283 (-2400) 752 433> - , <&key_physical_attrs 100 100 750 312 (-1200) 850 412> - , <&key_physical_attrs 100 100 850 312 0 0 0> - ; - }; - - foostan_corne_position_map { - compatible = "zmk,physical-layout-position-map"; - - complete; - - twelve { - physical-layout = <&foostan_corne_6col_layout>; - positions - = < 0 1 2 3 4 5 6 7 8 9 10 11> - , <12 13 14 15 16 17 18 19 20 21 22 23> - , <24 25 26 27 28 29 30 31 32 33 34 35> - , < 36 37 38 39 40 41 >; - }; - - ten { - physical-layout = <&foostan_corne_5col_layout>; - positions - = <36 0 1 2 3 4 5 6 7 8 9 37> - , <38 10 11 12 13 14 15 16 17 18 19 39> - , <40 20 21 22 23 24 25 26 27 28 29 41> - , < 30 31 32 33 34 35 >; - }; - }; -}; diff --git a/app/dts/layouts/foostan/corne/5column.dtsi b/app/dts/layouts/foostan/corne/5column.dtsi new file mode 100644 index 00000000000..2d96d0b262f --- /dev/null +++ b/app/dts/layouts/foostan/corne/5column.dtsi @@ -0,0 +1,59 @@ +#include +#include + +/ { + foostan_corne_5col_layout: foostan_corne_5col_layout { + compatible = "zmk,physical-layout"; + display-name = "5 Column"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 37 0 0 0> + , <&key_physical_attrs 100 100 100 12 0 0 0> + , <&key_physical_attrs 100 100 200 0 0 0 0> + , <&key_physical_attrs 100 100 300 12 0 0 0> + , <&key_physical_attrs 100 100 400 24 0 0 0> + , <&key_physical_attrs 100 100 700 24 0 0 0> + , <&key_physical_attrs 100 100 800 12 0 0 0> + , <&key_physical_attrs 100 100 900 0 0 0 0> + , <&key_physical_attrs 100 100 1000 12 0 0 0> + , <&key_physical_attrs 100 100 1100 37 0 0 0> + , <&key_physical_attrs 100 100 0 137 0 0 0> + , <&key_physical_attrs 100 100 100 112 0 0 0> + , <&key_physical_attrs 100 100 200 100 0 0 0> + , <&key_physical_attrs 100 100 300 112 0 0 0> + , <&key_physical_attrs 100 100 400 124 0 0 0> + , <&key_physical_attrs 100 100 700 124 0 0 0> + , <&key_physical_attrs 100 100 800 112 0 0 0> + , <&key_physical_attrs 100 100 900 100 0 0 0> + , <&key_physical_attrs 100 100 1000 112 0 0 0> + , <&key_physical_attrs 100 100 1100 137 0 0 0> + , <&key_physical_attrs 100 100 0 237 0 0 0> + , <&key_physical_attrs 100 100 100 212 0 0 0> + , <&key_physical_attrs 100 100 200 200 0 0 0> + , <&key_physical_attrs 100 100 300 212 0 0 0> + , <&key_physical_attrs 100 100 400 224 0 0 0> + , <&key_physical_attrs 100 100 700 224 0 0 0> + , <&key_physical_attrs 100 100 800 212 0 0 0> + , <&key_physical_attrs 100 100 900 200 0 0 0> + , <&key_physical_attrs 100 100 1000 212 0 0 0> + , <&key_physical_attrs 100 100 1100 237 0 0 0> + , <&key_physical_attrs 100 100 250 312 0 0 0> + , <&key_physical_attrs 100 100 350 312 1200 350 412> + , <&key_physical_attrs 100 150 448 283 2400 448 433> + , <&key_physical_attrs 100 150 652 283 (-2400) 752 433> + , <&key_physical_attrs 100 100 750 312 (-1200) 850 412> + , <&key_physical_attrs 100 100 850 312 0 0 0> + ; + }; +}; + +&layouts_foostan_corne_position_map { + five_column { + physical-layout = <&foostan_corne_5col_layout>; + positions + = <36 0 1 2 3 4 5 6 7 8 9 37> + , <38 10 11 12 13 14 15 16 17 18 19 39> + , <40 20 21 22 23 24 25 26 27 28 29 41> + , < 30 31 32 33 34 35 >; + }; +}; diff --git a/app/dts/layouts/foostan/corne/6column.dtsi b/app/dts/layouts/foostan/corne/6column.dtsi new file mode 100644 index 00000000000..bc1a196d53d --- /dev/null +++ b/app/dts/layouts/foostan/corne/6column.dtsi @@ -0,0 +1,65 @@ +#include +#include + +/ { + foostan_corne_6col_layout: foostan_corne_6col_layout { + compatible = "zmk,physical-layout"; + display-name = "6 Column"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 0 37 0 0 0> + , <&key_physical_attrs 100 100 100 37 0 0 0> + , <&key_physical_attrs 100 100 200 12 0 0 0> + , <&key_physical_attrs 100 100 300 0 0 0 0> + , <&key_physical_attrs 100 100 400 12 0 0 0> + , <&key_physical_attrs 100 100 500 24 0 0 0> + , <&key_physical_attrs 100 100 800 24 0 0 0> + , <&key_physical_attrs 100 100 900 12 0 0 0> + , <&key_physical_attrs 100 100 1000 0 0 0 0> + , <&key_physical_attrs 100 100 1100 12 0 0 0> + , <&key_physical_attrs 100 100 1200 37 0 0 0> + , <&key_physical_attrs 100 100 1300 37 0 0 0> + , <&key_physical_attrs 100 100 0 137 0 0 0> + , <&key_physical_attrs 100 100 100 137 0 0 0> + , <&key_physical_attrs 100 100 200 112 0 0 0> + , <&key_physical_attrs 100 100 300 100 0 0 0> + , <&key_physical_attrs 100 100 400 112 0 0 0> + , <&key_physical_attrs 100 100 500 124 0 0 0> + , <&key_physical_attrs 100 100 800 124 0 0 0> + , <&key_physical_attrs 100 100 900 112 0 0 0> + , <&key_physical_attrs 100 100 1000 100 0 0 0> + , <&key_physical_attrs 100 100 1100 112 0 0 0> + , <&key_physical_attrs 100 100 1200 137 0 0 0> + , <&key_physical_attrs 100 100 1300 137 0 0 0> + , <&key_physical_attrs 100 100 0 237 0 0 0> + , <&key_physical_attrs 100 100 100 237 0 0 0> + , <&key_physical_attrs 100 100 200 212 0 0 0> + , <&key_physical_attrs 100 100 300 200 0 0 0> + , <&key_physical_attrs 100 100 400 212 0 0 0> + , <&key_physical_attrs 100 100 500 224 0 0 0> + , <&key_physical_attrs 100 100 800 224 0 0 0> + , <&key_physical_attrs 100 100 900 212 0 0 0> + , <&key_physical_attrs 100 100 1000 200 0 0 0> + , <&key_physical_attrs 100 100 1100 212 0 0 0> + , <&key_physical_attrs 100 100 1200 237 0 0 0> + , <&key_physical_attrs 100 100 1300 237 0 0 0> + , <&key_physical_attrs 100 100 350 312 0 0 0> + , <&key_physical_attrs 100 100 450 312 1200 450 412> + , <&key_physical_attrs 100 150 548 283 2400 548 433> + , <&key_physical_attrs 100 150 752 283 (-2400) 852 433> + , <&key_physical_attrs 100 100 850 312 (-1200) 950 412> + , <&key_physical_attrs 100 100 950 312 0 0 0> + ; + }; +}; + +&layouts_foostan_corne_position_map { + twelve { + physical-layout = <&foostan_corne_6col_layout>; + positions + = < 0 1 2 3 4 5 6 7 8 9 10 11> + , <12 13 14 15 16 17 18 19 20 21 22 23> + , <24 25 26 27 28 29 30 31 32 33 34 35> + , < 36 37 38 39 40 41 >; + }; +}; diff --git a/app/dts/layouts/foostan/corne/position_map.dtsi b/app/dts/layouts/foostan/corne/position_map.dtsi new file mode 100644 index 00000000000..7cf87d72cdc --- /dev/null +++ b/app/dts/layouts/foostan/corne/position_map.dtsi @@ -0,0 +1,7 @@ +/ { + layouts_foostan_corne_position_map: layouts_foostan_corne_position_map { + compatible = "zmk,physical-layout-position-map"; + + complete; + }; +}; From c05aed2f19f062d833496b47c76f7b52bf62f346 Mon Sep 17 00:00:00 2001 From: Nicolas Munnich Date: Thu, 3 Oct 2024 15:45:06 +0200 Subject: [PATCH 41/42] fix(boards): Corneish-zen physical layout --- app/boards/arm/corneish_zen/corneish_zen.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/boards/arm/corneish_zen/corneish_zen.dtsi b/app/boards/arm/corneish_zen/corneish_zen.dtsi index 119781a29d5..788b7613a5b 100644 --- a/app/boards/arm/corneish_zen/corneish_zen.dtsi +++ b/app/boards/arm/corneish_zen/corneish_zen.dtsi @@ -10,7 +10,8 @@ #include -#include +#include +#include &foostan_corne_6col_layout { transform = <&default_transform>; From 29b39f2b9f0977098601b201be1942d299b44da5 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Thu, 3 Oct 2024 14:28:05 -0600 Subject: [PATCH 42/42] feat: A few enhancements to our RPC messages. * More fine grained status reporting when saving changes. Needed to we can notify the client if we've got errors saving settings due to running out of space, etc. * Return the max layer name lenght in the keymap payload, for the UI to leverage. --- app/src/keymap.c | 45 ++++++++++++++++++++++--------- app/src/studio/keymap_subsystem.c | 29 +++++++++++++++++--- app/west.yml | 2 +- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/app/src/keymap.c b/app/src/keymap.c index ad3c7278a21..0ea64b340fd 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -432,7 +432,7 @@ int zmk_keymap_check_unsaved_changes(void) { #define LAYER_NAME_SETTINGS_KEY "keymap/l_n/%d" #define LAYER_BINDING_SETTINGS_KEY "keymap/l/%d/%d" -static void save_bindings(void) { +static int save_bindings(void) { for (int l = 0; l < ZMK_KEYMAP_LAYERS_LEN; l++) { uint8_t *pending = zmk_keymap_layer_pending_changes[l]; @@ -461,45 +461,64 @@ static void save_bindings(void) { char setting_name[20]; sprintf(setting_name, LAYER_BINDING_SETTINGS_KEY, l, kp); - settings_save_one(setting_name, &binding_setting, len); + int ret = settings_save_one(setting_name, &binding_setting, len); + if (ret < 0) { + LOG_ERR("Failed to save keymap binding at %d on layer %d (%d)", l, kp, ret); + return ret; + } } } *pending = 0; } + + return 0; } #if IS_ENABLED(CONFIG_ZMK_KEYMAP_LAYER_REORDERING) -static void save_layer_orders(void) { - settings_save_one(LAYER_ORDER_SETTINGS_KEY, keymap_layer_orders, - ARRAY_SIZE(keymap_layer_orders)); +static int save_layer_orders(void) { + int ret = settings_save_one(LAYER_ORDER_SETTINGS_KEY, keymap_layer_orders, + ARRAY_SIZE(keymap_layer_orders)); + if (ret < 0) { + return ret; + } + memcpy(settings_layer_orders, keymap_layer_orders, ARRAY_SIZE(keymap_layer_orders)); + return 0; } #endif // IS_ENABLED(CONFIG_ZMK_KEYMAP_LAYER_REORDERING) -static void save_layer_names(void) { +static int save_layer_names(void) { for (int id = 0; id < ZMK_KEYMAP_LAYERS_LEN; id++) { if (changed_layer_names & BIT(id)) { char setting_name[14]; sprintf(setting_name, LAYER_NAME_SETTINGS_KEY, id); - settings_save_one(setting_name, zmk_keymap_layer_names[id], - strlen(zmk_keymap_layer_names[id])); + int ret = settings_save_one(setting_name, zmk_keymap_layer_names[id], + strlen(zmk_keymap_layer_names[id])); + if (ret < 0) { + return ret; + } } } changed_layer_names = 0; + return 0; } int zmk_keymap_save_changes(void) { - save_bindings(); + int ret = save_bindings(); + if (ret < 0) { + return ret; + } #if IS_ENABLED(CONFIG_ZMK_KEYMAP_LAYER_REORDERING) - save_layer_orders(); + ret = save_layer_orders(); + if (ret < 0) { + return ret; + } #endif // IS_ENABLED(CONFIG_ZMK_KEYMAP_LAYER_REORDERING) - save_layer_names(); - - return 0; + return save_layer_names(); } #if IS_ENABLED(CONFIG_ZMK_KEYMAP_LAYER_REORDERING) diff --git a/app/src/studio/keymap_subsystem.c b/app/src/studio/keymap_subsystem.c index 25297b63c8d..c3a78be01ea 100644 --- a/app/src/studio/keymap_subsystem.c +++ b/app/src/studio/keymap_subsystem.c @@ -103,6 +103,7 @@ zmk_studio_Response get_keymap(const zmk_studio_Request *req) { resp.layers.funcs.encode = encode_keymap_layers; + resp.max_layer_name_length = CONFIG_ZMK_KEYMAP_LAYER_NAME_MAX_LEN; resp.available_layers = 0; for (zmk_keymap_layer_index_t index = 0; index < ZMK_KEYMAP_LAYERS_LEN; index++) { @@ -174,25 +175,47 @@ zmk_studio_Response check_unsaved_changes(const zmk_studio_Request *req) { return KEYMAP_RESPONSE(check_unsaved_changes, layout_changes > 0 || keymap_changes > 0); } +static void map_errno_to_save_resp(int err, zmk_keymap_SaveChangesResponse *resp) { + resp->which_result = zmk_keymap_SaveChangesResponse_err_tag; + + switch (err) { + case -ENOTSUP: + resp->result.err = zmk_keymap_SaveChangesErrorCode_SAVE_CHANGES_ERR_NOT_SUPPORTED; + break; + case -ENOSPC: + resp->result.err = zmk_keymap_SaveChangesErrorCode_SAVE_CHANGES_ERR_NO_SPACE; + break; + default: + resp->result.err = zmk_keymap_SaveChangesErrorCode_SAVE_CHANGES_ERR_GENERIC; + break; + } +} + zmk_studio_Response save_changes(const zmk_studio_Request *req) { + zmk_keymap_SaveChangesResponse resp = zmk_keymap_SaveChangesResponse_init_zero; + resp.which_result = zmk_keymap_SaveChangesResponse_ok_tag; + resp.result.ok = true; + LOG_DBG(""); int ret = zmk_physical_layouts_save_selected(); if (ret < 0) { LOG_WRN("Failed to save selected physical layout (%d)", ret); - return ZMK_RPC_SIMPLE_ERR(GENERIC); + map_errno_to_save_resp(ret, &resp); + return KEYMAP_RESPONSE(save_changes, resp); } ret = zmk_keymap_save_changes(); if (ret < 0) { LOG_WRN("Failed to save keymap changes (%d)", ret); - return ZMK_RPC_SIMPLE_ERR(GENERIC); + map_errno_to_save_resp(ret, &resp); + return KEYMAP_RESPONSE(save_changes, resp); } raise_zmk_studio_rpc_notification((struct zmk_studio_rpc_notification){ .notification = KEYMAP_NOTIFICATION(unsaved_changes_status_changed, false)}); - return KEYMAP_RESPONSE(save_changes, true); + return KEYMAP_RESPONSE(save_changes, resp); } zmk_studio_Response discard_changes(const zmk_studio_Request *req) { diff --git a/app/west.yml b/app/west.yml index 5737bd004b1..e6c9758c685 100644 --- a/app/west.yml +++ b/app/west.yml @@ -34,7 +34,7 @@ manifest: path: modules/lib/nanopb remote: zephyrproject-rtos - name: zmk-studio-messages - revision: a79267a9661241a6603b6da3d2b3f71e8023a9d9 + revision: 6cb4c283e76209d59c45fbcb218800cd19e9339d path: modules/msgs/zmk-studio-messages remote: zmkfirmware self: