forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 35
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 PS/2 mouse/trackpoint/etc support
- Loading branch information
1 parent
40adb38
commit 2794f12
Showing
11 changed files
with
2,268 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#define NRF_DEFAULT_IRQ_PRIORITY 3 |
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,15 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
/ { | ||
behaviors { | ||
mms: behavior_mouse_setting { | ||
compatible = "zmk,behavior-mouse-setting"; | ||
label = "MOUSE_SETTING"; | ||
#binding-cells = <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,6 @@ | ||
description: Mouse Setting | ||
|
||
compatible: "zmk,behavior-mouse-setting" | ||
|
||
include: one_param.yaml | ||
|
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,15 @@ | ||
description: PS2 mouse configuration | ||
|
||
compatible: "zmk,mouse-ps2" | ||
|
||
properties: | ||
ps2-device: | ||
type: phandle | ||
required: true | ||
description: | | ||
The ps2 device the mouse should use. | ||
rst-gpios: | ||
type: phandle-array | ||
required: false | ||
description: GPIO to which the RST pin of the device is connected and on which the Power-On-Reset will be performed. |
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,18 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
#pragma once | ||
|
||
#define MS_TP_SENSITIVITY_INCR 10 | ||
#define MS_TP_SENSITIVITY_DECR 11 | ||
|
||
#define MS_TP_NEG_INERTIA_INCR 12 | ||
#define MS_TP_NEG_INERTIA_DECR 13 | ||
|
||
#define MS_TP_VALUE6_INCR 14 | ||
#define MS_TP_VALUE6_DECR 15 | ||
|
||
#define MS_TP_PTS_THRESHOLD_INCR 16 | ||
#define MS_TP_PTS_THRESHOLD_DECR 17 |
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 @@ | ||
/* | ||
* Copyright (c) 2021 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
int zmk_mouse_ps2_tp_sensitivity_change(int amount); | ||
int zmk_mouse_ps2_tp_neg_inertia_change(int amount); | ||
int zmk_mouse_ps2_tp_value6_upper_plateau_speed_change(int amount); | ||
int zmk_mouse_ps2_tp_pts_threshold_change(int amount); |
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,86 @@ | ||
#define DT_DRV_COMPAT zmk_behavior_mouse_setting | ||
|
||
#include <zephyr/device.h> | ||
#include <drivers/behavior.h> | ||
#include <zephyr/logging/log.h> | ||
|
||
#include <dt-bindings/zmk/mouse_settings.h> | ||
#include <zmk/mouse_ps2.h> | ||
#include <zmk/mouse.h> | ||
|
||
#define INCREMENT_TP_SENSITIVITY 10 | ||
#define INCREMENT_TP_NEG_INERTIA 1 | ||
#define INCREMENT_TP_VALUE6 5 | ||
#define INCREMENT_TP_PTS_THRESHOLD 1 | ||
|
||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) | ||
{ | ||
switch (binding->param1) { | ||
|
||
case MS_TP_SENSITIVITY_INCR: | ||
return zmk_mouse_ps2_tp_sensitivity_change( | ||
INCREMENT_TP_SENSITIVITY | ||
); | ||
case MS_TP_SENSITIVITY_DECR: | ||
return zmk_mouse_ps2_tp_sensitivity_change( | ||
-INCREMENT_TP_SENSITIVITY | ||
); | ||
|
||
case MS_TP_NEG_INERTIA_INCR: | ||
return zmk_mouse_ps2_tp_neg_inertia_change( | ||
INCREMENT_TP_NEG_INERTIA | ||
); | ||
case MS_TP_NEG_INERTIA_DECR: | ||
return zmk_mouse_ps2_tp_neg_inertia_change( | ||
-INCREMENT_TP_NEG_INERTIA | ||
); | ||
|
||
case MS_TP_VALUE6_INCR: | ||
return zmk_mouse_ps2_tp_value6_upper_plateau_speed_change( | ||
INCREMENT_TP_VALUE6 | ||
); | ||
case MS_TP_VALUE6_DECR: | ||
return zmk_mouse_ps2_tp_value6_upper_plateau_speed_change( | ||
-INCREMENT_TP_VALUE6 | ||
); | ||
|
||
case MS_TP_PTS_THRESHOLD_INCR: | ||
return zmk_mouse_ps2_tp_pts_threshold_change( | ||
INCREMENT_TP_PTS_THRESHOLD | ||
); | ||
case MS_TP_PTS_THRESHOLD_DECR: | ||
return zmk_mouse_ps2_tp_pts_threshold_change( | ||
-INCREMENT_TP_PTS_THRESHOLD | ||
); | ||
} | ||
|
||
return -ENOTSUP; | ||
} | ||
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) | ||
{ | ||
return ZMK_BEHAVIOR_OPAQUE; | ||
} | ||
|
||
// Initialization Function | ||
static int zmk_behavior_mouse_setting_init(const struct device *dev) { | ||
return 0; | ||
}; | ||
|
||
static const struct behavior_driver_api | ||
zmk_behavior_mouse_setting_driver_api = { | ||
.binding_pressed = on_keymap_binding_pressed, | ||
.binding_released = on_keymap_binding_released | ||
}; | ||
|
||
DEVICE_DT_INST_DEFINE( | ||
0, | ||
zmk_behavior_mouse_setting_init, NULL, | ||
NULL, NULL, | ||
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, | ||
&zmk_behavior_mouse_setting_driver_api | ||
); |
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,61 @@ | ||
# Copyright (c) 2023 The ZMK Contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
DT_COMPAT_ZMK_PS2_MOUSE := zmk,mouse-ps2 | ||
|
||
config ZMK_MOUSE | ||
bool "Enable ZMK mouse emulation" | ||
default n | ||
select INPUT | ||
select INPUT_THREAD_PRIORITY_OVERRIDE | ||
|
||
config ZMK_MOUSE_PS2 | ||
bool | ||
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_PS2_MOUSE)) | ||
depends on (!ZMK_SPLIT || ZMK_SPLIT_ROLE_CENTRAL) | ||
select ZMK_MOUSE | ||
select PS2 | ||
|
||
if ZMK_MOUSE_PS2 | ||
|
||
config ZMK_MOUSE_PS2_SAMPLING_RATE | ||
int "Sets how many mouse activity reports should be sent per second. The default is 100. You can reduce this setting if you see a lot of PS/2 transmission errors. Increasing it will not lead to significant improvements, because mouse reports are accumulated and only sent over bluetooth every `CONFIG_ZMK_MOUSE_TICK_DURATION` ms." | ||
default 100 | ||
|
||
config ZMK_MOUSE_PS2_ENABLE_CLICKING | ||
bool "Enables clicking events." | ||
default y | ||
|
||
config ZMK_MOUSE_PS2_INVERT_X | ||
bool "Invert the mouse movement x axis." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_INVERT_Y | ||
bool "Invert the mouse movement y axis." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_SWAP_XY | ||
bool "Swaps the X and Y axis." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_SCROLL | ||
bool "Enable scroll wheel on mouse devices supporting the Intellimouse extension." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_TP_TAP_TO_SELECT | ||
bool "Enables the ability to left-click by tapping the trackpoint." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_TP_INVERT_X | ||
bool "Inverts x on the trackpoint. This is sets the setting directly in the trackpoint firmware and should therefore correctly impact the trackpoint algorithms." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_TP_INVERT_Y | ||
bool "Inverts y on the trackpoint. This is sets the setting directly in the trackpoint firmware and should therefore correctly impact the trackpoint algorithms." | ||
default n | ||
|
||
config ZMK_MOUSE_PS2_TP_SWAP_XY | ||
bool "Swaps the x and y axis on the trackpoint. This is sets the swap settingin the trackpoint firmware and should therefore correctly impact the trackpoint algorithms. But this setting is not supported by all trackpoints." | ||
default n | ||
|
||
endif # ZMK_MOUSE_PS2 |
Oops, something went wrong.