Skip to content

Commit 8d85dbf

Browse files
Add touchscreen/trackpad/pen-tablet device support
Introduce first-class touchscreen, trackpad, and pen-tablet device types across the library. Public API: new DeviceType entries, DeviceNode reporting, Create*Options, creation results, and Runtime create_touchscreen/create_trackpad/create_pen_tablet overloads. Runtime/VirtualDevice: new Touchscreen/Trackpad/PenTablet handle classes with submit APIs (place_contact/release_contact/button/place_tool/button) and device_nodes accessors. Backend: new BackendTouchscreen/BackendTrackpad/BackendPenTablet interfaces, backend creation results, device_nodes hooks, and in-memory Fake* backends for tests; default in-memory backend capability flags updated. Profiles/reports: add DualSense USB/Bluetooth profiles, USB descriptor, report packing/parsing helpers, and parse_output_reports API; also add generic touchscreen/trackpad/pen-tablet built-in profiles. Types: add DeviceNode/DeviceNodeKind, touch/pen structures, battery/motion types, gamepad touch contact, auto-repeat interval, and various enums/fields required by new devices and DualSense features. Docs/tests: update README with Phase 2B notes and new device types; update unit tests accordingly.
1 parent 29116b7 commit 8d85dbf

18 files changed

Lines changed: 3187 additions & 38 deletions

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,13 @@ Expected core types:
212212
- `Keyboard`: key press/release and UTF-8 text submission.
213213
- `Mouse`: relative motion, absolute motion, button, vertical scroll, and
214214
horizontal scroll submission.
215+
- `Touchscreen`: direct multi-touch contacts for touch displays.
216+
- `Trackpad`: indirect multi-touch contacts and click state for touchpads.
217+
- `PenTablet`: tablet tool, pressure, distance, tilt, and pen button state.
215218
- `DeviceProfile`: VID/PID, product strings, bus type, HID descriptor, report
216219
layout, and platform capability metadata.
220+
- `DeviceNode`: platform-reported device nodes and sysfs paths for consumers
221+
that must hand created devices to SDL, libinput, HIDAPI, or diagnostics.
217222
- `GamepadState`: normalized buttons, axes, triggers, hats, motion sensors, and
218223
optional touchpad data.
219224
- `GamepadOutput`: normalized rumble, haptics, LEDs, adaptive triggers, and raw
@@ -247,10 +252,21 @@ the requirements expressed in terms that apply to other consumers:
247252
- [x] Keyboard and mouse APIs should map cleanly to common relative mouse,
248253
absolute mouse, buttons, scroll, horizontal scroll, keyboard scancode, and
249254
Unicode paths.
255+
- [ ] Linux keyboard support must include configurable auto-repeat for held keys
256+
so streaming hosts can preserve input behavior previously covered by
257+
inputtino.
258+
- [ ] Linux devices must expose created device nodes and relevant sysfs paths
259+
for consumers and diagnostics that need to inspect or pass those paths onward.
250260
- [x] Linux fallback behavior should match streaming-host operational
251261
expectations:
252262
prefer real virtual devices through `uhid`/`uinput`; only use XTest for
253263
keyboard/mouse when virtual device creation fails and X11 is available.
264+
- [ ] Linux gamepad support must reach inputtino parity before replacement:
265+
real DualSense UHID descriptors, GET_REPORT replies, periodic input reports,
266+
touchpad, motion, battery, RGB LED, adaptive trigger callbacks, CRC handling,
267+
and uinput force-feedback handling where a uinput gamepad path is used.
268+
- [ ] Linux pointer support must cover touchscreen, trackpad, and pen tablet
269+
virtual devices with libinput-observable behavior.
254270
- [x] The library must not own a consumer's network protocol, client packet
255271
parsing, configuration system, or feedback queue. It should expose the device
256272
primitives consumers need to keep that ownership in their applications.
@@ -327,6 +343,31 @@ third-party/googletest/ GoogleTest submodule
327343
through SDL2 for gamepads and libinput for keyboard/mouse.
328344
- [x] Document required Linux permissions and sample udev rules.
329345

