Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.57 KB

README.md

File metadata and controls

29 lines (24 loc) · 1.57 KB

DualShock Library

NOTE: Please run npm install in node_modules/node-hid before using!

Documentation & Code Examples Coming Soon.

For now, here's a quick summary:

Install with npm install dualshock, then include with ds = require('dualshock')

Important Library Functions:

  • ds.getDevices(type) returns list of devices with given type
  • ds.open(device, options={}) opens device and returns gamepad object
  • ds.getType(gamepadOrDevice) returns gamepad type string (like "ds3" or "ds4")
  • ds.getFeatures(gamepad) returns list of special features (like "charge" or "rumble")

Important Gamepad Properties:

  • gamepad.ondigital callback to trigger when digital button is pressed
  • gamepad.onanalog callback when analog axis (or button) value is changed
  • gamepad.onmotion callback when controller motion is detected
  • gamepad.onstatus callback when battery level or other status information changes
  • gamepad.setLed(state) set controller leds. function is undefined if not supported
  • gamepad.setLed(one, two, three, four) set controller leds
  • gamepad.rumble(left, right, durL, durR) make controller rumble. function is undefined if not supported
  • gamepad.rumbleAdd(left, right, durL, durR) add power or duration to current rumble
  • gamepad.type same as ds.getType(gamepad), but shorter

All callback functions follow the format function(buttonOrAxis, value)

Examples:

To use the example program, cd to the examples folder and run the command node test. You'll need to install the npm module chalk.