-
Notifications
You must be signed in to change notification settings - Fork 14
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
Nintendo Joycon gyro/accelerometer support #39
Comments
@medakk Thanks for opening this issue! /dev/input/js0 and /dev/input/js1 are the old Linux API for joysticks, and stick depends on the new Linux api, evdev. I believe there should be an equivalent for gyroscope and accelerometer for evdev - but I don't know what that would be. Have you tested it with the stick example program to see if it prints anything out? edit: sorry, just realized you said you are using the haptic example program. But just verifying it doesn't print anything out for those events? |
correct. the haptic example doesn't print out anything for those events. I modified the example slightly to print out all events: match event {
Event::Disconnect => {
self.controllers.swap_remove(id);
}
Event::MenuR(true) => return Ready(player),
Event::ActionA(pressed) => {
self.controllers[id].rumble(f32::from(u8::from(pressed)));
}
Event::ActionB(pressed) => {
self.controllers[id].rumble(0.5 * f32::from(u8::from(pressed)));
}
Event::BumperL(pressed) => {
self.rumble.0 = f32::from(u8::from(pressed));
self.controllers[id].rumble(self.rumble);
}
Event::BumperR(pressed) => {
self.rumble.1 = f32::from(u8::from(pressed));
self.controllers[id].rumble(self.rumble);
}
other => {
dbg!(other);
}
} but there is no events for the gyroscope and accelerometer. EDIT: Button presses are detected and rumble works I wasn't aware that js is the old API. I can confirm that the gyro works in the jstest-gtk app. According to dmesg, it might be showing up as two different controllers:
I'm unfamiliar with async in rust, but does the haptic example iterate through all available gamepads? Or stop at the first? |
EDIT: Disregard my previous message here. The bluetooth connection had died. I can see a single evdev device listed for the joycon:
EDIT 2: there also exists /dev/input/event21 for the IMU |
I think there's an unrelated permission issue involved. If I run as root 😨 I can see the IMU device. But stick isn't too happy about it.
|
Okay so I'm able to get some readings out by disabling that assert and hardcoding a random number for minimum and maximum. It now picks up on the gyro events! (JoyZ)
so I need to figure out:
|
@medakk Thanks for investigating further! ioctl failure looks like it's related to #38. Currently a work-in-progress to fix it. It's weird that the permissions are wrong for joycons, not sure what I can do about that. "Unknown Linux Misc Code" should be trivial enough to fix, should just be an extra branch arm for the match statement. |
I had the same problem. Everything was working fine. I changed the linux. A lot of packages were updated. Started to build the project and the bugs started. |
@aspanoz It should be fixed on my fork here: https://github.com/AldaronLau/stick/tree/deps-update - The reason I haven't merged it and released a new version is that the changes broke Windows compilation and I haven't had time to fix yet. I'll try to get back to it soon. |
Is there any progress on this? |
@ImUrX I was getting close to getting the Windows port fixed on that branch a couple months ago and finally merging, but got distracted by issues in other projects I'm maintaining. Sorry I'm so slow to resolve this one. I'm hoping to prioritize it in the next few months, and finally get this resolved - then try to get more maintainers on this crate, so issues like this aren't outstanding for so long in the future. |
I made some code based on evdev with tokio if interested. link |
Thanks for creating this library!
Is there a way to access gyroscope and accelerometer data from Joycons currently? On Ubuntu 20.04 with the dkms-hid-nintendo, there are two input sources I can see:
js0 corresponds to buttons/analog stick and that works fine in
stick
. The gyro and accelerometer readings seem to be a part of js1. Is there a way I can use the "second" controller via stick?I'm using the haptics example to test
The text was updated successfully, but these errors were encountered: