Update VirtualHIDDevice client to v8 - #20
Conversation
|
Hi @malpern, Thanks again for contributing to driverkit!
|
|
Please also update the compilation command commented above the main function in driverkit.cpp to use c++23 |
|
And btw, I installed v8 and did minimal testing. |
Co-Authored-By: Codex <noreply@openai.com>
6d00e59 to
4b2bded
Compare
|
Thanks — I’ve incorporated the requested I also completed the broader runtime matrix in a disposable macOS 15.7.7 ARM VM against current upstream Kanata. Startup before and after daemon availability, keyboard and pointing readiness/report output, daemon loss while input was seized, input release while output was unavailable, in-process recovery, three repeated reconnects, and clean shutdown all passed. I updated the PR description to record the agreed protocol-7/v8 compatibility cut, |
|
Correction to the multiple-client note: the VM run did not demonstrate a v8 single-client limitation. The second Kanata process connected to the v8 daemon and reached keyboard and pointing output readiness. Its Both the v6 and v8 daemon sources maintain per-client entries. I have corrected the PR description and will keep disjoint-device multi-instance behavior as a focused regression scenario rather than describing simultaneous clients as unsupported. |
|
Completed the controlled v6/v8 comparison described above. Both versions supported two simultaneous Kanata output clients and recovered both clients after daemon restart. The same-device input-ownership warning was identical across versions, so it is not introduced by this migration. I’ve updated the PR description with the result. |
|
Thanks a lot for your effort, it's really appreciated :) |
## Summary - update `karabiner-driverkit` from 0.3.x to 0.4.0 - update the lockfile to the published 0.4.0 crate - document VirtualHIDDevice v8.0.0 as the supported macOS driver - document the protocol-7 compatibility cut from protocol-5/v6.2.0 ## Why Karabiner-Elements 16.1 uses VirtualHIDDevice v8. Kanata currently depends on the protocol-5 driverkit client and documents VirtualHIDDevice v6.2.0, so it cannot communicate with the current v8 daemon. `karabiner-driverkit` 0.4.0 adds the protocol-7/v8 client support. This intentionally updates Kanata to v8 rather than maintaining two IPC implementations. Users of the standalone v6.2.0 driver must upgrade the driver and Kanata together. Closes #2105. ## Runtime validation The driverkit migration was validated in a disposable macOS 15.7.7 ARM VM during psych3r/driverkit#20. The validated scenarios included: - startup before and after daemon availability - keyboard and pointing output readiness - daemon loss and in-process recovery - repeated reconnects - clean shutdown - two simultaneous output clients and recovery after daemon restart The controlled v6/v8 comparison found the same same-device exclusive-input behavior in both versions; it was not introduced by the v8 migration. ## Local checks - `cargo fmt --all --check` - `RUSTFLAGS="-Dwarnings" cargo build --all-targets` - `RUSTFLAGS="-Dwarnings" cargo test --all` - `RUSTFLAGS="-Dwarnings" cargo clippy --all -- -D warnings` - `RUSTFLAGS="-Dwarnings" cargo test --all --features=cmd` - `RUSTFLAGS="-Dwarnings" cargo clippy --all --features=cmd -- -D warnings` - `RUSTFLAGS="-Dwarnings" cargo build --release` - `RUSTFLAGS="-Dwarnings" cargo build --release --features=cmd`
Summary
driver_activated()This prepares the crate for a separate Kanata dependency update. The migration was developed and runtime-tested against current upstream Kanata, without relying on an application-specific fork.
Why
Karabiner-Elements 16.1 installs VirtualHIDDevice v8, while the current crate is built for the v6.2/protocol-5 client. Current Kanata builds using this crate therefore cannot communicate with the v8 daemon and repeatedly report
connect_failed asio.system:2.VirtualHIDDevice v7 changed IPC from local datagrams to Unix-domain streams, and v8 moved the client protocol to 7. Supporting both generations at runtime would require retaining two transports and client implementations. This PR intentionally targets v8 rather than adding that complexity.
Implementation notes
The v8 update required two wrapper changes beyond the submodule bump:
std::to_underlying.virtual_hid_device_service.hppno longer transitively includespqrs::osx::iokit_mach_port.The Rust-facing readiness, input release/re-grab, keyboard report, and pointing report APIs remain unchanged because v8 retains the client signals used by the wrapper.
Build and package validation
Using upstream
psych3r/driverkitmainatff62645as the base:cargo buildcargo testcargo build --all-targetscargo testcargo package --allow-dirty, including rebuilding from the packaged cratedist/installer archive; the resulting crate is approximately 6.7 MB compressedThe repository currently has no automated runtime tests, so
cargo testcontains zero unit tests.Runtime validation
Validated in a disposable macOS 15.7.7 ARM VM with:
activated enabledmainatc7978d4The following scenarios passed:
send_keyreturned success)During daemon loss, Kanata remained running, marked keyboard and pointing output unavailable, retried the connection, and restored both outputs after the daemon restarted.
Multiple-client validation
I repeated the same two-client scenario in separate disposable macOS 15.7.7 VMs using current upstream Kanata:
In both environments:
Both processes selected the VM's single available keyboard, so one received the expected macOS
exclusive access and device already openerror. Which process received it depended on startup order. This behavior was identical with v6 and v8 and is separate from VirtualHID output-client multiplexing.This comparison found no multi-client regression from the v6 datagram transport to the v8 Unix-domain stream transport.
Compatibility
This is an intentional compatibility cut:
Maintainer decisions
Based on maintainer feedback:
0.4.0is the appropriate version for the compatibility breakThe implementation and isolated runtime matrix are complete.