gamepad.js
gamepad.js copied to clipboard
fix: support odd axes number
This makes the code work in case gamepad.axes.length is 1 or any other odd number. It will round it up to the closest integer as expected.
@Tom32i any chance you could take a look at this PR please?
Hey sorry I didn't see the notice :(
Thank you for the fix, Is it still relevent?
Yes definitely
This means there is gamepads with 1 dimentional sticks?
In our case it's a dictaphone, not a gamepad, but it gets exposed to the browser through the gamepad API.
Looks good to me. This makes me think maybe we should not expect axes to come by pair here.🤔
In your case, you're emulating a gamepad with only one axis that's right?
I'm not emulating it, it's a peripheral that is recognized as gamepad.
Oh ok awesome. And you can confirm that your device only have one axis?
I don't have access to it as it was reported by some customer, but I'm sure it reported a single axis. I suppose it was some kind of stick to allow scrolling up/down
Ok, that make sens. I'm gonna merge this PR. After that, I'll work on a small refactoring for a more clean support "odd" number of axis.
Do you need a new npm version with that fix?
It'd be useful, thanks
Here you go, v1.0.5 is available :)