node-ds4
Stream events from DualShock 4 controllers. Works for Bluetooth & USB.
Supports:
- Left & right analog stick
- D-pad: up, down, left, right (also intermediate positions)
- Buttons: x, circle, square, triangle, share, options, (DS4) trackpad button
- Left & right analog triggers
- (DS4) 2 touches on the trackpad (X, Y, active, ID) & trackpad button
- Gryoscope (absolute orientation) & accelerometer (relative movement)
- Activating motors
- Changing LED color
- Battery status
Compared to the DS3 the DS4 dropped most pressure sensitive buttons. Only L2 and R2 are still also analog. PEW PEW! I guess someone had to make room for the trackpad...
TODO:
- Microphone/speaker magic
Install
$ npm install -g ds4
Usage
$ ds4-dump
Will dump decoded events to stdout.
var ds4 = ;var through = ;// controller is a node-hid HID object representing the controllerhid;
Example output frame:
leftAnalogX: 128leftAnalogY: 128rightAnalogX: 127rightAnalogY: 127l2Analog: 0r2Analog: 0dPadUp: falsedPadRight: falsedPadDown: falsedPadLeft: falsecross: falsecircle: falsesquare: falsetriangle: falsel1: falsel2: falser1: falser2: falsel3: falser3: falseshare: falseoptions: falsetrackPadButton: falsepsButton: falsemotionY: 0motionX: 1motionZ: -2orientationRoll: -145orientationYaw: 8155orientationPitch: 2089trackPadTouch0Id: 4trackPadTouch0Active: falsetrackPadTouch0X: 1513trackPadTouch0Y: 40trackPadTouch1Id: 0trackPadTouch1Active: falsetrackPadTouch1X: 0trackPadTouch1Y: 0timestamp: 36batteryLevel: 0
Emitting data:
var ds4 = ;ds4;
Caveat
As long as this is pre 1.0 I'll rename property names.
¯\_(ツ)_/¯
Thanks & References
- http://www.psdevwiki.com/ps4/Talk:DualShock_4 http://www.psdevwiki.com/ps4/DualShock_4
- @johndrinkwater protocol gist
- @rdepena node-dualshock-controller
LICENSE
MIT