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

Allow passing only a platform to the constructor #6

Closed lukekarrys closed 10 years ago

lukekarrys commented 10 years ago

I think something like new GamePad(' snes ') would be nice, especially as more controllers get added. Then under the hood, it could look through all the config files in controllers/snes and see if any of them are available from HID.devices().

andrew commented 10 years ago

:+1: that sounds like a very handy shortcut

carldanley commented 10 years ago

agreed :+1:

I'll work on a patch for it tonight. I like that idea a lot, actually.

carldanley commented 10 years ago

Will this clash with https://github.com/carldanley/node-gamepad/issues/5 at all?

lukekarrys commented 10 years ago

I don't think we'll have the issues brought up in #5 since we don't automap anything. We rely on a user having a controller plugged in and knowing what that controller is and specifying it to the constructor.

I guess there could be an issue if there were NES and SNES Retrolink controllers plugged in and a user did new GamePad('snes') since the NES and SNES controllers have the same vendor/product IDs.

We could look at the output from HID.devices and if there are multiple values that would satisfy the requested platform, throw an error saying Please specify the full platform/vendor path. or something like that?

andrew commented 10 years ago

I don't think so, as long as you are specifying the name of the controller you'll know which mapping to use, #5 is about trying to guess which controller is plugged in.

carldanley commented 10 years ago

Take a look at https://github.com/carldanley/node-gamepad/commit/ec1cca7ba88e0fdaf01483217193feeb0030a3e9 and see if this looks good to you guys as far as automatically detecting a controller's product ID.

lukekarrys commented 10 years ago

Made a PR for the one issue I saw, other than that it looks great (I tested with SNES).

carldanley commented 10 years ago

:+1:

Thank you!