feat(hid): native agent-free touch via CoreDevice universalhidservice (iOS 17+) - #835
Open
danielpaulus wants to merge 1 commit into
Open
feat(hid): native agent-free touch via CoreDevice universalhidservice (iOS 17+)#835danielpaulus wants to merge 1 commit into
danielpaulus wants to merge 1 commit into
Conversation
… (iOS 17+)
Add an `ios hid` command family that taps the device by sending raw HID
reports over RemoteXPC through the DDI's dtuhidd daemon — no WDA, no
DeviceKit, no XCUITest runner. Ports the touch path of pymobiledevice3's
com.apple.coredevice.hid.universalhidservice.
New package ios/hid:
- 58-byte mainTouchscreen report builder (report ID 0x09, surface 257),
unit-tested to the exact byte layout + coordinate/timestamp mapping.
- Tap = CONTACT + RELEASE via the plain {featureIdentifier,messageType,
payload} envelope (reuses ios.ConnectToXpcServiceTunnelIface + ios/xpc).
- Media-stream auth gate (displayservice / action.mediastreamstart): builds
the negotiatorOffer protobuf + binary plist (byte-for-byte matched against
Apple's captured Xcode template in a unit test), opens a kernel-UDP RTP
receiver on the host tunnel address, drains it, and holds the stream open
while touches are sent. `--raw` skips the gate.
CLI: `ios hid tap --x=<0-65535> --y=<0-65535> [--raw]`.
Empirical finding (iPhone 00008110..., iOS 26.5, newer DDI 27A5194q mounted):
raw HID taps are dropped (display never wakes) and the media-stream gate the
touch path depends on is refused by the device with CoreDeviceError 9021
"Remote control requires iOS 27.0 or later on this device." So native
agent-free touch is gated to iOS 27+ by Apple; the code is correct and
ready for iOS 27 devices. FractionToNormalized is exported so this can back
`ios remote` input once available.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Actually raw HID events work just fine on iOS 18, 26.5, 27. Not sure if it works on iOS 17 because I have no device to test. I have it implemented in a private repo |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
A new
ios hidcommand family that taps the device by sending raw HID reports over RemoteXPC through the Developer Disk Image'sdtuhidddaemon — no WebDriverAgent, no DeviceKit, no XCUITest runner. It ports the touch path of pymobiledevice3'scom.apple.coredevice.hid.universalhidservice.Coordinates are normalized UInt16 (0..65535,
32768= screen center). A tap is one CONTACT report followed by one RELEASE report to the mainTouchscreen surface (_ServiceID 257).New package
ios/hidhid.go): the exact 58-byte mainTouchscreen report (report ID0x09), unit-tested byte-for-byte plus coordinate/timestamp mapping.{featureIdentifier, messageType, payload}CoreDevice remote-feature envelope (same shape as the pasteboard/deviceinfo services), reusingios.ConnectToXpcServiceTunnelIface+ theios/xpcencoder. No RemoteXPC reinvented; the frozen dtx/testmanagerd/nskeyedarchiver code is untouched.mediastream.go+mediaoffer.go): portsdisplayservice/action.mediastreamstart. Builds thenegotiatorOfferprotobuf + binary plist (the video mediaBlob is verified byte-for-byte against Apple's captured Xcode template in a unit test), binds a kernel-UDP RTP receiver on the host's tunnel-side IPv6, drains the RTP, and holds the stream open while touches are sent (pymd3'stouch_sessionpattern).--rawskips the gate.Empirical finding (the important part)
Tested on the only iOS 26 device available:
00008110-001C58C00A88401E, iOS 26.5, on office01, over its persistent go-ios tunnel.The mounted DDI initially pinned by go-ios (
ddi-15F31d) is far too old to exposeuniversalhidserviceat all — it predatesdtuhidd. Mounting the modern personalized DDI (27A5194q, requires a reboot to swap) makescom.apple.coredevice.hid.universalhidserviceandcom.apple.coredevice.displayserviceappear in RSD, and thedtuhiddlaunchd plist confirms the exact service/feature names this code targets.Milestone 1 — raw taps (no media stream): dropped. Repeated taps across the whole screen produced zero observable change (byte-identical screenshots; the display never woke). Consistent with pymobiledevice3's documented gate.
Milestone 2 — media-stream gate: refused by the OS. The
startmediastreaminvoke is well-formed and reaches the daemon, which returns a specific CoreDevice error rather than a parse error:Conclusion: native agent-free HID touch is gated by Apple to iOS 27.0+. On iOS 26.5 the device itself refuses to open the media stream that authenticates the HID surfaces, so touches can't be routed to UIKit. This is an OS version gate, not a defect — the offer is accepted and parsed (specific version error, not "Invalid Parameter"), and the byte-for-byte template test confirms wire correctness. The command is ready to work on iOS 27 devices.
Options considered
--rawfor A/B testing per iOS build.userspaceTun:false), so a normal host socket is reachable by the device.Backing
ios remoteinputhid.FractionToNormalized(fraction→UInt16) is exported and tested so a futureios remotecan map click fractions straight to taps once it drives this package.Testing
go build ./...,go vet ./...,gofmt -l,go test ./...all clean.--rawsends cleanly and the gated path surfaces the iOS-27 error above.🤖 Generated with Claude Code