From cac8cb392d7537ac2118da7a141128e8d6232887 Mon Sep 17 00:00:00 2001 From: ReFil <31960031+ReFil@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:22:33 +0000 Subject: [PATCH] Add metadata to mouse behavior --- app/src/behaviors/behavior_mouse_key_press.c | 49 +++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/app/src/behaviors/behavior_mouse_key_press.c b/app/src/behaviors/behavior_mouse_key_press.c index 66b54fce05b..1ab0a337a81 100644 --- a/app/src/behaviors/behavior_mouse_key_press.c +++ b/app/src/behaviors/behavior_mouse_key_press.c @@ -19,6 +19,48 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) +#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA) + +static const struct behavior_parameter_value_metadata param_values[] = { + { + .value = BIT(0), + .display_name = "Left click", + .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, + }, + { + .value = BIT(1), + .display_name = "Right click", + .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, + }, + { + .value = BIT(2), + .display_name = "Middle click", + .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, + }, + { + .value = BIT(3), + .display_name = "MB4 click", + .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, + }, + { + .value = BIT(4), + .display_name = "MB5 click", + .type = BEHAVIOR_PARAMETER_VALUE_TYPE_VALUE, + }, +}; + +static const struct behavior_parameter_metadata_set param_metadata_set[] = {{ + .param1_values = param_values, + .param1_values_len = ARRAY_SIZE(param_values), +}}; + +static const struct behavior_parameter_metadata metadata = { + .sets_len = ARRAY_SIZE(param_metadata_set), + .sets = param_metadata_set, +}; + +#endif + static int behavior_mouse_key_press_init(const struct device *dev) { return 0; }; static void process_key_state(const struct device *dev, int32_t val, bool pressed) { @@ -49,7 +91,12 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, } static const struct behavior_driver_api behavior_mouse_key_press_driver_api = { - .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; + .binding_pressed = on_keymap_binding_pressed, + .binding_released = on_keymap_binding_released, +#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA) + .parameter_metadata = &metadata, +#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA) +}; #define MKP_INST(n) \ BEHAVIOR_DT_INST_DEFINE(n, behavior_mouse_key_press_init, NULL, NULL, NULL, POST_KERNEL, \