Tom32i/gamepad.js

exception handling for unsupported HID devices

wtip opened this issue · 4 comments

wtip commented

I have a Xbox 360 Controller and Jabra Speak 710 plugged into my computer.
When I visit the http://tom32i.github.io/gamepad.js/ page I get the follow error in the console.

GamepadHandler.js:117 Uncaught TypeError: Cannot read property '0' of undefined
    at GamepadHandler.updateStick (GamepadHandler.js:117)
    at GamepadHandler.update (GamepadHandler.js:81)
    at GamepadListener.discover (GamepadListener.js:98)
    at GamepadListener.update (GamepadListener.js:86)
    at Loop.update (Loop.js:46)

The Jabra Speak 710 device shows up as a gamepad in Slot 1 but does not have any buttons or sticks.
There needs to be some exception handling so that no handler is registered for the Jabra device.

image

Thanks for reporting this.
The code "assumed" that two sticks were available wich is not always the case.
I juste published a new version 1.0.2 that fix this problem.

Could you try your Jabra Speak 710 again on http://tom32i.github.io/gamepad.js/ and confim that you dont get the error anymore? Thanks.

wtip commented

I'm still getting the error on http://tom32i.github.io/gamepad.js/
Did you update the gh-pages branch?

@wtip Sorry I forgot 😓

I just updated the gh-pages branch, can you try it now?

wtip commented

@Tom32i It works great now. Thanks for the quick fix!!