Skip to content

Commit

Permalink
Add messages to BLE queue without a waiting interval
Browse files Browse the repository at this point in the history
  • Loading branch information
krikun98 committed Jan 28, 2022
1 parent 96660dc commit 0bcd44a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 3 additions & 5 deletions app/src/hog.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,12 @@ void send_mouse_report_callback(struct k_work *work) {
K_WORK_DEFINE(hog_mouse_work, send_mouse_report_callback);

int zmk_hog_send_mouse_report(struct zmk_hid_mouse_report_body *report) {
int err = k_msgq_put(&zmk_hog_mouse_msgq, report, K_MSEC(100));
int err = k_msgq_put(&zmk_hog_mouse_msgq, report, K_NO_WAIT);
if (err) {
switch (err) {
case -EAGAIN: {
LOG_WRN("Mouse message queue full, popping first message and queueing again");
struct zmk_hid_mouse_report_body discarded_report;
k_msgq_get(&zmk_hog_mouse_msgq, &discarded_report, K_NO_WAIT);
return zmk_hog_send_mouse_report(report);
LOG_WRN("Mouse message queue full, dropping report");
return err;
}
default:
LOG_WRN("Failed to queue mouse report to send (%d)", err);
Expand Down
4 changes: 1 addition & 3 deletions app/src/mouse/key_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void mouse_timer_cb(struct k_timer *dummy) {
k_work_submit_to_queue(zmk_mouse_work_q(), &mouse_tick);
}

K_TIMER_DEFINE(mouse_timer, mouse_timer_cb, mouse_timer_cb);
K_TIMER_DEFINE(mouse_timer, mouse_timer_cb, NULL);

static int mouse_timer_ref_count = 0;

Expand All @@ -50,8 +50,6 @@ void mouse_timer_ref() {
k_timer_start(&mouse_timer, K_NO_WAIT, K_MSEC(CONFIG_ZMK_MOUSE_TICK_DURATION));
}
mouse_timer_ref_count += 1;
// trigger the first mouse tick event immediately
mouse_tick_timer_handler(NULL);
}

void mouse_timer_unref() {
Expand Down
1 change: 1 addition & 0 deletions app/src/mouse/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <kernel.h>
#include <zmk/mouse.h>

#if IS_ENABLED(CONFIG_ZMK_MOUSE_WORK_QUEUE_DEDICATED)

Expand Down

0 comments on commit 0bcd44a

Please sign in to comment.