Node api for the xbox controller
As cli tool
$ [sudo] npm install xbox-ctrl -g
Programmatically
$ [sudo] npm install xbox-ctrl
$ xbox-ctrl 0.0.0 - Node api for the xbox controller
USAGE
xbox-ctrl <command> [options]
COMMANDS
off [controllers...] Turn off controllers
vibrate [controllers...] Vibrate controllers
list List connected controllers
help <command> Display help for a specific command
GLOBAL OPTIONS
-h, --help Display help
-V, --version Display version
--no-color Disable colors
--quiet Quiet mode - only displays warn and error messages
-v, --verbose Verbose mode - will also output debug messages
This module is exported as xbox-ctrl
and as xctrl
.
All the methods return a promise
import {list, build, off, offAll, vibrate, vibrateAll} from 'xbox-ctrl';
// list connected controllers
list(); // => [0, 1]
// build a controller instance for every connected controller
build(); // => [new Controller(0), new Controller(1)]
// turns off controller 1
off(1);
// turns off all controllers
offAll();
// vibrate controller 1
vibrate(1);
// vibrate all controllers
vibrateAll();
This module exports a Controller
class as well
import {Controller} from 'xbox-ctrl';
const controller = new Controller(1);
controller.vibrate();
controller.off();
Every method has a sync implementation as well, just add Sync
to the method name