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-controller

v0.7.4

Published

Xbox controller for node

Downloads

63

Readme

Node Xbox Controller

npm version Dependency Status devDependency Status Gitter

Interface for Xbox 360 game controller into Node.js

Lots of low level details about the controller here:

  • http://free60.org/GamePad
  • http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/UsbInfo
  • http://euc.jp/periphs/xbox-controller.ja.html

Mac OSX driver: for Lion/Snow Leopard or for Yosemite

Install

npm install xbox-controller

Usage

var XboxController = require('xbox-controller');
var xbox = new XboxController;

xbox.on('a:press', function (key) {
  console.log(key + ' press');
});

xbox.on('b:release', function (key) {
  console.log(key+' release');
});

xbox.on('lefttrigger', function(position){
  console.log('lefttrigger', position);
});

xbox.on('righttrigger', function(position){
  console.log('righttrigger', position);
});

xbox.on('left:move', function(position){
  console.log('left:move', position);
});

xbox.on('right:move', function(position){
  console.log('right:move', position);
});

xbox.on('connected', function(){
  console.log('Xbox controller connected');
});

xbox.on('not-found', function(){
  console.log('Xbox controller could not be found');
});

Also see the example.js for usage.

LEDs

Set LED pattern on controller:

xbox.setLed(0x0A);

Available LED patterns:

0x00   All off
0x01   All blinking
0x02   1 flashes, then on
0x03   2 flashes, then on
0x04   3 flashes, then on
0x05   4 flashes, then on
0x06   1 on
0x07   2 on
0x08   3 on
0x09   4 on
0x0A   Rotating (e.g. 1-2-4-3)
0x0B   Blinking*
0x0C   Slow blinking*
0x0D   Alternating (e.g. 1+4-2+3), then back to previous*

Rumble

Control left and right rumble motors:

var leftStrength = 255;
var rightStrength = 255;

xbox.rumble(leftStrength, rightStrength);

Where the strengths are between 0 and 255.

Within function

Listen for when a trigger or stick's position is within a particular range:

xbox.within('righttrigger', [50,100], function(err, data){
	console.log('rightttrigger within 50 and 100', err, data);
});

Multiple Devices

On startup, if a device is in use, it will be skipped and the next available device will be used. The serial number and path will be printed to the console for debugging.

Use the printed serial number to specifically address devices if required, see Serial Numbers below.

Serial Numbers

Each device has own serial number. On startup, the serial number of the device detected will be printed to the console.

To use a specific serial number, specify it when creating the controller:

var xbox = new XboxController('9BB004D0');

If you have a third party controller without 'controller' in the name, specify the device serial number to use that device.

Configuring a Third Party Controller

To configure a third party controller:

XboxController.configure();

Copyright

Copyright (c) 2016 Andrew Nesbitt. See LICENSE for details.