346+
### Phase 2B: Linux inputtino Parity
347+
348+
- [ ] Replace the generic DualSense profile behavior with a real UHID DualSense
349+
backend path, including USB/Bluetooth descriptors, MAC/uniq identity,
350+
calibration, pairing, firmware, CRC, and periodic report handling.
351+
- [ ] Add DualSense input state for motion sensors, touchpad contacts, battery
352+
state, and profile-specific buttons without leaking Linux-specific details
353+
into consumers.
354+
- [ ] Parse DualSense output reports into rumble, RGB LED, adaptive trigger, and
355+
raw-report callbacks.
356+
- [ ] Expose created device nodes and sysfs paths through the platform-neutral
357+
public API.
358+
- [ ] Add configurable keyboard auto-repeat for held keys.
359+
- [ ] Add touchscreen, trackpad, and pen tablet public device types and Linux
360+
uinput/libevdev backend implementations.
361+
- [ ] Add uinput force-feedback event handling for any uinput-backed gamepad
362+
path, including uploaded effect tracking and gain handling.
363+
- [ ] Prefer libevdev for uinput device construction where it removes fragile
364+
direct ioctl setup, while keeping the public API unchanged.
365+
- [ ] Expand Linux consumer tests so SDL2 validates controller-specific behavior
366+
and libinput validates keyboard, mouse, touchscreen, trackpad, and pen tablet
367+
events.
368+
- [ ] Defer C, Python, and Rust bindings until after the platform API is stable,
369+
likely after macOS support lands.
370+
330371
### Phase 3: Windows MVP
331372

332373
- [ ] Build a UMDF2 HID minidriver package with CMake/WDK integration.

include/libvirtualhid/profiles.hpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,24 @@ namespace lvh::profiles {
4444
/**
4545
* @brief Create the PlayStation DualSense-compatible gamepad profile.
4646
*
47-
* @return DualSense-compatible device profile.
47+
* @return Default DualSense-compatible device profile.
4848
*/
4949
DeviceProfile dualsense();
5050

51+
/**
52+
* @brief Create the USB PlayStation DualSense-compatible gamepad profile.
53+
*
54+
* @return USB DualSense-compatible device profile.
55+
*/
56+
DeviceProfile dualsense_usb();
57+
58+
/**
59+
* @brief Create the Bluetooth PlayStation DualSense-compatible gamepad profile.
60+
*
61+
* @return Bluetooth DualSense-compatible device profile.
62+
*/
63+
DeviceProfile dualsense_bluetooth();
64+
5165
/**
5266
* @brief Create the Nintendo Switch Pro-compatible gamepad profile.
5367
*
@@ -69,6 +83,27 @@ namespace lvh::profiles {
6983
*/
7084
DeviceProfile mouse();
7185

86+
/**
87+
* @brief Create the generic touchscreen profile.
88+
*
89+
* @return Generic touchscreen device profile.
90+
*/
91+
DeviceProfile touchscreen();
92+
93+
/**
94+
* @brief Create the generic trackpad profile.
95+
*
96+
* @return Generic trackpad device profile.
97+
*/
98+
DeviceProfile trackpad();
99+
100+
/**
101+
* @brief Create the generic pen tablet profile.
102+
*
103+
* @return Generic pen tablet device profile.
104+
*/
105+
DeviceProfile pen_tablet();
106+
72107
/**
73108
* @brief Look up a built-in gamepad profile by kind.
74109
*

include/libvirtualhid/report.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,13 @@ namespace lvh::reports {
7979
*/
8080
GamepadOutput parse_output_report(const DeviceProfile &profile, const std::vector<std::uint8_t> &report);
8181

82+
/**
83+
* @brief Parse a backend output report into zero or more profile-neutral output events.
84+
*
85+
* @param profile Device profile used for report identity and capabilities.
86+
* @param report Raw HID output report bytes.
87+
* @return Parsed gamepad outputs. Unrecognized reports are returned as one raw-report event.
88+
*/
89+
std::vector<GamepadOutput> parse_output_reports(const DeviceProfile &profile, const std::vector<std::uint8_t> &report);
90+
8291
} // namespace lvh::reports

0 commit comments

Comments
 (0)