Skip to content

Add HIDP support#61

Merged
colemancda merged 10 commits into
masterfrom
feature/hidp
Jul 18, 2026
Merged

Add HIDP support#61
colemancda merged 10 commits into
masterfrom
feature/hidp

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

Adds Human Interface Device Protocol support via the kernel's HIDP module, turning the previously empty HIDP target into a working session-management layer:

  • HIDPSocket — control socket for kernel HID sessions: addConnection bridges connected L2CAP control (PSM 17) and interrupt (PSM 19) sockets into a kernel input device, passing the HID report descriptor, parser version, device identity (vendor/product/version), name, flags, and idle timeout; removeConnection destroys a session; connections() lists active sessions; connectionInformation(for:) queries a single device.
  • Ioctl wrappers for all four operations (the identifiers already existed in HIDPIO but had no request types). The add request embeds a pointer to the caller's report descriptor buffer, and the connection list embeds a pointer to a caller-allocated array — both wired internally with the buffers kept alive for the duration of the call.
  • C interop structures matching the kernel ABI, including the fixed 128-byte device name buffers (modeled as 32-bit words to preserve C alignment) and little-endian device addresses.
  • Value typesHIDPConnectionFlag (virtual cable unplug, boot protocol mode), HIDPConnectionState, and a public HIDPConnection info struct.

Together with the classic L2CAP conveniences (#58), this enables HID hosting without a daemon; fetching the report descriptor via service discovery remains a follow-up.

Test plan

  • 7 new unit tests using the syscall mocking driver: ioctl request codes asserted against exact kernel values, struct memory layouts asserted against the C ABI (168/12/148/16 bytes), faked kernel replies for add connection (including report descriptor pointer contents), connection list, and connection information, and device name encoding round-trips with truncation
  • Full test suite passes
  • swift build succeeds with no new warnings
  • Live sessions require Linux with the kernel HIDP module and CAP_NET_ADMIN (root)

@colemancda
colemancda merged commit 706cd38 into master Jul 18, 2026
1 check failed
@colemancda
colemancda deleted the feature/hidp branch July 18, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant