diff --git a/app/include/zmk/events/mouse_move_state_changed.h b/app/include/zmk/events/mouse_move_state_changed.h index d1ebad87e0e..3e8cced0532 100644 --- a/app/include/zmk/events/mouse_move_state_changed.h +++ b/app/include/zmk/events/mouse_move_state_changed.h @@ -20,14 +20,13 @@ struct zmk_mouse_move_state_changed { ZMK_EVENT_DECLARE(zmk_mouse_move_state_changed); -static inline struct zmk_mouse_move_state_changed_event * -zmk_mouse_move_state_changed_from_encoded(uint32_t encoded, struct mouse_config config, - bool pressed, int64_t timestamp) { +static inline int raise_zmk_mouse_move_state_changed_from_encoded(uint32_t encoded, + struct mouse_config config, + bool pressed, int64_t timestamp) { struct vector2d max_speed = (struct vector2d){ .x = MOVE_X_DECODE(encoded), .y = MOVE_Y_DECODE(encoded), }; - - return new_zmk_mouse_move_state_changed((struct zmk_mouse_move_state_changed){ + return raise_zmk_mouse_move_state_changed((struct zmk_mouse_move_state_changed){ .max_speed = max_speed, .config = config, .state = pressed, .timestamp = timestamp}); } diff --git a/app/include/zmk/events/mouse_scroll_state_changed.h b/app/include/zmk/events/mouse_scroll_state_changed.h index bf03308f1d5..456ea6d3281 100644 --- a/app/include/zmk/events/mouse_scroll_state_changed.h +++ b/app/include/zmk/events/mouse_scroll_state_changed.h @@ -21,14 +21,15 @@ struct zmk_mouse_scroll_state_changed { ZMK_EVENT_DECLARE(zmk_mouse_scroll_state_changed); -static inline struct zmk_mouse_scroll_state_changed_event * -zmk_mouse_scroll_state_changed_from_encoded(uint32_t encoded, struct mouse_config config, - bool pressed, int64_t timestamp) { +static inline int raise_zmk_mouse_scroll_state_changed_from_encoded(uint32_t encoded, + struct mouse_config config, + bool pressed, + int64_t timestamp) { struct vector2d max_speed = (struct vector2d){ .x = SCRL_X_DECODE(encoded), .y = SCRL_Y_DECODE(encoded), }; - return new_zmk_mouse_scroll_state_changed((struct zmk_mouse_scroll_state_changed){ + return raise_zmk_mouse_scroll_state_changed((struct zmk_mouse_scroll_state_changed){ .max_speed = max_speed, .config = config, .state = pressed, .timestamp = timestamp}); } diff --git a/app/include/zmk/events/mouse_tick.h b/app/include/zmk/events/mouse_tick.h index 75a041e96b4..5f606c4eecb 100644 --- a/app/include/zmk/events/mouse_tick.h +++ b/app/include/zmk/events/mouse_tick.h @@ -22,18 +22,3 @@ struct zmk_mouse_tick { }; ZMK_EVENT_DECLARE(zmk_mouse_tick); - -static inline struct zmk_mouse_tick_event *zmk_mouse_tick(struct vector2d max_move, - struct vector2d max_scroll, - struct mouse_config move_config, - struct mouse_config scroll_config, - struct mouse_times movement_start) { - return new_zmk_mouse_tick((struct zmk_mouse_tick){ - .max_move = max_move, - .max_scroll = max_scroll, - .move_config = move_config, - .scroll_config = scroll_config, - .start_times = movement_start, - .timestamp = k_uptime_get(), - }); -} diff --git a/app/src/behaviors/behavior_mouse_move.c b/app/src/behaviors/behavior_mouse_move.c index 2822b9c054f..4ebc5763953 100644 --- a/app/src/behaviors/behavior_mouse_move.c +++ b/app/src/behaviors/behavior_mouse_move.c @@ -26,8 +26,8 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); 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)); + return raise_zmk_mouse_move_state_changed_from_encoded(binding->param1, *config, true, + event.timestamp); } static int on_keymap_binding_released(struct zmk_behavior_binding *binding, @@ -35,8 +35,8 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); 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)); + return raise_zmk_mouse_move_state_changed_from_encoded(binding->param1, *config, false, + event.timestamp); } static const struct behavior_driver_api behavior_mouse_move_driver_api = { @@ -49,8 +49,8 @@ static const struct behavior_driver_api behavior_mouse_move_driver_api = { .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); + &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 743afa8d7b1..18cffc80817 100644 --- a/app/src/behaviors/behavior_mouse_scroll.c +++ b/app/src/behaviors/behavior_mouse_scroll.c @@ -27,8 +27,8 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); 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)); + return raise_zmk_mouse_scroll_state_changed_from_encoded(binding->param1, *config, true, + event.timestamp); } static int on_keymap_binding_released(struct zmk_behavior_binding *binding, @@ -36,8 +36,8 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, LOG_DBG("position %d keycode 0x%02X", event.position, binding->param1); 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)); + return raise_zmk_mouse_scroll_state_changed_from_encoded(binding->param1, *config, false, + event.timestamp); } static const struct behavior_driver_api behavior_mouse_scroll_driver_api = { @@ -49,9 +49,9 @@ static const struct behavior_driver_api behavior_mouse_scroll_driver_api = { .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); + 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) diff --git a/app/src/mouse/key_listener.c b/app/src/mouse/key_listener.c index bd06efebd9f..011d5453a76 100644 --- a/app/src/mouse/key_listener.c +++ b/app/src/mouse/key_listener.c @@ -50,8 +50,12 @@ static void mouse_tick_timer_handler(struct k_work *work) { zmk_hid_mouse_movement_set(0, 0); zmk_hid_mouse_scroll_set(0, 0); LOG_DBG("Raising mouse tick event"); - ZMK_EVENT_RAISE( - zmk_mouse_tick(move_speed, scroll_speed, move_config, scroll_config, start_times)); + raise_zmk_mouse_tick((struct zmk_mouse_tick){.max_move = move_speed, + .max_scroll = scroll_speed, + .move_config = move_config, + .scroll_config = scroll_config, + .start_times = start_times, + .timestamp = k_uptime_get()}); zmk_endpoints_send_mouse_report(); }