tomayac / joy-con-webhid

Use the Nintendo Switch Joy-Cons via the WebHID API
https://tomayac.github.io/joy-con-webhid/demo/
Apache License 2.0
139 stars 19 forks source link

NotAllowedError Failed to open the device #3

Closed derwehr closed 3 years ago

derwehr commented 3 years ago

When trying out any of the 2 demos, after clicking connect on the webBluetooth dialog, I always get the following Output in the Console:

HID connected: Joy-Con (L)

Uncaught (in promise) DOMException: Failed to open the device.

NotAllowedError Failed to open the device.
connectJoyCon @ index.js:42

(I did connect to JoyCon to my Computer via my computer's bluetooth settings before, otherwise they don't show up in the webBluetooth dialog.)

The JoyCon I'm using is brand-new and hasn't been connected to a switch before, do I have to install some kind of firmware on the JoyCon first or should the demos work with devices right out of the box?

tomayac commented 3 years ago

It may be that the controller needs a firmware update. Try connecting it to a Switch and checking for firmware updates. Can you then also try the demo linked from the article (Glitch seems to have a Bad Gateway issue at the moment) and let me know if it worked?

tomayac commented 3 years ago

(After connecting the controllers to the Switch, be sure to turn the Switch off or turn on airplane mode, else, the Switch won't let you connect to the controller with your computer and instead stay connected to it.)

derwehr commented 3 years ago

It may be that the controller needs a firmware update. Try connecting it to a Switch and checking for firmware updates. Can you then also try the demo linked from the article (Glitch seems to have a Bad Gateway issue at the moment) and let me know if it worked?

Thanks for the fast response. I get the same error on the demo mentioned above:

script.js:67 Uncaught (in promise) DOMException: Failed to open the device.
openButton.onclick @ script.js:67
async function (async)
openButton.onclick @ script.js:52

I'll try to get my hands on a switch to update the Joy-Cons firmware and give you an update then.

derwehr commented 3 years ago

The issue persisted after connecting my joy-cons to a switch and updating their firmware. However, I found out that this isa Linux issue. The Demo works fine on a windows machine.

tomayac commented 3 years ago

Thanks for updating the issue. In this case we can close it here, and you should report it as a new Linux issue. If you let me know the bug ID here, I can help triage.

derwehr commented 3 years ago

I figured out how to use the JoyCons on Linux. For anyone stumbling upon this: You have to configure a udev rule, making the JoyCons writable. To do so, follow the steps below.

  1. Create a file /etc/udev/rules.d/10-joycon.rules
  2. paste the following rules into it
    
    # Switch Joy-con (L) (Bluetooth only)
    KERNEL=="hidraw*", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2006.*", MODE="0666"

Switch Joy-con (R) (Bluetooth only)

KERNEL=="hidraw", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2007.", MODE="0666"

Switch Pro controller (USB and Bluetooth)

KERNEL=="hidraw", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0666" KERNEL=="hidraw", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2009.*", MODE="0666"

Switch Joy-con charging grip (USB only)

KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="200e", MODE="0666"


3. Save the file and reload udev rules using `sudo udevadm control --reload-rules`
tomayac commented 3 years ago

Thank you <3 for sharing the solution. I'll point to here from the README.