From 39a14154a98479b864fba7735717e5147f6c0c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Cazenave?= <70967142+Nuclear-Squid@users.noreply.github.com> Date: Tue, 17 Feb 2026 03:26:40 +0000 Subject: [PATCH] docs: Fix C code examples in new behavior documentation (#3242) --- docs/docs/development/new-behavior.mdx | 49 +++++++++++++------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/docs/docs/development/new-behavior.mdx b/docs/docs/development/new-behavior.mdx index 2aca1ee90..9eb66581d 100644 --- a/docs/docs/development/new-behavior.mdx +++ b/docs/docs/development/new-behavior.mdx @@ -202,7 +202,7 @@ values={[ * SPDX-License-Identifier: MIT */ -#define DT_DRV_COMPAT zmk_ +#define DT_DRV_COMPAT zmk_behavior_ // Dependencies #include @@ -247,7 +247,7 @@ static int on__binding_released(struct zmk_behavior_binding *b // API struct static const struct behavior_driver_api _driver_api = { .binding_pressed = on__binding_pressed, - .binding_released = on__binding_pressed, + .binding_released = on__binding_released, }; BEHAVIOR_DT_INST_DEFINE(0, // Instance Number (0) @@ -273,7 +273,7 @@ BEHAVIOR_DT_INST_DEFINE(0, // Ins * SPDX-License-Identifier: MIT */ -#define DT_DRV_COMPAT zmk_ +#define DT_DRV_COMPAT zmk_behavior_ // Dependencies #include @@ -318,29 +318,30 @@ static int on__binding_released(struct zmk_behavior_binding *b // API struct static const struct behavior_driver_api _driver_api = { .binding_pressed = on__binding_pressed, - .binding_released = on__binding_pressed, + .binding_released = on__binding_released, }; -#define _INST(n) \ - static struct behavior__data_##n { \ - .data_param1 = foo1; \ - .data_param2 = foo2; \ - .data_param3 = foo3; \ - }; \ - \ - static struct behavior__config_##n { \ - .config_param1 = bar1; \ - .config_param2 = bar2; \ - .config_param3 = bar3; \ - }; \ - \ - BEHAVIOR_DT_INST_DEFINE(n, \ // Instance Number (Automatically populated by macro) - _init, \ // Initialization Function - NULL, \ // Power Management Device Pointer - &_data_##n, \ // Behavior Data Pointer - &_config_##n, \ // Behavior Configuration Pointer - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT \ // Initialization Level, Device Priority - &_driver_api); // API struct +#define _INST(n) \ + static struct behavior__data_##n { \ + .data_param1 = foo1, \ + .data_param2 = foo2, \ + .data_param3 = foo3, \ + }; \ + \ + static struct behavior__config_##n { \ + .config_param1 = bar1, \ + .config_param2 = bar2, \ + .config_param3 = bar3, \ + }; \ + \ + BEHAVIOR_DT_INST_DEFINE(n, /* Instance Number (Automatically populated by macro) */ \ + _init, /* Initialization Function */ \ + NULL, /* Power Management Device Pointer */ \ + &_data_##n, /* Behavior Data Pointer */ \ + &_config_##n, /* Behavior Configuration Pointer */ \ + POST_KERNEL, /* Initialization Level */ \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT /* Device Priority */ \ + &_driver_api); /* API struct */ \ DT_INST_FOREACH_STATUS_OKAY(_INST)