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

Unable to run examples #65

Open
medakk opened this issue Nov 8, 2021 · 3 comments
Open

Unable to run examples #65

medakk opened this issue Nov 8, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@medakk
Copy link

medakk commented Nov 8, 2021

Thanks for creating this library!

I'm having some trouble running the examples on Ubuntu 20.04, with kernel 5.11.0-38-generic. I paired my Joy-Con (R) via bluetooth.

$ dmesg
[   52.887339] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[   52.887344] Bluetooth: HIDP socket layer initialized
[   53.950876] hid-generic 0005:057E:2007.0007: unknown main item tag 0x0
[   53.951099] input: Joy-Con (R) as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:057E:2007.0007/input/input31
[   53.951471] hid-generic 0005:057E:2007.0007: input,hidraw4: BLUETOOTH HID v0.01 Gamepad [Joy-Con (R)] on c8:21:58:8e:32:ca

If I run cat /dev/input/js0 I can see that button presses are getting sent to my computer. However, the joycon-rs examples (for example scan_for_joycons) don't seem to recognize my joycon. There is no output and I can only close it with Ctrl+C

I also tried the "Receiving reports" example on the README.md and the same behaviour occurs there. Using a debugger, its stuck on the line managed_devices.into_iter()

I've also tried using the dkms-hid-nintendo kernel module, but I still can't get the library to work.

Do you have any pointers on what else I could try/check?

EDIT: to confirm the dkms HID nintendo kernel module works, I have verified with dmesg:

[ 1841.730027] input: Nintendo Switch Right Joy-Con as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:057E:2007.0009/input/input34
[ 1841.730617] input: Nintendo Switch Right Joy-Con IMU as /devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:256/0005:057E:2007.0009/input/input35

and two controllers(regulars controls, and IMU) show up in jstest-gtk

@medakk
Copy link
Author

medakk commented Nov 8, 2021

some more info: the hid_enumerate API just seems to not list the JoyCon

@KaiseiYokoyama KaiseiYokoyama added the help wanted Extra attention is needed label Nov 14, 2021
@KaiseiYokoyama
Copy link
Owner

I appreciate your report. @medakk 👍
Let me try reproducing the error.

But I have few experience of linux OS, it seems to be so difficult to solve this problem immidiately by myself.

@eduidl
Copy link

eduidl commented Dec 25, 2021

@KaiseiYokoyama @medakk

I succeeded in running examples on Ubuntu 20.04.
Here are the steps I took.

  1. Created a file /etc/udev/rules.d/50-nintendo-switch.rules, referencing the link
# 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"
  1. Applied udev rules
$ sudo udevadm control --reload-rules
$ sudo udevadm trigger
  1. Changed a backend of hidapi from libusb (default) to hidraw

Cargo.toml

-hidapi = "1.3"
+hidapi = { version = "1.3", features = ["linux-static-hidraw"], default-features = false }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants