From 8a44ef109ae301ce084b32dd5fe25200da9e402f Mon Sep 17 00:00:00 2001 From: snoyer Date: Tue, 31 Mar 2026 08:52:27 +0400 Subject: [PATCH] feat(behaviors): add `&out OUT_NONE` (#3235) Allow manually setting the preferred transport to `ZMK_TRANSPORT_NONE` with the `&out` behavior to prevent the keyboard from sending any output. --- app/include/dt-bindings/zmk/outputs.h | 3 ++- app/src/behaviors/behavior_outputs.c | 7 +++++++ docs/docs/keymaps/behaviors/outputs.md | 11 ++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/include/dt-bindings/zmk/outputs.h b/app/include/dt-bindings/zmk/outputs.h index f24380f7e..1bb8d740f 100644 --- a/app/include/dt-bindings/zmk/outputs.h +++ b/app/include/dt-bindings/zmk/outputs.h @@ -6,4 +6,5 @@ #define OUT_TOG 0 #define OUT_USB 1 -#define OUT_BLE 2 \ No newline at end of file +#define OUT_BLE 2 +#define OUT_NONE 3 \ No newline at end of file diff --git a/app/src/behaviors/behavior_outputs.c b/app/src/behaviors/behavior_outputs.c index a8d1b36c6..e6b51d0c7 100644 --- a/app/src/behaviors/behavior_outputs.c +++ b/app/src/behaviors/behavior_outputs.c @@ -42,6 +42,11 @@ static const struct behavior_parameter_value_metadata std_values[] = { .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, }, #endif // IS_ENABLED(CONFIG_ZMK_BLE) + { + .value = OUT_NONE, + .display_name = "No Output", + .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, + }, }; static const struct behavior_parameter_metadata_set std_set = { @@ -65,6 +70,8 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, return zmk_endpoint_set_preferred_transport(ZMK_TRANSPORT_USB); case OUT_BLE: return zmk_endpoint_set_preferred_transport(ZMK_TRANSPORT_BLE); + case OUT_NONE: + return zmk_endpoint_set_preferred_transport(ZMK_TRANSPORT_NONE); default: LOG_ERR("Unknown output command: %d", binding->param1); } diff --git a/docs/docs/keymaps/behaviors/outputs.md b/docs/docs/keymaps/behaviors/outputs.md index 98d2186ee..77090a172 100644 --- a/docs/docs/keymaps/behaviors/outputs.md +++ b/docs/docs/keymaps/behaviors/outputs.md @@ -29,11 +29,12 @@ header, which is added at the top of the keymap file: This allows you to reference the actions defined in this header: -| Define | Action | -| --------- | ----------------------------------------------- | -| `OUT_USB` | Prefer sending to USB | -| `OUT_BLE` | Prefer sending to the current bluetooth profile | -| `OUT_TOG` | Toggle between USB and BLE | +| Define | Action | +| ---------- | ----------------------------------------------- | +| `OUT_USB` | Prefer sending to USB | +| `OUT_BLE` | Prefer sending to the current bluetooth profile | +| `OUT_TOG` | Toggle between USB and BLE | +| `OUT_NONE` | Prevent from sending any output | ## Output Selection Behavior