Skip to content

Commit

Permalink
Update mouse keys for label removal
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes committed Dec 8, 2023
1 parent af27c4b commit a164626
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
3 changes: 1 addition & 2 deletions app/dts/behaviors/mouse_move.dtsi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/ {
behaviors {
/omit-if-no-ref/ mmv: behavior_mouse_move {
/omit-if-no-ref/ mmv: mouse_move {
compatible = "zmk,behavior-mouse-move";
label = "MOUSE_MOVE";
#binding-cells = <1>;
delay-ms = <0>;
time-to-max-speed-ms = <300>;
Expand Down
3 changes: 1 addition & 2 deletions app/dts/behaviors/mouse_scroll.dtsi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/ {
behaviors {
/omit-if-no-ref/ msc: behavior_mouse_scroll {
/omit-if-no-ref/ msc: mouse_scroll {
compatible = "zmk,behavior-mouse-scroll";
label = "MOUSE_SCROLL";
#binding-cells = <1>;
delay-ms = <0>;
time-to-max-speed-ms = <300>;
Expand Down
22 changes: 11 additions & 11 deletions app/src/behaviors/behavior_mouse_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static int behavior_mouse_move_init(const struct device *dev) { return 0; };
static int on_keymap_binding_pressed(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 device *dev = zmk_behavior_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));
Expand All @@ -33,7 +33,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
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 device *dev = zmk_behavior_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));
Expand All @@ -42,15 +42,15 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding,
static const struct behavior_driver_api behavior_mouse_move_driver_api = {
.binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released};

#define KP_INST(n) \
static struct mouse_config behavior_mouse_move_config_##n = { \
.delay_ms = DT_INST_PROP(n, delay_ms), \
.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, NULL, NULL, \
&behavior_mouse_move_config_##n, APPLICATION, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_move_driver_api);
#define KP_INST(n) \
static struct mouse_config behavior_mouse_move_config_##n = { \
.delay_ms = DT_INST_PROP(n, delay_ms), \
.time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \
.acceleration_exponent = DT_INST_PROP(n, acceleration_exponent), \
}; \
BEHAVIOR_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);

DT_INST_FOREACH_STATUS_OKAY(KP_INST)

Expand Down
22 changes: 11 additions & 11 deletions app/src/behaviors/behavior_mouse_scroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int behavior_mouse_scroll_init(const struct device *dev) { return 0; };
static int on_keymap_binding_pressed(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 device *dev = zmk_behavior_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));
Expand All @@ -34,7 +34,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
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 device *dev = zmk_behavior_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));
Expand All @@ -43,15 +43,15 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding,
static const struct behavior_driver_api behavior_mouse_scroll_driver_api = {
.binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released};

#define KP_INST(n) \
static struct mouse_config behavior_mouse_scroll_config_##n = { \
.delay_ms = DT_INST_PROP(n, delay_ms), \
.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, NULL, NULL, \
&behavior_mouse_scroll_config_##n, APPLICATION, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mouse_scroll_driver_api);
#define KP_INST(n) \
static struct mouse_config behavior_mouse_scroll_config_##n = { \
.delay_ms = DT_INST_PROP(n, delay_ms), \
.time_to_max_speed_ms = DT_INST_PROP(n, time_to_max_speed_ms), \
.acceleration_exponent = DT_INST_PROP(n, acceleration_exponent), \
}; \
BEHAVIOR_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);

DT_INST_FOREACH_STATUS_OKAY(KP_INST)

Expand Down

0 comments on commit a164626

Please sign in to comment.