Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Controllers #68

Open
tlee732 opened this issue Apr 17, 2017 · 1 comment
Open

Multiple Controllers #68

tlee732 opened this issue Apr 17, 2017 · 1 comment

Comments

@tlee732
Copy link

tlee732 commented Apr 17, 2017

I'm trying to connect multiple dual-shock controllers but can't find where the HID is being implemented. I want to search for HID devices, and create new controllers based on path.

@rdepena
Copy link
Owner

rdepena commented Apr 18, 2017

Hey @tlee732, I did not think to add multiple controller support. The following are the connecting pieces that the library uses to choose the device to connect to:

[The config has a vendorId Device Id combo] (https://github.com/rdepena/node-dualshock-controller/blob/master/controllerConfigurations/dualShock4.json#L2)

That is used to query the list of connected devices, Actual filter function.

The filter function could be modified to accept a path as well but you would have to know the path and feed it to the library.

marxarelli added a commit to marxarelli/node-dualshock-controller that referenced this issue Apr 3, 2020
Refactor use of globals in config module in favor of `Config` object
instances that can be encapsulated by each `Controller`, avoiding race
conditions when doing multiple async instantiations.

Introduce `index` controller option that specifies which of the
discovered HID devices for the given controller config (those matching
product and vendor IDs) to use.

Example:

    let
      ds1 = dualShock({ config: "dualshock4", index: 0 }),
      ds2 = dualShock({ config: "dualshock4", index: 1 }),
      ds3 = dualShock({ config: "dualshock3", index: 0 });
marxarelli added a commit to marxarelli/node-dualshock-controller that referenced this issue Apr 3, 2020
Removed use of global config module in favor of `Config` objects that
can be encapsulated by each `Controller` instance, allowing distinct
instantiations of the latter and avoiding race conditions should
instantiation take place within async events.

Introduced `index` controller option that specifies which of the
discovered HID devices (matched vendor and product ID) to use for the
given controller config.

Example:

    let
      ds1 = dualShock({ config: "dualshock4", index: 0 }),
      ds2 = dualShock({ config: "dualshock4", index: 1 }),
      ds3 = dualShock({ config: "dualshock3", index: 0 });
marxarelli added a commit to marxarelli/node-dualshock-controller that referenced this issue Apr 3, 2020
Removed use of global config module in favor of `Config` objects that
can be encapsulated by each `Controller` instance, allowing distinct
instantiations of the latter and avoiding race conditions should
instantiation take place within async events.

Introduced optional `index` option that specifies which of the
discovered HID devices (matched vendor and product ID) to use for the
given controller config. Note that discovered controllers are sorted by
device path before assignment to ensure consistency in selection.

Exposed `Controller` as part of the core module to make multiple
instantiation seem more clear. However, the original `dualShock`
entry-point function was left for backwards compatibility.

Example:

    var ds = require('dualshock-controller');

    var
      ds1 = new ds.Controller({ config: "dualshock4", index: 0 }),
      ds2 = new ds.Controller({ config: "dualshock4", index: 1 }),
      ds3 = new ds.Controller({ config: "dualshock3", index: 0 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants