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
# Conflicts: # app/CMakeLists.txt
- Loading branch information
1 parent
aab47ea
commit bdb29a0
Showing
11 changed files
with
2,262 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
Oops, something went wrong.