GithubHelp home page GithubHelp logo

nucliweb / node-xbox-controller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrew/node-xbox-controller

0.0 2.0 0.0 143 KB

:video_game: Interface for Xbox 360 game controller into Node.js

Home Page: http://libraries.io/npm/xbox-controller

License: MIT License

JavaScript 100.00%

node-xbox-controller's Introduction

Interface for Xbox 360 game controller into Node.js

Lots of low level details about the controller here:

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

Usage

var XboxController = require('./lib/xbox');
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) 2015 Andrew Nesbitt. See LICENSE for details.

node-xbox-controller's People

Contributors

andrew avatar bolbola avatar divanvisagie avatar neocotic avatar chiefcll avatar ericsmekens avatar gordonturner avatar alspore avatar stewart avatar ianwitherow avatar nucliweb avatar ertrzyiks avatar rwaldron avatar

Watchers

James Cloos avatar  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.