andrew/node-xbox-controller

filter non-xbox controllers

Closed this issue · 2 comments

some non-xbox contollers (ex: dualshock3 or dualshock4) are detected as native xbox controllers.

screen shot 2015-03-15 at 00 45 34
if would be nice to have a filtering option.

img_0002

also it would be great if i could use multiple xbox controllers for a multi player setup.

according to HID.devices() we could use the serialNumber

  • to filter a specific controller
var myController = new XboxController('70623960');
  • to init multiple controllers
var player1 = new XboxController('A4DE0760');
var player2 = new XboxController('70623960');

all devices

[ { vendorId: 1118,
    productId: 654,
    path: 'Wireless_045e_028e_4100002',
    serialNumber: 'A4DE0760',
    manufacturer: 'Microsoft',
    product: 'Wireless 360 Controller',
    release: 0,
    interface: -1,
    usagePage: 1,
    usage: 5 },
  { vendorId: 1118,
    productId: 654,
    path: 'Wireless_045e_028e_4100001',
    serialNumber: '70623960',
    manufacturer: 'Microsoft',
    product: 'Wireless 360 Controller',
    release: 0,
    interface: -1,
    usagePage: 1,
    usage: 5 } ]

that's also valid for DualShock controllers
(note: the Unknown manufacturer is actually Sony (DS4)

[ { vendorId: 1356,
    productId: 616,
    path: 'Bluetooth_054c_0268_75517eb7',
    serialNumber: '00-06-f5-51-7e-b7',
    manufacturer: 'Sony',
    product: 'PLAYSTATION(R)3 Controller',
    release: 256,
    interface: -1,
    usagePage: 1,
    usage: 4 } ]
[ { vendorId: 1356,
    productId: 1476,
    path: 'Bluetooth_054c_05c4_5aad1995',
    serialNumber: '1c-96-5a-ad-19-95',
    manufacturer: 'Unknown',
    product: 'Wireless Controller',
    release: 256,
    interface: -1,
    usagePage: 1,
    usage: 5 } ]

something similar was already coded by @barisbalic on multiple-controllers branch.

it would be great to have this commit d910af8 tested and merged into master branch.

thank you!

update

it might be possible that a HID controller connected via USB cable not to have a serialNumber in HID.devices().

since DualShock controllers can work via Bluetooth or USB cable I was able to make a test with a DS3 connected via Bluetooth and a DS4 connected via USB cable.

[ { vendorId: 1356,
    productId: 616,
    path: 'Bluetooth_054c_0268_75517eb7',
    serialNumber: '00-06-f5-51-7e-b7',
    manufacturer: 'Sony',
    product: 'PLAYSTATION(R)3 Controller',
    release: 256,
    interface: -1,
    usagePage: 1,
    usage: 4 } ]
[ { vendorId: 1356,
    productId: 1476,
    path: 'USB_054c_05c4_4100000',
    serialNumber: '',
    manufacturer: 'Sony Computer Entertainment',
    product: 'Wireless Controller',
    release: 256,
    interface: -1,
    usagePage: 1,
    usage: 5 } ]

the same is also valid for a non-xbox or a non-ds USB controller.

  { vendorId: 3727,
    productId: 18,
    path: 'USB_0e8f_0012_26220000',
    serialNumber: '',
    manufacturer: 'GreenAsia Inc.',
    product: 'USB  Joystick',
    release: 263,
    interface: -1,
    usagePage: 1,
    usage: 4 },

having this said maybe a better idea is to use a filter by vendorId and path or only by path.

  • Wireless_045e_028e_26210002
[ { vendorId: 1118,
    productId: 654,
    path: 'Wireless_045e_028e_26210002',
    serialNumber: '70623960',
    manufacturer: 'Microsoft',
    product: 'Wireless 360 Controller',
    release: 0,
    interface: -1,
    usagePage: 1,
    usage: 5 }
  • Wireless_045e_028e_26210001
  { vendorId: 1118,
    productId: 654,
    path: 'Wireless_045e_028e_26210001',
    serialNumber: 'A4DE0760',
    manufacturer: 'Microsoft',
    product: 'Wireless 360 Controller',
    release: 0,
    interface: -1,
    usagePage: 1,
    usage: 5 } ]

I'm no longer supporting this library as I don't use it any longer so I'm going to close this issue.