node-gamepad icon indicating copy to clipboard operation
node-gamepad copied to clipboard

Xbox controller support

Open andrew opened this issue 10 years ago • 9 comments

You could pull the mappings out of https://github.com/andrew/node-xbox-controller/blob/master/lib/buttons.json but it might be easier to require('xbox-controller') and wrap it in a helper function to reduce the amount of duplicate code.

andrew avatar Jun 02 '14 14:06 andrew

Can you take a crack at including a dictionary file for the xbox controller? You can use hid-mapper (by @lukekarrys) to generate the JSON file for you. Though, it might need some tweaking for joysticks (see https://github.com/lukekarrys/hid-mapper/issues/3).

I wanted to include a bunch of packages for each controller but if I did that for every controller we supported, we'd have a rather large dependency tree so I was trying to eliminate that. Also, by including the dictionary files we guarantee that the developer using node-gamepad will have access to the same events, no matter what controller they use (given the controller has support for those things).

carldanley avatar Jun 03 '14 02:06 carldanley

hid-mapper should have joystick support in the last version. I only tested it on my Retrolink N64 though. I can get my hands on an Xbox controller, and might try testing this soon.

lukekarrys avatar Jun 03 '14 19:06 lukekarrys

My rabbit chewed the cable on my 360 controller, paging @barisbalic and @adamyeats who both have 360 controllers I believe.

andrew avatar Jun 03 '14 20:06 andrew

@lukekarrys - I'll try with my PS3 dualshock3 controller tonight when I get back to the hotel.

@andrew that sucks!

carldanley avatar Jun 03 '14 20:06 carldanley

Any luck on this @barisbalic and @adamyeats?

carldanley avatar Jun 12 '14 06:06 carldanley

Any luck on this?

carldanley avatar Aug 31 '14 23:08 carldanley

I just ordered a replacement xbox 360 controller, I'll take a look at this when it arrives if no-one else does.

andrew avatar Sep 01 '14 08:09 andrew

Just giving this a try but hid-mapper doesn't seem to be able to handle the sensitivity of the xbox controller joysticks so the pin/value is different every time!

Will try to find some time to investigate but this new puppy is like a DDOS on my life so it might take me a few weeks to find a spare few hours.

andrew avatar Sep 06 '14 17:09 andrew

Thinking about it, I must have repressed the memory of reverse engineering the controller to find that the sticks return a signed 16 bit integer, see some funky conversion code here: https://github.com/andrew/node-xbox-controller/blob/master/lib/xbox.js#L318

I'm pretty sure most of the other controllers supported here only return 8 bit values for the controller positions.

andrew avatar Sep 06 '14 17:09 andrew