carldanley / node-gamepad

node-gamepad is a package for node that allows you to effortlessly interface your node applications with a variety of gamepad controllers.
82 stars 32 forks source link

Xbox controller support #1

Open andrew opened 10 years ago

andrew commented 10 years ago

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.

carldanley commented 10 years ago

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).

lukekarrys commented 10 years ago

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.

andrew commented 10 years ago

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

carldanley commented 10 years ago

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

@andrew that sucks!

carldanley commented 10 years ago

Any luck on this @barisbalic and @adamyeats?

carldanley commented 10 years ago

Any luck on this?

andrew commented 10 years ago

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

andrew commented 10 years ago

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 commented 10 years ago

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.