@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.
Files changed (142) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +44 -0
  3. package/README.md +266 -0
  4. package/bin/desklink-host.mjs +113 -0
  5. package/dist/bridge.d.ts +57 -0
  6. package/dist/bridge.d.ts.map +1 -0
  7. package/dist/bridge.js +208 -0
  8. package/dist/bridge.js.map +1 -0
  9. package/dist/engineProcess.d.ts +82 -0
  10. package/dist/engineProcess.d.ts.map +1 -0
  11. package/dist/engineProcess.js +243 -0
  12. package/dist/engineProcess.js.map +1 -0
  13. package/dist/index.d.ts +12 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +12 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/protocol.d.ts +169 -0
  18. package/dist/protocol.d.ts.map +1 -0
  19. package/dist/protocol.js +18 -0
  20. package/dist/protocol.js.map +1 -0
  21. package/dist/resolveEngine.d.ts +34 -0
  22. package/dist/resolveEngine.d.ts.map +1 -0
  23. package/dist/resolveEngine.js +103 -0
  24. package/dist/resolveEngine.js.map +1 -0
  25. package/docs/BOUNDARY.md +145 -0
  26. package/docs/PROTOCOL.md +363 -0
  27. package/engine/Cargo.lock +3077 -0
  28. package/engine/Cargo.toml +37 -0
  29. package/engine/build.rs +107 -0
  30. package/engine/native/inputtino_shim.cpp +11 -0
  31. package/engine/native/vpx_shim.c +184 -0
  32. package/engine/native/wrapper.h +7 -0
  33. package/engine/src/capture.rs +510 -0
  34. package/engine/src/clipboard.rs +132 -0
  35. package/engine/src/convert.rs +299 -0
  36. package/engine/src/encoder.rs +204 -0
  37. package/engine/src/input.rs +355 -0
  38. package/engine/src/keymap.rs +338 -0
  39. package/engine/src/main.rs +614 -0
  40. package/engine/src/peer.rs +775 -0
  41. package/engine/src/portal.rs +115 -0
  42. package/engine/src/protocol.rs +331 -0
  43. package/engine/src/session.rs +2159 -0
  44. package/engine/src/x11.rs +244 -0
  45. package/engine/vendor/inputtino/.clang-format +166 -0
  46. package/engine/vendor/inputtino/.clang-tidy +30 -0
  47. package/engine/vendor/inputtino/.dockerignore +11 -0
  48. package/engine/vendor/inputtino/.github/workflows/mirror-repo.yml +14 -0
  49. package/engine/vendor/inputtino/.github/workflows/python-lint-format-test-typecheck.yml +124 -0
  50. package/engine/vendor/inputtino/.github/workflows/python-test-install.yaml +49 -0
  51. package/engine/vendor/inputtino/.github/workflows/rust.yml +40 -0
  52. package/engine/vendor/inputtino/CMakeLists.txt +187 -0
  53. package/engine/vendor/inputtino/LICENSE +21 -0
  54. package/engine/vendor/inputtino/README.md +110 -0
  55. package/engine/vendor/inputtino/bindings/python/.devcontainer/Dockerfile +23 -0
  56. package/engine/vendor/inputtino/bindings/python/.devcontainer/devcontainer.json +28 -0
  57. package/engine/vendor/inputtino/bindings/python/.python-version +1 -0
  58. package/engine/vendor/inputtino/bindings/python/CMakeLists.txt +23 -0
  59. package/engine/vendor/inputtino/bindings/python/CPPLINT.cfg +2 -0
  60. package/engine/vendor/inputtino/bindings/python/Makefile +49 -0
  61. package/engine/vendor/inputtino/bindings/python/README.md +215 -0
  62. package/engine/vendor/inputtino/bindings/python/pyproject.toml +178 -0
  63. package/engine/vendor/inputtino/bindings/python/src/inputtino/__init__.py +43 -0
  64. package/engine/vendor/inputtino/bindings/python/src/inputtino/_core.pyi +533 -0
  65. package/engine/vendor/inputtino/bindings/python/src/inputtino/base.py +63 -0
  66. package/engine/vendor/inputtino/bindings/python/src/inputtino/joypad.py +248 -0
  67. package/engine/vendor/inputtino/bindings/python/src/inputtino/keyboard.py +256 -0
  68. package/engine/vendor/inputtino/bindings/python/src/inputtino/mouse.py +106 -0
  69. package/engine/vendor/inputtino/bindings/python/src/inputtino/pentablet.py +73 -0
  70. package/engine/vendor/inputtino/bindings/python/src/inputtino/py.typed +0 -0
  71. package/engine/vendor/inputtino/bindings/python/src/inputtino/touchscreen.py +61 -0
  72. package/engine/vendor/inputtino/bindings/python/src/inputtino/trackpad.py +74 -0
  73. package/engine/vendor/inputtino/bindings/python/src/main.cpp +217 -0
  74. package/engine/vendor/inputtino/bindings/python/tests/__init__.py +0 -0
  75. package/engine/vendor/inputtino/bindings/python/tests/helpers.py +3 -0
  76. package/engine/vendor/inputtino/bindings/python/tests/test_base.py +60 -0
  77. package/engine/vendor/inputtino/bindings/python/tests/test_inputtino.py +5 -0
  78. package/engine/vendor/inputtino/bindings/python/tests/test_joypad.py +332 -0
  79. package/engine/vendor/inputtino/bindings/python/tests/test_keyboard.py +164 -0
  80. package/engine/vendor/inputtino/bindings/python/tests/test_mouse.py +185 -0
  81. package/engine/vendor/inputtino/bindings/python/tests/test_pentablet.py +198 -0
  82. package/engine/vendor/inputtino/bindings/python/tests/test_touchscreen.py +144 -0
  83. package/engine/vendor/inputtino/bindings/python/tests/test_trackpad.py +146 -0
  84. package/engine/vendor/inputtino/bindings/python/uv.lock +390 -0
  85. package/engine/vendor/inputtino/bindings/rust/Cargo.toml +6 -0
  86. package/engine/vendor/inputtino/bindings/rust/inputtino/.dockerignore +1 -0
  87. package/engine/vendor/inputtino/bindings/rust/inputtino/Cargo.toml +18 -0
  88. package/engine/vendor/inputtino/bindings/rust/inputtino/examples/keyboard.rs +33 -0
  89. package/engine/vendor/inputtino/bindings/rust/inputtino/examples/mouse.rs +17 -0
  90. package/engine/vendor/inputtino/bindings/rust/inputtino/src/common.rs +116 -0
  91. package/engine/vendor/inputtino/bindings/rust/inputtino/src/error.rs +17 -0
  92. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad.rs +74 -0
  93. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_nintendo.rs +135 -0
  94. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_ps5.rs +280 -0
  95. package/engine/vendor/inputtino/bindings/rust/inputtino/src/joypad_xbox.rs +134 -0
  96. package/engine/vendor/inputtino/bindings/rust/inputtino/src/keyboard.rs +76 -0
  97. package/engine/vendor/inputtino/bindings/rust/inputtino/src/lib.rs +32 -0
  98. package/engine/vendor/inputtino/bindings/rust/inputtino/src/mouse.rs +178 -0
  99. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/common.rs +38 -0
  100. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/joypads.rs +150 -0
  101. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/keyboard.rs +73 -0
  102. package/engine/vendor/inputtino/bindings/rust/inputtino/tests/mouse.rs +139 -0
  103. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/.dockerignore +1 -0
  104. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/Cargo.toml +12 -0
  105. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/build.rs +48 -0
  106. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/src/lib.rs +5 -0
  107. package/engine/vendor/inputtino/bindings/rust/inputtino-sys/wrapper.h +1 -0
  108. package/engine/vendor/inputtino/cmake/utils.cmake +9 -0
  109. package/engine/vendor/inputtino/docker/Dockerfile +70 -0
  110. package/engine/vendor/inputtino/include/inputtino/input.h +324 -0
  111. package/engine/vendor/inputtino/include/inputtino/input.hpp +466 -0
  112. package/engine/vendor/inputtino/include/inputtino/result.hpp +37 -0
  113. package/engine/vendor/inputtino/share/pkgconfig/libinputtino.pc.in +17 -0
  114. package/engine/vendor/inputtino/src/c-bindings/helpers.hpp +19 -0
  115. package/engine/vendor/inputtino/src/c-bindings/joypad_ps5.cpp +115 -0
  116. package/engine/vendor/inputtino/src/c-bindings/joypad_switch.cpp +63 -0
  117. package/engine/vendor/inputtino/src/c-bindings/joypad_xone.cpp +62 -0
  118. package/engine/vendor/inputtino/src/c-bindings/keyboard.cpp +42 -0
  119. package/engine/vendor/inputtino/src/c-bindings/mouse.cpp +67 -0
  120. package/engine/vendor/inputtino/src/c-bindings/pen_tablet.cpp +50 -0
  121. package/engine/vendor/inputtino/src/c-bindings/touchscreen.cpp +43 -0
  122. package/engine/vendor/inputtino/src/c-bindings/trackpad.cpp +49 -0
  123. package/engine/vendor/inputtino/src/uhid/README.adoc +63 -0
  124. package/engine/vendor/inputtino/src/uhid/include/crc32.hpp +38 -0
  125. package/engine/vendor/inputtino/src/uhid/include/uhid/protected_types.hpp +36 -0
  126. package/engine/vendor/inputtino/src/uhid/include/uhid/ps5.hpp +550 -0
  127. package/engine/vendor/inputtino/src/uhid/include/uhid/uhid.hpp +168 -0
  128. package/engine/vendor/inputtino/src/uhid/joypad_ps5.cpp +580 -0
  129. package/engine/vendor/inputtino/src/uinput/include/inputtino/keyboard.hpp +84 -0
  130. package/engine/vendor/inputtino/src/uinput/include/inputtino/protected_ps5_types.hpp +7 -0
  131. package/engine/vendor/inputtino/src/uinput/include/inputtino/protected_types.hpp +110 -0
  132. package/engine/vendor/inputtino/src/uinput/joypad_nintendo.cpp +190 -0
  133. package/engine/vendor/inputtino/src/uinput/joypad_ps.cpp +203 -0
  134. package/engine/vendor/inputtino/src/uinput/joypad_utils.hpp +246 -0
  135. package/engine/vendor/inputtino/src/uinput/joypad_xbox.cpp +190 -0
  136. package/engine/vendor/inputtino/src/uinput/keyboard.cpp +120 -0
  137. package/engine/vendor/inputtino/src/uinput/mouse.cpp +199 -0
  138. package/engine/vendor/inputtino/src/uinput/pentablet.cpp +162 -0
  139. package/engine/vendor/inputtino/src/uinput/touchscreen.cpp +140 -0
  140. package/engine/vendor/inputtino/src/uinput/trackpad.cpp +192 -0
  141. package/examples/reference-client.html +428 -0
  142. 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
+ }
@@ -0,0 +1,3 @@
1
+ import pytest
2
+
3
+ mark_practical = pytest.mark.practical
@@ -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()
@@ -0,0 +1,5 @@
1
+ import inputtino
2
+
3
+
4
+ def test_version():
5
+ assert isinstance(inputtino.__version__, str)