dualsense_api 1.0.1
dualsense_api: ^1.0.1 copied to clipboard
Control a Sony DualSense (PS5) controller over USB on macOS via HIDAPI + Dart FFI: read sticks, triggers, buttons, battery and audio jack in real time, and command the lightbar color.
1.0.1 #
Bug fixes found in end-to-end testing against real hardware:
- Fix L3/R3 button mapping. They read bits
0x04/0x08of the button byte, which are actually the digital L2/R2 (set when the analog triggers are pulled). L3/R3 live in bits0x40/0x80. Pulling the triggers no longer reports L3/R3, and real stick clicks are now detected. - Fix
setLedColordoing nothing. The output report set feature flag byte 0 but not byte 1, whoseLIGHTBAR_CONTROL_ENABLE(0x04) bit is required for the controller to apply the RGB. The lightbar now changes. - Detect disconnection. The read loop now stops and signals listeners
(stream error) when
hid_readreturns an error (controller unplugged), instead of spinning silently — consumers can react instead of freezing.
1.0.0 #
- Initial release.
DualSenseBindings: FFI bindings tolibhidapi(hid_init,hid_open,hid_read,hid_write,hid_close,hid_get_product_string).DualSenseController: connects to the DualSense over USB, runs a background polling loop, exposes anonInputChangedstream with structural deduplication, andsetLedColor(r, g, b)for the lightbar.DualSenseState: immutable model with sticks, analog triggers, buttons, D-Pad, battery, charging state, and the 3.5mm audio jack.- Platform support: macOS (Apple Silicon, Homebrew).