npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xbox-hid-controller

v0.0.0

Published

Original Xbox Controller API using node-hid HID device

Downloads

3

Readme

Xbox HID Controller

Original Xbox Controller API using node-hid HID device

Usage

First, you require the module, and run listControllers to get a list of HID devices that look like on Original Xbox Controller. The array returned is a filtered version of HID.devices() from the node-hid module.

Then, you create an XboxController object, which is a subclass of HID.HID, and subscribe to the values event emitted. Events will be emitted whenever the state of the controller changes.

var xhc = require('xbox-hid-controller');

var controllers = xhc.listControllers();
console.log(controllers);

var controller = new xhc.XboxController(controllers[0].path);
controller.on('values', function(values) {
  console.log(values);
});
[ { vendorId: 1118,
    productId: 645,
    path: 'USB_045e_0285_fd121000',
    serialNumber: '',
    manufacturer: 'Unknown Third-Party',
    product: 'Xbox Controller',
    release: 256,
    interface: -1 } ]
{ up: 0,
  down: 0,
  left: 0,
  right: 0,
  start: 0,
  back: 0,
  las: 0,
  ras: 0,
  a: 0,
  b: 0,
  x: 0,
  y: 0,
  black: 0,
  white: 0,
  ltrigger: 0,
  rtrigger: 0,
  lasX: 896,
  lasY: -1228,
  rasX: 0,
  rasY: 413 }
{ up: 0,
  down: 0,
  left: 0,
  right: 0,
  start: 0,
  back: 0,
  las: 0,
  ras: 0,
  a: 0,
  b: 0,
  x: 0,
  y: 0,
  black: 0,
  white: 0,
  ltrigger: 0,
  rtrigger: 0,
  lasX: 1344,
  lasY: -1228,
  rasX: 0,
  rasY: 413 }
...

API

xhc.listControllers([product])

List all HID devices that look like Xbox Controllers.

  • product: the name to use to filter the list of HID devices, defaults to Xbox Controller

xhc.listAll()

List all HID devices. Same as HID.devices()

new XboxController(path)

Create a new XboxController object that emits values events whenever the controllers state is changed.

  • Event vaules: emitted whenever the controllers state is changed, contains information about the buttons pressed and axis moved

Because this class is a subclass of HID.HID from node-hid, you can also subscribe to the events emitted directly by this object.

  • Event error: any possible error with the HID device
  • Event data: the raw data buffer from the device, this is parsed for you and emitted in a nicer form with the values event

Installation

npm install xbox-hid-controller

To use the tools in the examples/ directory, you must install the dev dependencies from npm

git clone git://github.com/bahamas10/node-xbox-hid-controller.git
cd node-xbox-hid-controller
npm install
npm install -d

Mac OS X

You must first installed this driver http://xhd.sourceforge.net/ for the original Xbox controller to be recognized by OS X.

If you are running Mountain Lion, Mavericks, or above, you need to download this version of the driver specifically for it to work http://macman860.wordpress.com/2013/05/03/xbox-driver-for-mac-os-x-lion/

License

MIT