-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 input configs for data mods.
* Add ability to swap X/Y, invert X and Y values, and apply a scalar multiplier/divisor.
- Loading branch information
1 parent
442289d
commit c2bf21b
Showing
17 changed files
with
325 additions
and
21 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,24 @@ | ||
description: | | ||
Allows post-processing of input events based on the configuration | ||
compatible: "zmk,input-configs" | ||
|
||
child-binding: | ||
description: "A configuration for a given input device" | ||
|
||
properties: | ||
device: | ||
type: phandle | ||
required: true | ||
xy-swap: | ||
type: boolean | ||
x-invert: | ||
type: boolean | ||
y-invert: | ||
type: boolean | ||
scale-multiplier: | ||
type: int | ||
default: 1 | ||
scale-divisor: | ||
type: int | ||
default: 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,21 @@ | ||
/* | ||
* Copyright (c) 2023 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/device.h> | ||
|
||
struct zmk_input_config { | ||
const struct device *dev; | ||
bool xy_swap; | ||
bool x_invert; | ||
bool y_invert; | ||
uint16_t scale_multiplier; | ||
uint16_t scale_divisor; | ||
}; | ||
|
||
const struct zmk_input_config *zmk_input_config_get_for_device(const struct device *dev); |
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,42 @@ | ||
/* | ||
* Copyright (c) 2023 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include <zmk/mouse/input_config.h> | ||
#include <zephyr/device.h> | ||
|
||
#define DT_DRV_COMPAT zmk_input_configs | ||
|
||
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) | ||
|
||
#define CHILD_CONFIG(inst) \ | ||
{ \ | ||
.dev = DEVICE_DT_GET(DT_PHANDLE(inst, device)), \ | ||
.xy_swap = DT_PROP(inst, xy_swap), \ | ||
.x_invert = DT_PROP(inst, x_invert), \ | ||
.y_invert = DT_PROP(inst, y_invert), \ | ||
.scale_multiplier = DT_PROP(inst, scale_multiplier), \ | ||
.scale_divisor = DT_PROP(inst, scale_divisor), \ | ||
}, | ||
|
||
const struct zmk_input_config configs[] = {DT_INST_FOREACH_CHILD(0, CHILD_CONFIG)}; | ||
|
||
const struct zmk_input_config *zmk_input_config_get_for_device(const struct device *dev) { | ||
for (int i = 0; i < ARRAY_SIZE(configs); i++) { | ||
if (configs[i].dev == dev) { | ||
return &configs[i]; | ||
} | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
#else | ||
|
||
const struct zmk_input_config *zmk_input_config_get_for_device(const struct device *dev) { | ||
return NULL; | ||
} | ||
|
||
#endif |
1 change: 1 addition & 0 deletions
1
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_scaling/events.patterns
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 @@ | ||
s/.*hid_mouse_//p |
22 changes: 22 additions & 0 deletions
22
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_scaling/keycode_events.snapshot
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,22 @@ | ||
movement_update: Mouse movement updated to -1/0 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to -3/0 | ||
movement_update: Mouse movement updated to -3/-3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to -3/0 | ||
movement_update: Mouse movement updated to -3/-3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to -5/0 | ||
movement_update: Mouse movement updated to -5/-3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to -5/0 | ||
movement_update: Mouse movement updated to -5/-5 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 0/-5 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 |
38 changes: 38 additions & 0 deletions
38
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_scaling/native_posix_64.keymap
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,38 @@ | ||
#include <behaviors.dtsi> | ||
#include <dt-bindings/zmk/keys.h> | ||
#include <dt-bindings/zmk/kscan_mock.h> | ||
#include <dt-bindings/zmk/mouse.h> | ||
|
||
/ { | ||
keymap { | ||
compatible = "zmk,keymap"; | ||
label ="Default keymap"; | ||
|
||
default_layer { | ||
bindings = < | ||
&mmv MOVE_LEFT &mmv MOVE_UP | ||
&none &none | ||
>; | ||
}; | ||
}; | ||
|
||
input_configs { | ||
compatible = "zmk,input-configs"; | ||
|
||
mmv { | ||
device = <&mmv>; | ||
scale-multiplier = <5>; | ||
scale-divisor = <3>; | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
&kscan { | ||
events = < | ||
ZMK_MOCK_PRESS(0,0,10) | ||
ZMK_MOCK_PRESS(0,1,100) | ||
ZMK_MOCK_RELEASE(0,0,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
>; | ||
}; |
1 change: 1 addition & 0 deletions
1
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_xy_invert/events.patterns
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 @@ | ||
s/.*hid_mouse_//p |
22 changes: 22 additions & 0 deletions
22
...tests/mouse-keys/mouse-move/input-configs/move_diagonal_xy_invert/keycode_events.snapshot
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,22 @@ | ||
movement_update: Mouse movement updated to 1/0 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 2/0 | ||
movement_update: Mouse movement updated to 2/2 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 2/0 | ||
movement_update: Mouse movement updated to 2/2 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 3/0 | ||
movement_update: Mouse movement updated to 3/2 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 3/0 | ||
movement_update: Mouse movement updated to 3/3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 0/3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 |
38 changes: 38 additions & 0 deletions
38
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_xy_invert/native_posix_64.keymap
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,38 @@ | ||
#include <behaviors.dtsi> | ||
#include <dt-bindings/zmk/keys.h> | ||
#include <dt-bindings/zmk/kscan_mock.h> | ||
#include <dt-bindings/zmk/mouse.h> | ||
|
||
/ { | ||
keymap { | ||
compatible = "zmk,keymap"; | ||
label ="Default keymap"; | ||
|
||
default_layer { | ||
bindings = < | ||
&mmv MOVE_LEFT &mmv MOVE_UP | ||
&none &none | ||
>; | ||
}; | ||
}; | ||
|
||
input_configs { | ||
compatible = "zmk,input-configs"; | ||
|
||
mmv { | ||
device = <&mmv>; | ||
x-invert; | ||
y-invert; | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
&kscan { | ||
events = < | ||
ZMK_MOCK_PRESS(0,0,10) | ||
ZMK_MOCK_PRESS(0,1,100) | ||
ZMK_MOCK_RELEASE(0,0,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
>; | ||
}; |
1 change: 1 addition & 0 deletions
1
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_xy_swap/events.patterns
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 @@ | ||
s/.*hid_mouse_//p |
22 changes: 22 additions & 0 deletions
22
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_xy_swap/keycode_events.snapshot
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,22 @@ | ||
movement_update: Mouse movement updated to 0/-1 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 0/-2 | ||
movement_update: Mouse movement updated to -2/-2 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 0/-2 | ||
movement_update: Mouse movement updated to -2/-2 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 0/-3 | ||
movement_update: Mouse movement updated to -2/-3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to 0/-3 | ||
movement_update: Mouse movement updated to -3/-3 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 | ||
movement_update: Mouse movement updated to -3/0 | ||
scroll_set: Mouse scroll set to 0/0 | ||
movement_set: Mouse movement set to 0/0 |
37 changes: 37 additions & 0 deletions
37
app/tests/mouse-keys/mouse-move/input-configs/move_diagonal_xy_swap/native_posix_64.keymap
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,37 @@ | ||
#include <behaviors.dtsi> | ||
#include <dt-bindings/zmk/keys.h> | ||
#include <dt-bindings/zmk/kscan_mock.h> | ||
#include <dt-bindings/zmk/mouse.h> | ||
|
||
/ { | ||
keymap { | ||
compatible = "zmk,keymap"; | ||
label ="Default keymap"; | ||
|
||
default_layer { | ||
bindings = < | ||
&mmv MOVE_LEFT &mmv MOVE_UP | ||
&none &none | ||
>; | ||
}; | ||
}; | ||
|
||
input_configs { | ||
compatible = "zmk,input-configs"; | ||
|
||
mmv { | ||
device = <&mmv>; | ||
xy-swap; | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
&kscan { | ||
events = < | ||
ZMK_MOCK_PRESS(0,0,10) | ||
ZMK_MOCK_PRESS(0,1,100) | ||
ZMK_MOCK_RELEASE(0,0,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
>; | ||
}; |
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.