Skip to content

Commit

Permalink
fix(mouse): Fix for Zephyr 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes committed Feb 20, 2024
1 parent bd7b361 commit fbaeb90
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
8 changes: 4 additions & 4 deletions app/include/zmk/events/mouse_move_state_changed.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ 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});
}
9 changes: 5 additions & 4 deletions app/include/zmk/events/mouse_scroll_state_changed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
15 changes: 0 additions & 15 deletions app/include/zmk/events/mouse_tick.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}
10 changes: 5 additions & 5 deletions app/src/behaviors/behavior_mouse_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ 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 = device_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,
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 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 = {
Expand All @@ -49,7 +49,7 @@ static const struct behavior_driver_api behavior_mouse_move_driver_api = {
.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, \
&behavior_mouse_move_config_##n, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_move_driver_api);

DT_INST_FOREACH_STATUS_OKAY(KP_INST)
Expand Down
10 changes: 5 additions & 5 deletions app/src/behaviors/behavior_mouse_scroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ 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 = device_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,
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 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 = {
Expand All @@ -50,7 +50,7 @@ static const struct behavior_driver_api behavior_mouse_scroll_driver_api = {
.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, \
&behavior_mouse_scroll_config_##n, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_scroll_driver_api);

DT_INST_FOREACH_STATUS_OKAY(KP_INST)
Expand Down
8 changes: 6 additions & 2 deletions app/src/mouse/key_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit fbaeb90

Please sign in to comment.