@desklink/host 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +44 -0
- package/README.md +266 -0
- package/bin/desklink-host.mjs +113 -0
- package/dist/bridge.d.ts +57 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +208 -0
- package/dist/bridge.js.map +1 -0
- package/dist/engineProcess.d.ts +82 -0
- package/dist/engineProcess.d.ts.map +1 -0
- package/dist/engineProcess.js +243 -0
- package/dist/engineProcess.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +169 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +18 -0
- package/dist/protocol.js.map +1 -0
- package/dist/resolveEngine.d.ts +34 -0
- package/dist/resolveEngine.d.ts.map +1 -0
- package/dist/resolveEngine.js +103 -0
- package/dist/resolveEngine.js.map +1 -0
- package/docs/BOUNDARY.md +145 -0
- package/docs/PROTOCOL.md +363 -0
- package/engine/Cargo.lock +3077 -0
- package/engine/Cargo.toml +37 -0
- package/engine/build.rs +107 -0
- package/engine/native/inputtino_shim.cpp +11 -0
- package/engine/native/vpx_shim.c +184 -0
- package/engine/native/wrapper.h +7 -0
- package/engine/src/capture.rs +510 -0
- package/engine/src/clipboard.rs +132 -0
- package/engine/src/convert.rs +299 -0
- package/engine/src/encoder.rs +204 -0
- package/engine/src/input.rs +355 -0
- package/engine/src/keymap.rs +338 -0
- package/engine/src/main.rs +614 -0
- package/engine/src/peer.rs +775 -0
- package/engine/src/portal.rs +115 -0
- package/engine/src/protocol.rs +331 -0
- package/engine/src/session.rs +2159 -0
- package/engine/src/x11.rs +244 -0
- package/engine/vendor/inputtino/.clang-format +166 -0
- package/engine/vendor/inputtino/.clang-tidy +30 -0
- package/engine/vendor/inputtino/.dockerignore +11 -0
- package/engine/vendor/inputtino/.github/workflows/mirror-repo.yml +14 -0
- package/engine/vendor/inputtino/.github/workflows/python-lint-format-test-typecheck.yml +124 -0
- package/engine/vendor/inputtino/.github/workflows/python-test-install.yaml +49 -0
- package/engine/vendor/inputtino/.github/workflows/rust.yml +40 -0
- package/engine/vendor/inputtino/CMakeLists.txt +187 -0
- package/engine/vendor/inputtino/LICENSE +21 -0
- package/engine/vendor/inputtino/README.md +110 -0
- package/engine/vendor/inputtino/bindings/python/.devcontainer/Dockerfile +23 -0
- package/engine/vendor/inputtino/bindings/python/.devcontainer/devcontainer.json +28 -0
- package/engine/vendor/inputtino/bindings/python/.python-version +1 -0
- package/engine/vendor/inputtino/bindings/python/CMakeLists.txt +23 -0
- package/engine/vendor/inputtino/bindings/python/CPPLINT.cfg +2 -0
- package/engine/vendor/inputtino/bindings/python/Makefile +49 -0
- package/engine/vendor/inputtino/bindings/python/README.md +215 -0
- package/engine/vendor/inputtino/bindings/python/pyproject.toml +178 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/__init__.py +43 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/_core.pyi +533 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/base.py +63 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/joypad.py +248 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/keyboard.py +256 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/mouse.py +106 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/pentablet.py +73 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/py.typed +0 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/touchscreen.py +61 -0
- package/engine/vendor/inputtino/bindings/python/src/inputtino/trackpad.py +74 -0
- package/engine/vendor/inputtino/bindings/python/src/main.cpp +217 -0
- package/engine/vendor/inputtino/bindings/python/tests/__init__.py +0 -0
- package/engine/vendor/inputtino/bindings/python/tests/helpers.py +3 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_base.py +60 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_inputtino.py +5 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_joypad.py +332 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_keyboard.py +164 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_mouse.py +185 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_pentablet.py +198 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_touchscreen.py +144 -0
- package/engine/vendor/inputtino/bindings/python/tests/test_trackpad.py +146 -0
- package/engine/vendor/inputtino/bindings/python/uv.lock +390 -0
- package/engine/vendor/inputtino/bindings/rust/Cargo.toml +6 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/.dockerignore +1 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/Cargo.toml +18 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/examples/keyboard.rs +33 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/examples/mouse.rs +17 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/common.rs +116 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/error.rs +17 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad.rs +74 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_nintendo.rs +135 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_ps5.rs +280 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_xbox.rs +134 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/keyboard.rs +76 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/lib.rs +32 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/src/mouse.rs +178 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/tests/common.rs +38 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/tests/joypads.rs +150 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/tests/keyboard.rs +73 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino/tests/mouse.rs +139 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino-sys/.dockerignore +1 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino-sys/Cargo.toml +12 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino-sys/build.rs +48 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino-sys/src/lib.rs +5 -0
- package/engine/vendor/inputtino/bindings/rust/inputtino-sys/wrapper.h +1 -0
- package/engine/vendor/inputtino/cmake/utils.cmake +9 -0
- package/engine/vendor/inputtino/docker/Dockerfile +70 -0
- package/engine/vendor/inputtino/include/inputtino/input.h +324 -0
- package/engine/vendor/inputtino/include/inputtino/input.hpp +466 -0
- package/engine/vendor/inputtino/include/inputtino/result.hpp +37 -0
- package/engine/vendor/inputtino/share/pkgconfig/libinputtino.pc.in +17 -0
- package/engine/vendor/inputtino/src/c-bindings/helpers.hpp +19 -0
- package/engine/vendor/inputtino/src/c-bindings/joypad_ps5.cpp +115 -0
- package/engine/vendor/inputtino/src/c-bindings/joypad_switch.cpp +63 -0
- package/engine/vendor/inputtino/src/c-bindings/joypad_xone.cpp +62 -0
- package/engine/vendor/inputtino/src/c-bindings/keyboard.cpp +42 -0
- package/engine/vendor/inputtino/src/c-bindings/mouse.cpp +67 -0
- package/engine/vendor/inputtino/src/c-bindings/pen_tablet.cpp +50 -0
- package/engine/vendor/inputtino/src/c-bindings/touchscreen.cpp +43 -0
- package/engine/vendor/inputtino/src/c-bindings/trackpad.cpp +49 -0
- package/engine/vendor/inputtino/src/uhid/README.adoc +63 -0
- package/engine/vendor/inputtino/src/uhid/include/crc32.hpp +38 -0
- package/engine/vendor/inputtino/src/uhid/include/uhid/protected_types.hpp +36 -0
- package/engine/vendor/inputtino/src/uhid/include/uhid/ps5.hpp +550 -0
- package/engine/vendor/inputtino/src/uhid/include/uhid/uhid.hpp +168 -0
- package/engine/vendor/inputtino/src/uhid/joypad_ps5.cpp +580 -0
- package/engine/vendor/inputtino/src/uinput/include/inputtino/keyboard.hpp +84 -0
- package/engine/vendor/inputtino/src/uinput/include/inputtino/protected_ps5_types.hpp +7 -0
- package/engine/vendor/inputtino/src/uinput/include/inputtino/protected_types.hpp +110 -0
- package/engine/vendor/inputtino/src/uinput/joypad_nintendo.cpp +190 -0
- package/engine/vendor/inputtino/src/uinput/joypad_ps.cpp +203 -0
- package/engine/vendor/inputtino/src/uinput/joypad_utils.hpp +246 -0
- package/engine/vendor/inputtino/src/uinput/joypad_xbox.cpp +190 -0
- package/engine/vendor/inputtino/src/uinput/keyboard.cpp +120 -0
- package/engine/vendor/inputtino/src/uinput/mouse.cpp +199 -0
- package/engine/vendor/inputtino/src/uinput/pentablet.cpp +162 -0
- package/engine/vendor/inputtino/src/uinput/touchscreen.cpp +140 -0
- package/engine/vendor/inputtino/src/uinput/trackpad.cpp +192 -0
- package/examples/reference-client.html +428 -0
- package/package.json +38 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Touchscreen input device implementation."""
|
|
2
|
+
|
|
3
|
+
from . import _core
|
|
4
|
+
from .base import DeviceDefinition, VirtualDevice
|
|
5
|
+
|
|
6
|
+
# Default device definition for touchscreen
|
|
7
|
+
DEFAULT_TOUCHSCREEN = DeviceDefinition(
|
|
8
|
+
name="Wolf (virtual) touchscreen",
|
|
9
|
+
vendor_id=0xAB00,
|
|
10
|
+
product_id=0xAB03,
|
|
11
|
+
version=0xAB00,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TouchScreen(VirtualDevice):
|
|
16
|
+
"""Virtual touchscreen input device.
|
|
17
|
+
|
|
18
|
+
This class provides functionality to simulate touchscreen
|
|
19
|
+
interactions. The device appears as a real touchscreen input device
|
|
20
|
+
to the system.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, device_def: DeviceDefinition = DEFAULT_TOUCHSCREEN) -> None:
|
|
24
|
+
"""Initialize the touchscreen device with optional custom device
|
|
25
|
+
definition.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
device_def: Optional device definition for customizing the virtual device properties
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
RuntimeError: If device creation fails
|
|
32
|
+
"""
|
|
33
|
+
self._touchscreen = _core.TouchScreen.create(device_def.to_core())
|
|
34
|
+
super().__init__(self._touchscreen)
|
|
35
|
+
|
|
36
|
+
def place_finger(
|
|
37
|
+
self,
|
|
38
|
+
finger_nr: int,
|
|
39
|
+
x: float,
|
|
40
|
+
y: float,
|
|
41
|
+
pressure: float = 1.0,
|
|
42
|
+
orientation: int = 0,
|
|
43
|
+
) -> None:
|
|
44
|
+
"""Place a finger on the touchscreen.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
finger_nr: Finger number for multi-touch support
|
|
48
|
+
x: X coordinate in normalized device coordinates [0.0, 1.0]
|
|
49
|
+
y: Y coordinate in normalized device coordinates [0.0, 1.0]
|
|
50
|
+
pressure: Pressure value between 0.0 and 1.0
|
|
51
|
+
orientation: Finger orientation in degrees [-90, 90]
|
|
52
|
+
"""
|
|
53
|
+
self._touchscreen.place_finger(finger_nr, x, y, pressure, orientation)
|
|
54
|
+
|
|
55
|
+
def release_finger(self, finger_nr: int) -> None:
|
|
56
|
+
"""Release a finger from the touchscreen.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
finger_nr: Finger number to release
|
|
60
|
+
"""
|
|
61
|
+
self._touchscreen.release_finger(finger_nr)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Trackpad input device implementation."""
|
|
2
|
+
|
|
3
|
+
from . import _core
|
|
4
|
+
from .base import DeviceDefinition, VirtualDevice
|
|
5
|
+
|
|
6
|
+
DEFAULT_TRACKPAD = DeviceDefinition(
|
|
7
|
+
name="Wolf (virtual) touchpad",
|
|
8
|
+
vendor_id=0xAB00,
|
|
9
|
+
product_id=0xAB02,
|
|
10
|
+
version=0xAB00,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Trackpad(VirtualDevice):
|
|
15
|
+
"""Virtual trackpad input device.
|
|
16
|
+
|
|
17
|
+
This class provides functionality to simulate multi-touch trackpad
|
|
18
|
+
interactions. The device appears as a real touchpad input device to
|
|
19
|
+
the system.
|
|
20
|
+
|
|
21
|
+
implements a pure multi-touch touchpad as defined in libinput
|
|
22
|
+
https://wayland.freedesktop.org/libinput/doc/latest/touchpads.html
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, device_def: DeviceDefinition = DEFAULT_TRACKPAD) -> None:
|
|
26
|
+
"""Initialize the trackpad device with optional custom device
|
|
27
|
+
definition.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
device_def: Optional device definition for customizing the virtual device properties
|
|
31
|
+
|
|
32
|
+
Raises:
|
|
33
|
+
RuntimeError: If device creation fails
|
|
34
|
+
"""
|
|
35
|
+
self._trackpad = _core.Trackpad.create(device_def.to_core())
|
|
36
|
+
super().__init__(self._trackpad)
|
|
37
|
+
|
|
38
|
+
def place_finger(
|
|
39
|
+
self,
|
|
40
|
+
finger_nr: int,
|
|
41
|
+
x: float,
|
|
42
|
+
y: float,
|
|
43
|
+
pressure: float = 1.0,
|
|
44
|
+
orientation: int = 0,
|
|
45
|
+
) -> None:
|
|
46
|
+
"""Place a finger on the trackpad surface.
|
|
47
|
+
|
|
48
|
+
The x and y coordinates are normalized device coordinates from the top-left
|
|
49
|
+
corner (0.0, 0.0) to bottom-right corner (1.0, 1.0).
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
finger_nr: Finger index (supports multi-touch)
|
|
53
|
+
x: Normalized X coordinate [0.0, 1.0]
|
|
54
|
+
y: Normalized Y coordinate [0.0, 1.0]
|
|
55
|
+
pressure: Touch pressure [0.0, 1.0]
|
|
56
|
+
orientation: Finger orientation in degrees [-90, 90]
|
|
57
|
+
"""
|
|
58
|
+
self._trackpad.place_finger(finger_nr, x, y, pressure, orientation)
|
|
59
|
+
|
|
60
|
+
def release_finger(self, finger_nr: int) -> None:
|
|
61
|
+
"""Release a finger from the trackpad surface.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
finger_nr: Finger index to release
|
|
65
|
+
"""
|
|
66
|
+
self._trackpad.release_finger(finger_nr)
|
|
67
|
+
|
|
68
|
+
def set_left_button(self, pressed: bool) -> None:
|
|
69
|
+
"""Set the state of the left trackpad button.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
pressed: True to press the button, False to release
|
|
73
|
+
"""
|
|
74
|
+
self._trackpad.set_left_btn(pressed)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#include <pybind11/functional.h>
|
|
2
|
+
#include <pybind11/pybind11.h>
|
|
3
|
+
#include <pybind11/stl.h>
|
|
4
|
+
|
|
5
|
+
#include <inputtino/input.hpp>
|
|
6
|
+
|
|
7
|
+
namespace py = pybind11;
|
|
8
|
+
|
|
9
|
+
PYBIND11_MODULE(_core, m) {
|
|
10
|
+
m.doc() = "pybind inputtino module!";
|
|
11
|
+
|
|
12
|
+
// DeviceDefinition
|
|
13
|
+
py::class_<inputtino::DeviceDefinition>(m, "DeviceDefinition")
|
|
14
|
+
.def(py::init<>())
|
|
15
|
+
.def_readwrite("name", &inputtino::DeviceDefinition::name)
|
|
16
|
+
.def_readwrite("vendor_id", &inputtino::DeviceDefinition::vendor_id)
|
|
17
|
+
.def_readwrite("product_id", &inputtino::DeviceDefinition::product_id)
|
|
18
|
+
.def_readwrite("version", &inputtino::DeviceDefinition::version)
|
|
19
|
+
.def_readwrite("device_phys", &inputtino::DeviceDefinition::device_phys)
|
|
20
|
+
.def_readwrite("device_uniq", &inputtino::DeviceDefinition::device_uniq);
|
|
21
|
+
|
|
22
|
+
// VirtualDevice
|
|
23
|
+
py::class_<inputtino::VirtualDevice>(m, "VirtualDevice")
|
|
24
|
+
.def("get_nodes", &inputtino::VirtualDevice::get_nodes);
|
|
25
|
+
|
|
26
|
+
// Mouse Button Enum
|
|
27
|
+
py::enum_<inputtino::Mouse::MOUSE_BUTTON>(m, "MouseButton")
|
|
28
|
+
.value("LEFT", inputtino::Mouse::MOUSE_BUTTON::LEFT)
|
|
29
|
+
.value("MIDDLE", inputtino::Mouse::MOUSE_BUTTON::MIDDLE)
|
|
30
|
+
.value("RIGHT", inputtino::Mouse::MOUSE_BUTTON::RIGHT)
|
|
31
|
+
.value("SIDE", inputtino::Mouse::MOUSE_BUTTON::SIDE)
|
|
32
|
+
.value("EXTRA", inputtino::Mouse::MOUSE_BUTTON::EXTRA);
|
|
33
|
+
|
|
34
|
+
// Mouse
|
|
35
|
+
py::class_<inputtino::Mouse, inputtino::VirtualDevice>(m, "Mouse")
|
|
36
|
+
.def_static("create",
|
|
37
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
38
|
+
auto result = inputtino::Mouse::create(dev);
|
|
39
|
+
if (!result) {
|
|
40
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
41
|
+
}
|
|
42
|
+
return std::move(*result);
|
|
43
|
+
})
|
|
44
|
+
.def("move", &inputtino::Mouse::move)
|
|
45
|
+
.def("move_abs", &inputtino::Mouse::move_abs)
|
|
46
|
+
.def("press", &inputtino::Mouse::press)
|
|
47
|
+
.def("release", &inputtino::Mouse::release)
|
|
48
|
+
.def("vertical_scroll", &inputtino::Mouse::vertical_scroll)
|
|
49
|
+
.def("horizontal_scroll", &inputtino::Mouse::horizontal_scroll);
|
|
50
|
+
|
|
51
|
+
// Keyboard
|
|
52
|
+
py::class_<inputtino::Keyboard, inputtino::VirtualDevice>(m, "Keyboard")
|
|
53
|
+
.def_static("create",
|
|
54
|
+
[](const inputtino::DeviceDefinition& dev,
|
|
55
|
+
int millis_repress_key = 50) {
|
|
56
|
+
auto result =
|
|
57
|
+
inputtino::Keyboard::create(dev, millis_repress_key);
|
|
58
|
+
if (!result) {
|
|
59
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
60
|
+
}
|
|
61
|
+
return std::move(*result);
|
|
62
|
+
})
|
|
63
|
+
.def("press", &inputtino::Keyboard::press)
|
|
64
|
+
.def("release", &inputtino::Keyboard::release);
|
|
65
|
+
|
|
66
|
+
// Trackpad
|
|
67
|
+
py::class_<inputtino::Trackpad, inputtino::VirtualDevice>(m, "Trackpad")
|
|
68
|
+
.def_static("create",
|
|
69
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
70
|
+
auto result = inputtino::Trackpad::create(dev);
|
|
71
|
+
if (!result) {
|
|
72
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
73
|
+
}
|
|
74
|
+
return std::move(*result);
|
|
75
|
+
})
|
|
76
|
+
.def("place_finger", &inputtino::Trackpad::place_finger)
|
|
77
|
+
.def("release_finger", &inputtino::Trackpad::release_finger)
|
|
78
|
+
.def("set_left_btn", &inputtino::Trackpad::set_left_btn);
|
|
79
|
+
|
|
80
|
+
// Joypad Enums
|
|
81
|
+
py::enum_<inputtino::Joypad::CONTROLLER_BTN>(m, "ControllerButton")
|
|
82
|
+
.value("DPAD_UP", inputtino::Joypad::CONTROLLER_BTN::DPAD_UP)
|
|
83
|
+
.value("DPAD_DOWN", inputtino::Joypad::CONTROLLER_BTN::DPAD_DOWN)
|
|
84
|
+
.value("DPAD_LEFT", inputtino::Joypad::CONTROLLER_BTN::DPAD_LEFT)
|
|
85
|
+
.value("DPAD_RIGHT", inputtino::Joypad::CONTROLLER_BTN::DPAD_RIGHT)
|
|
86
|
+
.value("START", inputtino::Joypad::CONTROLLER_BTN::START)
|
|
87
|
+
.value("BACK", inputtino::Joypad::CONTROLLER_BTN::BACK)
|
|
88
|
+
.value("HOME", inputtino::Joypad::CONTROLLER_BTN::HOME)
|
|
89
|
+
.value("LEFT_STICK", inputtino::Joypad::CONTROLLER_BTN::LEFT_STICK)
|
|
90
|
+
.value("RIGHT_STICK", inputtino::Joypad::CONTROLLER_BTN::RIGHT_STICK)
|
|
91
|
+
.value("LEFT_BUTTON", inputtino::Joypad::CONTROLLER_BTN::LEFT_BUTTON)
|
|
92
|
+
.value("RIGHT_BUTTON", inputtino::Joypad::CONTROLLER_BTN::RIGHT_BUTTON)
|
|
93
|
+
.value("SPECIAL_FLAG", inputtino::Joypad::CONTROLLER_BTN::SPECIAL_FLAG)
|
|
94
|
+
.value("PADDLE1_FLAG", inputtino::Joypad::CONTROLLER_BTN::PADDLE1_FLAG)
|
|
95
|
+
.value("PADDLE2_FLAG", inputtino::Joypad::CONTROLLER_BTN::PADDLE2_FLAG)
|
|
96
|
+
.value("PADDLE3_FLAG", inputtino::Joypad::CONTROLLER_BTN::PADDLE3_FLAG)
|
|
97
|
+
.value("PADDLE4_FLAG", inputtino::Joypad::CONTROLLER_BTN::PADDLE4_FLAG)
|
|
98
|
+
.value("TOUCHPAD_FLAG", inputtino::Joypad::CONTROLLER_BTN::TOUCHPAD_FLAG)
|
|
99
|
+
.value("MISC_FLAG", inputtino::Joypad::CONTROLLER_BTN::MISC_FLAG)
|
|
100
|
+
.value("A", inputtino::Joypad::CONTROLLER_BTN::A)
|
|
101
|
+
.value("B", inputtino::Joypad::CONTROLLER_BTN::B)
|
|
102
|
+
.value("X", inputtino::Joypad::CONTROLLER_BTN::X)
|
|
103
|
+
.value("Y", inputtino::Joypad::CONTROLLER_BTN::Y);
|
|
104
|
+
|
|
105
|
+
py::enum_<inputtino::Joypad::STICK_POSITION>(m, "StickPosition")
|
|
106
|
+
.value("RS", inputtino::Joypad::STICK_POSITION::RS)
|
|
107
|
+
.value("LS", inputtino::Joypad::STICK_POSITION::LS);
|
|
108
|
+
|
|
109
|
+
// Joypad base class
|
|
110
|
+
py::class_<inputtino::Joypad, inputtino::VirtualDevice>(m, "Joypad")
|
|
111
|
+
.def("set_pressed_buttons", &inputtino::Joypad::set_pressed_buttons)
|
|
112
|
+
.def("set_triggers", &inputtino::Joypad::set_triggers)
|
|
113
|
+
.def("set_stick", &inputtino::Joypad::set_stick);
|
|
114
|
+
|
|
115
|
+
// XboxOneJoypad
|
|
116
|
+
py::class_<inputtino::XboxOneJoypad, inputtino::Joypad>(m, "XboxOneJoypad")
|
|
117
|
+
.def_static("create",
|
|
118
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
119
|
+
auto result = inputtino::XboxOneJoypad::create(dev);
|
|
120
|
+
if (!result) {
|
|
121
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
122
|
+
}
|
|
123
|
+
return std::move(*result);
|
|
124
|
+
})
|
|
125
|
+
.def("set_on_rumble", &inputtino::XboxOneJoypad::set_on_rumble);
|
|
126
|
+
|
|
127
|
+
// SwitchJoypad
|
|
128
|
+
py::class_<inputtino::SwitchJoypad, inputtino::Joypad>(m, "SwitchJoypad")
|
|
129
|
+
.def_static("create",
|
|
130
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
131
|
+
auto result = inputtino::SwitchJoypad::create(dev);
|
|
132
|
+
if (!result) {
|
|
133
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
134
|
+
}
|
|
135
|
+
return std::move(*result);
|
|
136
|
+
})
|
|
137
|
+
.def("set_on_rumble", &inputtino::SwitchJoypad::set_on_rumble);
|
|
138
|
+
|
|
139
|
+
// PS5 Joypad Enums
|
|
140
|
+
py::enum_<inputtino::PS5Joypad::MOTION_TYPE>(m, "PS5MotionType")
|
|
141
|
+
.value("ACCELERATION", inputtino::PS5Joypad::MOTION_TYPE::ACCELERATION)
|
|
142
|
+
.value("GYROSCOPE", inputtino::PS5Joypad::MOTION_TYPE::GYROSCOPE);
|
|
143
|
+
|
|
144
|
+
py::enum_<inputtino::PS5Joypad::BATTERY_STATE>(m, "PS5BatteryState")
|
|
145
|
+
.value("BATTERY_DISCHARGING",
|
|
146
|
+
inputtino::PS5Joypad::BATTERY_STATE::BATTERY_DISCHARGING)
|
|
147
|
+
.value("BATTERY_CHARGING",
|
|
148
|
+
inputtino::PS5Joypad::BATTERY_STATE::BATTERY_CHARGHING)
|
|
149
|
+
.value("BATTERY_FULL", inputtino::PS5Joypad::BATTERY_STATE::BATTERY_FULL)
|
|
150
|
+
.value("VOLTAGE_OR_TEMPERATURE_OUT_OF_RANGE",
|
|
151
|
+
inputtino::PS5Joypad::BATTERY_STATE::
|
|
152
|
+
VOLTAGE_OR_TEMPERATURE_OUT_OF_RANGE)
|
|
153
|
+
.value("TEMPERATURE_ERROR",
|
|
154
|
+
inputtino::PS5Joypad::BATTERY_STATE::TEMPERATURE_ERROR)
|
|
155
|
+
.value("CHARGING_ERROR",
|
|
156
|
+
inputtino::PS5Joypad::BATTERY_STATE::CHARGHING_ERROR);
|
|
157
|
+
|
|
158
|
+
// PS5 Joypad
|
|
159
|
+
py::class_<inputtino::PS5Joypad, inputtino::Joypad>(m, "PS5Joypad")
|
|
160
|
+
.def_static("create",
|
|
161
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
162
|
+
auto result = inputtino::PS5Joypad::create(dev);
|
|
163
|
+
if (!result) {
|
|
164
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
165
|
+
}
|
|
166
|
+
return std::move(*result);
|
|
167
|
+
})
|
|
168
|
+
.def("get_mac_address", &inputtino::PS5Joypad::get_mac_address)
|
|
169
|
+
.def("get_sys_nodes", &inputtino::PS5Joypad::get_sys_nodes)
|
|
170
|
+
.def("place_finger", &inputtino::PS5Joypad::place_finger)
|
|
171
|
+
.def("release_finger", &inputtino::PS5Joypad::release_finger)
|
|
172
|
+
.def("set_motion", &inputtino::PS5Joypad::set_motion)
|
|
173
|
+
.def("set_battery", &inputtino::PS5Joypad::set_battery)
|
|
174
|
+
.def("set_on_rumble", &inputtino::PS5Joypad::set_on_rumble)
|
|
175
|
+
.def("set_on_led", &inputtino::PS5Joypad::set_on_led);
|
|
176
|
+
|
|
177
|
+
// TouchScreen
|
|
178
|
+
py::class_<inputtino::TouchScreen, inputtino::VirtualDevice>(m, "TouchScreen")
|
|
179
|
+
.def_static("create",
|
|
180
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
181
|
+
auto result = inputtino::TouchScreen::create(dev);
|
|
182
|
+
if (!result) {
|
|
183
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
184
|
+
}
|
|
185
|
+
return std::move(*result);
|
|
186
|
+
})
|
|
187
|
+
.def("place_finger", &inputtino::TouchScreen::place_finger)
|
|
188
|
+
.def("release_finger", &inputtino::TouchScreen::release_finger);
|
|
189
|
+
|
|
190
|
+
// PenTablet tool and button enums
|
|
191
|
+
py::enum_<inputtino::PenTablet::TOOL_TYPE>(m, "PenToolType")
|
|
192
|
+
.value("PEN", inputtino::PenTablet::TOOL_TYPE::PEN)
|
|
193
|
+
.value("ERASER", inputtino::PenTablet::TOOL_TYPE::ERASER)
|
|
194
|
+
.value("BRUSH", inputtino::PenTablet::TOOL_TYPE::BRUSH)
|
|
195
|
+
.value("PENCIL", inputtino::PenTablet::TOOL_TYPE::PENCIL)
|
|
196
|
+
.value("AIRBRUSH", inputtino::PenTablet::TOOL_TYPE::AIRBRUSH)
|
|
197
|
+
.value("TOUCH", inputtino::PenTablet::TOOL_TYPE::TOUCH)
|
|
198
|
+
.value("SAME_AS_BEFORE", inputtino::PenTablet::TOOL_TYPE::SAME_AS_BEFORE);
|
|
199
|
+
|
|
200
|
+
py::enum_<inputtino::PenTablet::BTN_TYPE>(m, "PenButtonType")
|
|
201
|
+
.value("PRIMARY", inputtino::PenTablet::BTN_TYPE::PRIMARY)
|
|
202
|
+
.value("SECONDARY", inputtino::PenTablet::BTN_TYPE::SECONDARY)
|
|
203
|
+
.value("TERTIARY", inputtino::PenTablet::BTN_TYPE::TERTIARY);
|
|
204
|
+
|
|
205
|
+
// PenTablet
|
|
206
|
+
py::class_<inputtino::PenTablet, inputtino::VirtualDevice>(m, "PenTablet")
|
|
207
|
+
.def_static("create",
|
|
208
|
+
[](const inputtino::DeviceDefinition& dev) {
|
|
209
|
+
auto result = inputtino::PenTablet::create(dev);
|
|
210
|
+
if (!result) {
|
|
211
|
+
throw std::runtime_error(result.getErrorMessage());
|
|
212
|
+
}
|
|
213
|
+
return std::move(*result);
|
|
214
|
+
})
|
|
215
|
+
.def("place_tool", &inputtino::PenTablet::place_tool)
|
|
216
|
+
.def("set_btn", &inputtino::PenTablet::set_btn);
|
|
217
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from unittest.mock import MagicMock
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from inputtino import _core
|
|
6
|
+
from inputtino.base import DeviceDefinition, VirtualDevice
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_device_definition_creation():
|
|
10
|
+
definition = DeviceDefinition(
|
|
11
|
+
name="Test Device",
|
|
12
|
+
vendor_id=0x1234,
|
|
13
|
+
product_id=0x5678,
|
|
14
|
+
version=1,
|
|
15
|
+
device_phys="/dev/input/test",
|
|
16
|
+
device_uniq="unique_id",
|
|
17
|
+
)
|
|
18
|
+
assert definition.name == "Test Device"
|
|
19
|
+
assert definition.vendor_id == 0x1234
|
|
20
|
+
assert definition.product_id == 0x5678
|
|
21
|
+
assert definition.version == 1
|
|
22
|
+
assert definition.device_phys == "/dev/input/test"
|
|
23
|
+
assert definition.device_uniq == "unique_id"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_device_definition_to_core():
|
|
27
|
+
definition = DeviceDefinition(
|
|
28
|
+
name="Test Device",
|
|
29
|
+
vendor_id=0x1234,
|
|
30
|
+
product_id=0x5678,
|
|
31
|
+
version=1,
|
|
32
|
+
device_phys="/dev/input/test",
|
|
33
|
+
device_uniq="unique_id",
|
|
34
|
+
)
|
|
35
|
+
core_def = definition.to_core()
|
|
36
|
+
|
|
37
|
+
assert isinstance(core_def, _core.DeviceDefinition)
|
|
38
|
+
assert core_def.name == definition.name
|
|
39
|
+
assert core_def.vendor_id == definition.vendor_id
|
|
40
|
+
assert core_def.product_id == definition.product_id
|
|
41
|
+
assert core_def.version == definition.version
|
|
42
|
+
assert core_def.device_phys == definition.device_phys
|
|
43
|
+
assert core_def.device_uniq == definition.device_uniq
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.fixture
|
|
47
|
+
def mock_core_device():
|
|
48
|
+
"""Create a mock for core VirtualDevice."""
|
|
49
|
+
mock_device = MagicMock(spec=_core.VirtualDevice)
|
|
50
|
+
mock_device.get_nodes.return_value = ["/dev/input/event0", "/dev/input/mouse0"]
|
|
51
|
+
return mock_device
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_virtual_device_nodes(mock_core_device):
|
|
55
|
+
"""Test getting device nodes from virtual device."""
|
|
56
|
+
device = VirtualDevice(mock_core_device)
|
|
57
|
+
nodes = device.nodes
|
|
58
|
+
|
|
59
|
+
assert nodes == ["/dev/input/event0", "/dev/input/mouse0"]
|
|
60
|
+
mock_core_device.get_nodes.assert_called_once()
|