gamepad.js icon indicating copy to clipboard operation
gamepad.js copied to clipboard

fix: support odd axes number

Open FezVrasta opened this issue 3 years ago • 1 comments

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.

FezVrasta avatar Jun 19 '22 11:06 FezVrasta

@Tom32i any chance you could take a look at this PR please?

FezVrasta avatar Jun 28 '22 16:06 FezVrasta

Hey sorry I didn't see the notice :(

Thank you for the fix, Is it still relevent?

Tom32i avatar Jan 26 '23 08:01 Tom32i

Yes definitely

FezVrasta avatar Jan 26 '23 10:01 FezVrasta

This means there is gamepads with 1 dimentional sticks?

Tom32i avatar Jan 26 '23 11:01 Tom32i

In our case it's a dictaphone, not a gamepad, but it gets exposed to the browser through the gamepad API.

FezVrasta avatar Jan 26 '23 11:01 FezVrasta

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?

Tom32i avatar Jan 26 '23 11:01 Tom32i

I'm not emulating it, it's a peripheral that is recognized as gamepad.

FezVrasta avatar Jan 26 '23 12:01 FezVrasta

Oh ok awesome. And you can confirm that your device only have one axis?

Tom32i avatar Jan 26 '23 12:01 Tom32i

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

FezVrasta avatar Jan 26 '23 12:01 FezVrasta

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.

Tom32i avatar Jan 26 '23 12:01 Tom32i

Do you need a new npm version with that fix?

Tom32i avatar Jan 26 '23 12:01 Tom32i

It'd be useful, thanks

FezVrasta avatar Jan 26 '23 12:01 FezVrasta

Here you go, v1.0.5 is available :)

Tom32i avatar Jan 26 '23 12:01 Tom32i