Added dedicated mouse work queue option
This commit is contained in:
parent
35eef63fa9
commit
30581f7207
7 changed files with 90 additions and 2 deletions
|
@ -28,6 +28,7 @@ target_sources(app PRIVATE src/kscan.c)
|
||||||
target_sources(app PRIVATE src/matrix_transform.c)
|
target_sources(app PRIVATE src/matrix_transform.c)
|
||||||
target_sources(app PRIVATE src/hid.c)
|
target_sources(app PRIVATE src/hid.c)
|
||||||
target_sources(app PRIVATE src/mouse/key_listener.c)
|
target_sources(app PRIVATE src/mouse/key_listener.c)
|
||||||
|
target_sources(app PRIVATE src/mouse/main.c)
|
||||||
target_sources(app PRIVATE src/mouse/tick_listener.c)
|
target_sources(app PRIVATE src/mouse/tick_listener.c)
|
||||||
target_sources(app PRIVATE src/sensors.c)
|
target_sources(app PRIVATE src/sensors.c)
|
||||||
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c)
|
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c)
|
||||||
|
|
|
@ -326,6 +326,13 @@ endif
|
||||||
#Display/LED Options
|
#Display/LED Options
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
menu "Mouse Options"
|
||||||
|
|
||||||
|
rsource "src/mouse/Kconfig"
|
||||||
|
|
||||||
|
#Mouse Options
|
||||||
|
endmenu
|
||||||
|
|
||||||
menu "Power Management"
|
menu "Power Management"
|
||||||
|
|
||||||
config ZMK_IDLE_TIMEOUT
|
config ZMK_IDLE_TIMEOUT
|
||||||
|
|
|
@ -25,3 +25,6 @@ struct vector2d {
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct k_work_q *zmk_mouse_work_q();
|
||||||
|
int zmk_mouse_init();
|
|
@ -29,4 +29,8 @@ void main(void) {
|
||||||
#ifdef CONFIG_ZMK_DISPLAY
|
#ifdef CONFIG_ZMK_DISPLAY
|
||||||
zmk_display_init();
|
zmk_display_init();
|
||||||
#endif /* CONFIG_ZMK_DISPLAY */
|
#endif /* CONFIG_ZMK_DISPLAY */
|
||||||
|
|
||||||
|
#ifdef CONFIG_ZMK_MOUSE
|
||||||
|
zmk_mouse_init();
|
||||||
|
#endif /* CONFIG_ZMK_MOUSE */
|
||||||
}
|
}
|
||||||
|
|
34
app/src/mouse/Kconfig
Normal file
34
app/src/mouse/Kconfig
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright (c) 2021 The ZMK Contributors
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
menuconfig ZMK_MOUSE
|
||||||
|
bool "Enable ZMK mouse emulation"
|
||||||
|
default n
|
||||||
|
|
||||||
|
if ZMK_MOUSE
|
||||||
|
|
||||||
|
choice ZMK_MOUSE_WORK_QUEUE
|
||||||
|
prompt "Work queue selection for mouse events"
|
||||||
|
default ZMK_MOUSE_WORK_QUEUE_DEDICATED
|
||||||
|
|
||||||
|
config ZMK_MOUSE_WORK_QUEUE_SYSTEM
|
||||||
|
bool "Use default system work queue for mouse events"
|
||||||
|
|
||||||
|
config ZMK_MOUSE_WORK_QUEUE_DEDICATED
|
||||||
|
bool "Use dedicated work queue for mouse events"
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
if ZMK_MOUSE_WORK_QUEUE_DEDICATED
|
||||||
|
|
||||||
|
config ZMK_MOUSE_DEDICATED_THREAD_STACK_SIZE
|
||||||
|
int "Stack size for dedicated mouse thread/queue"
|
||||||
|
default 2048
|
||||||
|
|
||||||
|
config ZMK_MOUSE_DEDICATED_THREAD_PRIORITY
|
||||||
|
int "Thread priority for dedicated mouse thread/queue"
|
||||||
|
default 5
|
||||||
|
|
||||||
|
endif # ZMK_MOUSE_WORK_QUEUE_DEDICATED
|
||||||
|
|
||||||
|
endif
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The ZMK Contributors
|
* Copyright (c) 2021 The ZMK Contributors
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,9 @@ static void mouse_tick_timer_handler(struct k_work *work) {
|
||||||
|
|
||||||
K_WORK_DEFINE(mouse_tick, &mouse_tick_timer_handler);
|
K_WORK_DEFINE(mouse_tick, &mouse_tick_timer_handler);
|
||||||
|
|
||||||
void mouse_timer_cb(struct k_timer *dummy) { k_work_submit(&mouse_tick); }
|
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, mouse_timer_cb);
|
||||||
|
|
||||||
|
|
37
app/src/mouse/main.c
Normal file
37
app/src/mouse/main.c
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 The ZMK Contributors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <kernel.h>
|
||||||
|
#include <init.h>
|
||||||
|
#include <device.h>
|
||||||
|
#include <devicetree.h>
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_ZMK_MOUSE_WORK_QUEUE_DEDICATED)
|
||||||
|
|
||||||
|
K_THREAD_STACK_DEFINE(mouse_work_stack_area, CONFIG_ZMK_MOUSE_DEDICATED_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
|
static struct k_work_q mouse_work_q;
|
||||||
|
|
||||||
|
struct k_work_q *zmk_mouse_work_q() {
|
||||||
|
return &mouse_work_q;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
struct k_work_q *zmk_mouse_work_q() {
|
||||||
|
return &k_sys_work_q;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int zmk_mouse_init() {
|
||||||
|
#if IS_ENABLED(CONFIG_ZMK_MOUSE_WORK_QUEUE_DEDICATED)
|
||||||
|
k_work_q_start(&mouse_work_q, mouse_work_stack_area,
|
||||||
|
K_THREAD_STACK_SIZEOF(mouse_work_stack_area),
|
||||||
|
CONFIG_ZMK_MOUSE_DEDICATED_THREAD_PRIORITY);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue