refactor(mouse): Remove mouse work queue, Kconfig
* Remove now-unused mouse work queue and related mouse main file. * Move ticks config into a DTS property on the two axis input behavior.
This commit is contained in:
parent
e9513c51d3
commit
4d37113f3f
7 changed files with 16 additions and 79 deletions
|
@ -27,7 +27,6 @@ target_sources(app PRIVATE src/behavior.c)
|
|||
target_sources_ifdef(CONFIG_ZMK_KSCAN_SIDEBAND_BEHAVIORS app PRIVATE src/kscan_sideband_behaviors.c)
|
||||
target_sources(app PRIVATE src/matrix_transform.c)
|
||||
target_sources(app PRIVATE src/physical_layouts.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse/main.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse/input_config.c)
|
||||
target_sources(app PRIVATE src/sensors.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c)
|
||||
|
@ -45,7 +44,6 @@ target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext
|
|||
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_SOFT_OFF app PRIVATE src/behaviors/behavior_soft_off.c)
|
||||
if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
||||
target_sources(app PRIVATE src/hid.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse/main.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse/hid_input_listener.c)
|
||||
target_sources(app PRIVATE src/behaviors/behavior_key_press.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_KEY_TOGGLE app PRIVATE src/behaviors/behavior_key_toggle.c)
|
||||
|
|
|
@ -11,6 +11,10 @@ properties:
|
|||
y-input-code:
|
||||
type: int
|
||||
required: true
|
||||
trigger-period-ms:
|
||||
type: int
|
||||
default: 16
|
||||
description: The time (in ms) between generated inputs when an input has non-zero speed.
|
||||
delay-ms:
|
||||
type: int
|
||||
time-to-max-speed-ms:
|
||||
|
|
|
@ -10,5 +10,3 @@
|
|||
|
||||
typedef uint8_t zmk_mouse_button_flags_t;
|
||||
typedef uint16_t zmk_mouse_button_t;
|
||||
|
||||
int zmk_mouse_init(void);
|
||||
|
|
|
@ -43,12 +43,13 @@ struct behavior_input_two_axis_data {
|
|||
struct behavior_input_two_axis_config {
|
||||
int16_t x_code;
|
||||
int16_t y_code;
|
||||
int delay_ms;
|
||||
int time_to_max_speed_ms;
|
||||
uint16_t delay_ms;
|
||||
uint16_t time_to_max_speed_ms;
|
||||
uint8_t trigger_period_ms;
|
||||
// acceleration exponent 0: uniform speed
|
||||
// acceleration exponent 1: uniform acceleration
|
||||
// acceleration exponent 2: uniform jerk
|
||||
int acceleration_exponent;
|
||||
uint8_t acceleration_exponent;
|
||||
};
|
||||
|
||||
#if CONFIG_MINIMAL_LIBC
|
||||
|
@ -107,9 +108,8 @@ static float update_movement_1d(const struct behavior_input_two_axis_config *con
|
|||
}
|
||||
|
||||
int64_t move_duration = ms_since_start(state->start_time, now, config->delay_ms);
|
||||
move =
|
||||
(move_duration > 0)
|
||||
? (speed(config, state->speed, move_duration) * CONFIG_ZMK_MOUSE_TICK_DURATION / 1000)
|
||||
move = (move_duration > 0)
|
||||
? (speed(config, state->speed, move_duration) * config->trigger_period_ms / 1000)
|
||||
: 0;
|
||||
|
||||
track_remainder(&(move), &(state->remainder));
|
||||
|
@ -165,7 +165,7 @@ static void tick_work_cb(struct k_work *work) {
|
|||
}
|
||||
|
||||
if (should_be_working(data)) {
|
||||
k_work_schedule(&data->tick_work, K_MSEC(CONFIG_ZMK_MOUSE_TICK_DURATION));
|
||||
k_work_schedule(&data->tick_work, K_MSEC(cfg->trigger_period_ms));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,11 +183,12 @@ static void set_start_times_for_activity(struct movement_state_2d *state) {
|
|||
|
||||
static void update_work_scheduling(const struct device *dev) {
|
||||
struct behavior_input_two_axis_data *data = dev->data;
|
||||
const struct behavior_input_two_axis_config *cfg = dev->config;
|
||||
|
||||
set_start_times_for_activity(&data->state);
|
||||
|
||||
if (should_be_working(data)) {
|
||||
k_work_schedule(&data->tick_work, K_MSEC(CONFIG_ZMK_MOUSE_TICK_DURATION));
|
||||
k_work_schedule(&data->tick_work, K_MSEC(cfg->trigger_period_ms));
|
||||
} else {
|
||||
k_work_cancel_delayable(&data->tick_work);
|
||||
}
|
||||
|
@ -260,6 +261,7 @@ static const struct behavior_driver_api behavior_input_two_axis_driver_api = {
|
|||
static struct behavior_input_two_axis_config behavior_input_two_axis_config_##n = { \
|
||||
.x_code = DT_INST_PROP(n, x_input_code), \
|
||||
.y_code = DT_INST_PROP(n, y_input_code), \
|
||||
.trigger_period_ms = DT_INST_PROP(n, trigger_period_ms), \
|
||||
.delay_ms = DT_INST_PROP_OR(n, delay_ms, 0), \
|
||||
.time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \
|
||||
.acceleration_exponent = DT_INST_PROP_OR(n, acceleration_exponent, 1), \
|
||||
|
|
|
@ -30,8 +30,5 @@ int main(void) {
|
|||
zmk_display_init();
|
||||
#endif /* CONFIG_ZMK_DISPLAY */
|
||||
|
||||
#ifdef CONFIG_ZMK_MOUSE
|
||||
zmk_mouse_init();
|
||||
#endif /* CONFIG_ZMK_MOUSE */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,40 +1,8 @@
|
|||
# Copyright (c) 2023 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
menuconfig ZMK_MOUSE
|
||||
config ZMK_MOUSE
|
||||
bool "Mouse Emulation"
|
||||
select INPUT
|
||||
select INPUT_THREAD_PRIORITY_OVERRIDE
|
||||
|
||||
if ZMK_MOUSE
|
||||
|
||||
config ZMK_MOUSE_TICK_DURATION
|
||||
int "Mouse tick duration in ms"
|
||||
default 16
|
||||
|
||||
|
||||
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 3
|
||||
|
||||
endif # ZMK_MOUSE_WORK_QUEUE_DEDICATED
|
||||
|
||||
endif
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zmk/mouse.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;
|
||||
#endif
|
||||
|
||||
struct k_work_q *zmk_mouse_work_q() {
|
||||
#if IS_ENABLED(CONFIG_ZMK_MOUSE_WORK_QUEUE_DEDICATED)
|
||||
return &mouse_work_q;
|
||||
#else
|
||||
return &k_sys_work_q;
|
||||
#endif
|
||||
}
|
||||
|
||||
int zmk_mouse_init(void) {
|
||||
#if IS_ENABLED(CONFIG_ZMK_MOUSE_WORK_QUEUE_DEDICATED)
|
||||
k_work_queue_start(&mouse_work_q, mouse_work_stack_area,
|
||||
K_THREAD_STACK_SIZEOF(mouse_work_stack_area),
|
||||
CONFIG_ZMK_MOUSE_DEDICATED_THREAD_PRIORITY, NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue