Coder Social home page Coder Social logo

lewy20041 / dualshock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pecacheu/dualshock

0.0 0.0 0.0 90 KB

Node.js module for DualShock (3 and 4) controllers.

License: GNU General Public License v3.0

JavaScript 16.78% C++ 2.71% Python 0.12% C 80.40%

dualshock's Introduction

DualShock Library

Now Supports:

  • DS4 led/rumble/trackpad even over bluetooth!
  • DS4 internal speaker & headphone/headset jack!

Documentation & Code Examples Coming Soon.

For now, here's a quick summary:

Install with npm install dualshock --global-style, 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. DS4 takes (r, g, b) instead
  • gamepad.setLed(one, two, three, four) alt 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
  • gamepad.setVolume(left, right, mic, spk) set volume of DS4
  • gamepad.sound(data) write sound to DS4. use int16 44100Hz audio. Will be converted to 32000Hz and compressed.

NOTE: gamepad.sound can take an optional second parameter that determines the maximum buffer size when the function is called for the first time.

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.

dualshock's People

Contributors

pecacheu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.