-
Notifications
You must be signed in to change notification settings - Fork 9
Configuration Guide
#Xbox Controller Configuration Guide
Wiki of xbox-controller-node configuration and parametrization.
If the button commands coming wrong you can configure your own controller interface.
var xbox = require('xbox-controller-node');
xbox.configure();This will launch a server page on browser to you configure your controller. The page will be available on http://localhost:3000.
The configuration is very simple. Just click on any box and hold the correspondent button until the box lose focus. After all boxes filled click on "Save configuration" and it's done. Just restart your application and now your config is active.
If you connect your xbox controller and the interface does not recognize it, or on the configuration page you press the buttons and no command is sent, see the Parametrization steps.
##Parametrization If you connect your xbox controller and even this had an
Error: Xbox controller not foundor on config page no commands are sent, you can parameterize your Xbox Controller Interface using the constructor CreateController(HIDInfo).
###Find your controller
xbox-controller-node use node-hid to recive the controller data and emit it in events. node-hid is a interface to access USB HID devices build on Nodejs. Read more about node-hid.
xbox-controller-node uses the HID product name to find your controller.
var xbox = require('xbox-controller-node');
xbox.listHIDDevices();This method will list all HID devices connected in your computer. The return of this will be like:
[{ vendorId: 1118,
productId: 673,
path: '\\\\?\\hid#vid_045e&pid_02a1&ig_00#7&1e27c39e&0&0000#{4d1e55b2-f16f-1
1cf-88cb-001111000030}',
product: 'Controller (Xbox 360 Wireless Receiver for Windows)',
release: 0,
interface: -1,
usagePage: 1,
usage: 5 },
{ vendorId: 1118,
productId: 1970,
path: '\\\\?\\hid#vid_045e&pid_07b2&mi_02&col02#8&173ae064&0&0001#{4d1e55b2-
f16f-11cf-88cb-001111000030}',
manufacturer: '',
product: '',
release: 1796,
interface: 2,
usagePage: 12,
usage: 1 }]By default the keyword to find a Xbox controller is controller. So, the example controller is found with no problems. If your controller was not found you can use a constructor passing the product name as parameter.
var xbox = require('xbox-controller-node');
var customXbox = xbox.CreateController({
product: 'Xbox'
});Try to run the customXbox.configure() and take a look if the button commands are coming. If don´t you will have to parameterize the Buffer blocks of your controller.
###Parameterize Buffer blocks
A HID device send a Buffer data. But what is that? "A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap". See the complete Buffer documentation.
So if you are not receiving data on config page probably the columns "blocks" analized are wrong. By default the block for direcional buttons (up, down, left) is 11 and the control buttons (a, b, rb, start) is 10.
var xbox = require('xbox-controller-node');
var customXbox = xbox.CreateController({
product: 'Xbox'
});
customXbox.HIDController.on('data', function (data) {
console.log(data);
});The data event will listen any data sent by the controller and log it. Analize which column "block" change when you press each group of buttons. If the columns are different change them in the constructor of your custom xbox controller config.
var xbox = require('xbox-controller-node');
var customXbox = xbox.CreateController({
product: 'Xbox',
config: {
controlBtnsBlock: 9,
directionalBtnsBlock: 4
}
});After this, run the configure() method to customize your Interface. See the Conguration steps.