Browse Source

ifdefs for link errors when compiling non-central, some includes, other minor hacks to compile, cleanup is needed later

xmkb
Shawn Meier 2 years ago committed by Julia Luna
parent
commit
995e286016
Signed by: xenua
GPG Key ID: 6A0C04FA9A7D7582
  1. 2
      app/include/zmk/events/mouse_button_state_changed.h
  2. 2
      app/src/behaviors/behavior_mouse_key_press.c
  3. 2
      app/src/behaviors/behavior_mouse_move.c
  4. 2
      app/src/behaviors/behavior_mouse_scroll.c
  5. 4
      app/src/mouse/key_listener.c
  6. 5
      app/src/mouse/tick_listener.c

2
app/include/zmk/events/mouse_button_state_changed.h

@ -23,5 +23,5 @@ ZMK_EVENT_DECLARE(zmk_mouse_button_state_changed); @@ -23,5 +23,5 @@ ZMK_EVENT_DECLARE(zmk_mouse_button_state_changed);
static inline struct zmk_mouse_button_state_changed_event *
zmk_mouse_button_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
return new_zmk_mouse_button_state_changed((struct zmk_mouse_button_state_changed){
.buttons = HID_USAGE_ID(encoded), .state = pressed, .timestamp = timestamp});
.buttons = ZMK_HID_USAGE_ID(encoded), .state = pressed, .timestamp = timestamp});
}

2
app/src/behaviors/behavior_mouse_key_press.c

@ -39,7 +39,7 @@ static const struct behavior_driver_api behavior_mouse_key_press_driver_api = { @@ -39,7 +39,7 @@ static const struct behavior_driver_api behavior_mouse_key_press_driver_api = {
.binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released};
#define KP_INST(n) \
DEVICE_DT_INST_DEFINE(n, behavior_mouse_key_press_init, device_pm_control_nop, NULL, NULL, \
DEVICE_DT_INST_DEFINE(n, behavior_mouse_key_press_init, NULL, NULL, NULL, \
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
&behavior_mouse_key_press_driver_api);

2
app/src/behaviors/behavior_mouse_move.c

@ -48,7 +48,7 @@ static const struct behavior_driver_api behavior_mouse_move_driver_api = { @@ -48,7 +48,7 @@ static const struct behavior_driver_api behavior_mouse_move_driver_api = {
.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, device_pm_control_nop, NULL, \
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);

2
app/src/behaviors/behavior_mouse_scroll.c

@ -49,7 +49,7 @@ static const struct behavior_driver_api behavior_mouse_scroll_driver_api = { @@ -49,7 +49,7 @@ 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), \
}; \
DEVICE_DT_INST_DEFINE(n, behavior_mouse_scroll_init, device_pm_control_nop, NULL, \
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);

4
app/src/mouse/key_listener.c

@ -45,6 +45,8 @@ void mouse_clear_cb(struct k_timer *dummy) { @@ -45,6 +45,8 @@ void mouse_clear_cb(struct k_timer *dummy) {
k_work_submit_to_queue(zmk_mouse_work_q(), &mouse_clear);
}
//TODO: There is probably a better flag to use here
#if(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
static void mouse_tick_timer_handler(struct k_work *work) {
zmk_hid_mouse_movement_set(0, 0);
zmk_hid_mouse_scroll_set(0, 0);
@ -158,3 +160,5 @@ ZMK_LISTENER(mouse_listener, mouse_listener); @@ -158,3 +160,5 @@ ZMK_LISTENER(mouse_listener, mouse_listener);
ZMK_SUBSCRIPTION(mouse_listener, zmk_mouse_button_state_changed);
ZMK_SUBSCRIPTION(mouse_listener, zmk_mouse_move_state_changed);
ZMK_SUBSCRIPTION(mouse_listener, zmk_mouse_scroll_state_changed);
#endif /* CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL */

5
app/src/mouse/tick_listener.c

@ -11,6 +11,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -11,6 +11,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/event_manager.h>
#include <zmk/events/mouse_tick.h>
#include <zmk/endpoints.h>
#include <zmk/hid.h>
#include <zmk/mouse.h>
#include <sys/util.h> // CLAMP
@ -78,6 +79,7 @@ static struct vector2d update_movement(struct vector2d *remainder, @@ -78,6 +79,7 @@ static struct vector2d update_movement(struct vector2d *remainder,
return move;
}
#if(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
static void mouse_tick_handler(const struct zmk_mouse_tick *tick) {
struct vector2d move = update_movement(&move_remainder, &(tick->move_config), tick->max_move,
tick->timestamp, tick->start_time);
@ -88,13 +90,16 @@ static void mouse_tick_handler(const struct zmk_mouse_tick *tick) { @@ -88,13 +90,16 @@ static void mouse_tick_handler(const struct zmk_mouse_tick *tick) {
zmk_hid_mouse_scroll_update((int8_t)CLAMP(scroll.x, INT8_MIN, INT8_MAX),
(int8_t)CLAMP(scroll.y, INT8_MIN, INT8_MAX));
}
#endif
int zmk_mouse_tick_listener(const zmk_event_t *eh) {
const struct zmk_mouse_tick *tick = as_zmk_mouse_tick(eh);
#if(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
if (tick) {
mouse_tick_handler(tick);
return 0;
}
#endif
return 0;
}

Loading…
Cancel
Save