forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mouse): Add mouse move and scroll support [WIP]
Co-authored-by: Alexander Krikun <[email protected]> Co-authored-by: Robert U <[email protected]> Co-authored-by: Shawn Meier <[email protected]>
- Loading branch information
1 parent
03bdce0
commit 0eb5091
Showing
31 changed files
with
803 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ mmv: behavior_mouse_move { | ||
compatible = "zmk,behavior-mouse-move"; | ||
label = "MOUSE_MOVE"; | ||
#binding-cells = <1>; | ||
delay-ms = <0>; | ||
time-to-max-speed-ms = <300>; | ||
acceleration-exponent = <1>; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ msc: behavior_mouse_scroll { | ||
compatible = "zmk,behavior-mouse-scroll"; | ||
label = "MOUSE_SCROLL"; | ||
#binding-cells = <1>; | ||
delay-ms = <0>; | ||
time-to-max-speed-ms = <300>; | ||
acceleration-exponent = <0>; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: Mouse move | ||
|
||
compatible: "zmk,behavior-mouse-move" | ||
|
||
include: one_param.yaml | ||
|
||
properties: | ||
delay-ms: | ||
type: int | ||
time-to-max-speed-ms: | ||
type: int | ||
acceleration-exponent: | ||
type: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: Mouse scroll | ||
|
||
compatible: "zmk,behavior-mouse-scroll" | ||
|
||
include: one_param.yaml | ||
|
||
properties: | ||
delay-ms: | ||
type: int | ||
time-to-max-speed-ms: | ||
type: int | ||
acceleration-exponent: | ||
type: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
|
||
struct zmk_mouse_move_state_changed { | ||
struct vector2d max_speed; | ||
struct mouse_config config; | ||
bool state; | ||
int64_t timestamp; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_mouse_move_state_changed); | ||
|
||
static inline struct zmk_mouse_move_state_changed_event * | ||
zmk_mouse_move_state_changed_from_encoded(uint32_t encoded, struct mouse_config config, | ||
bool pressed, int64_t timestamp) { | ||
struct vector2d max_speed = (struct vector2d){ | ||
.x = MOVE_X_DECODE(encoded), | ||
.y = MOVE_Y_DECODE(encoded), | ||
}; | ||
|
||
return new_zmk_mouse_move_state_changed((struct zmk_mouse_move_state_changed){ | ||
.max_speed = max_speed, .config = config, .state = pressed, .timestamp = timestamp}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
#include <dt-bindings/zmk/mouse.h> | ||
|
||
struct zmk_mouse_scroll_state_changed { | ||
struct vector2d max_speed; | ||
struct mouse_config config; | ||
bool state; | ||
int64_t timestamp; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_mouse_scroll_state_changed); | ||
|
||
static inline struct zmk_mouse_scroll_state_changed_event * | ||
zmk_mouse_scroll_state_changed_from_encoded(uint32_t encoded, struct mouse_config config, | ||
bool pressed, int64_t timestamp) { | ||
struct vector2d max_speed = (struct vector2d){ | ||
.x = SCRL_X_DECODE(encoded), | ||
.y = SCRL_Y_DECODE(encoded), | ||
}; | ||
|
||
return new_zmk_mouse_scroll_state_changed((struct zmk_mouse_scroll_state_changed){ | ||
.max_speed = max_speed, .config = config, .state = pressed, .timestamp = timestamp}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <dt-bindings/zmk/mouse.h> | ||
#include <zephyr/kernel.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/mouse.h> | ||
|
||
struct zmk_mouse_tick { | ||
struct vector2d max_move; | ||
struct vector2d max_scroll; | ||
struct mouse_config move_config; | ||
struct mouse_config scroll_config; | ||
int64_t *start_time; | ||
int64_t timestamp; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(zmk_mouse_tick); | ||
|
||
static inline struct zmk_mouse_tick_event *zmk_mouse_tick(struct vector2d max_move, | ||
struct vector2d max_scroll, | ||
struct mouse_config move_config, | ||
struct mouse_config scroll_config, | ||
int64_t *movement_start) { | ||
return new_zmk_mouse_tick((struct zmk_mouse_tick){ | ||
.max_move = max_move, | ||
.max_scroll = max_scroll, | ||
.move_config = move_config, | ||
.scroll_config = scroll_config, | ||
.start_time = movement_start, | ||
.timestamp = k_uptime_get(), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.