From a164626d9ed2cfe4da79415f03b7b5f9c1cc86d6 Mon Sep 17 00:00:00 2001 From: Bryan Forbes Date: Fri, 8 Dec 2023 10:11:27 -0600 Subject: [PATCH] Update mouse keys for label removal --- app/dts/behaviors/mouse_move.dtsi | 3 +-- app/dts/behaviors/mouse_scroll.dtsi | 3 +-- app/src/behaviors/behavior_mouse_move.c | 22 +++++++++++----------- app/src/behaviors/behavior_mouse_scroll.c | 22 +++++++++++----------- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/dts/behaviors/mouse_move.dtsi b/app/dts/behaviors/mouse_move.dtsi index 2e165f3a6e43..c1037bce15c9 100644 --- a/app/dts/behaviors/mouse_move.dtsi +++ b/app/dts/behaviors/mouse_move.dtsi @@ -1,8 +1,7 @@ / { behaviors { - /omit-if-no-ref/ mmv: behavior_mouse_move { + /omit-if-no-ref/ mmv: mouse_move { compatible = "zmk,behavior-mouse-move"; - label = "MOUSE_MOVE"; #binding-cells = <1>; delay-ms = <0>; time-to-max-speed-ms = <300>; diff --git a/app/dts/behaviors/mouse_scroll.dtsi b/app/dts/behaviors/mouse_scroll.dtsi index f2cb86f6d882..2f1af2f1ee61 100644 --- a/app/dts/behaviors/mouse_scroll.dtsi +++ b/app/dts/behaviors/mouse_scroll.dtsi @@ -1,8 +1,7 @@ / { behaviors { - /omit-if-no-ref/ msc: behavior_mouse_scroll { + /omit-if-no-ref/ msc: mouse_scroll { compatible = "zmk,behavior-mouse-scroll"; - label = "MOUSE_SCROLL"; #binding-cells = <1>; delay-ms = <0>; time-to-max-speed-ms = <300>; diff --git a/app/src/behaviors/behavior_mouse_move.c b/app/src/behaviors/behavior_mouse_move.c index 0d591f003245..28dcef7ce3ff 100644 --- a/app/src/behaviors/behavior_mouse_move.c +++ b/app/src/behaviors/behavior_mouse_move.c @@ -24,7 +24,7 @@ static int behavior_mouse_move_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); - const struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = zmk_behavior_get_binding(binding->behavior_dev); const struct mouse_config *config = dev->config; return ZMK_EVENT_RAISE( zmk_mouse_move_state_changed_from_encoded(binding->param1, *config, true, event.timestamp)); @@ -33,7 +33,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); - const struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = zmk_behavior_get_binding(binding->behavior_dev); const struct mouse_config *config = dev->config; return ZMK_EVENT_RAISE(zmk_mouse_move_state_changed_from_encoded(binding->param1, *config, false, event.timestamp)); @@ -42,15 +42,15 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, static const struct behavior_driver_api behavior_mouse_move_driver_api = { .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; -#define KP_INST(n) \ - static struct mouse_config behavior_mouse_move_config_##n = { \ - .delay_ms = DT_INST_PROP(n, delay_ms), \ - .time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \ - .acceleration_exponent = DT_INST_PROP(n, acceleration_exponent), \ - }; \ - DEVICE_DT_INST_DEFINE(n, behavior_mouse_move_init, NULL, NULL, \ - &behavior_mouse_move_config_##n, APPLICATION, \ - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_move_driver_api); +#define KP_INST(n) \ + static struct mouse_config behavior_mouse_move_config_##n = { \ + .delay_ms = DT_INST_PROP(n, delay_ms), \ + .time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \ + .acceleration_exponent = DT_INST_PROP(n, acceleration_exponent), \ + }; \ + BEHAVIOR_DT_INST_DEFINE(n, behavior_mouse_move_init, NULL, NULL, \ + &behavior_mouse_move_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_move_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_mouse_scroll.c b/app/src/behaviors/behavior_mouse_scroll.c index d71671724d0b..d595608ceed2 100644 --- a/app/src/behaviors/behavior_mouse_scroll.c +++ b/app/src/behaviors/behavior_mouse_scroll.c @@ -25,7 +25,7 @@ static int behavior_mouse_scroll_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); - const struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = zmk_behavior_get_binding(binding->behavior_dev); const struct mouse_config *config = dev->config; return ZMK_EVENT_RAISE(zmk_mouse_scroll_state_changed_from_encoded(binding->param1, *config, true, event.timestamp)); @@ -34,7 +34,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); - const struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = zmk_behavior_get_binding(binding->behavior_dev); const struct mouse_config *config = dev->config; return ZMK_EVENT_RAISE(zmk_mouse_scroll_state_changed_from_encoded(binding->param1, *config, false, event.timestamp)); @@ -43,15 +43,15 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, static const struct behavior_driver_api behavior_mouse_scroll_driver_api = { .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; -#define KP_INST(n) \ - static struct mouse_config behavior_mouse_scroll_config_##n = { \ - .delay_ms = DT_INST_PROP(n, delay_ms), \ - .time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \ - .acceleration_exponent = DT_INST_PROP(n, acceleration_exponent), \ - }; \ - DEVICE_DT_INST_DEFINE(n, behavior_mouse_scroll_init, NULL, NULL, \ - &behavior_mouse_scroll_config_##n, APPLICATION, \ - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_scroll_driver_api); +#define KP_INST(n) \ + static struct mouse_config behavior_mouse_scroll_config_##n = { \ + .delay_ms = DT_INST_PROP(n, delay_ms), \ + .time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \ + .acceleration_exponent = DT_INST_PROP(n, acceleration_exponent), \ + }; \ + BEHAVIOR_DT_INST_DEFINE(n, behavior_mouse_scroll_init, NULL, NULL, \ + &behavior_mouse_scroll_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_scroll_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST)