Yamakaky / joy

Library and tools for working with Nintendo Switch JoyCon/Pro Controller
MIT License
27 stars 6 forks source link

Trouble detecting paired joycons with joytk #3

Open hoverbird opened 3 years ago

hoverbird commented 3 years ago

Hey @Yamakaky!

First of all, thank you for making this software, I am really excited to start using this to get flex data off of the ringcon, something I've been hoping to do for over a year. It seems from discussions on the dekuNukem forums like you've really solved it.

That said I am not able to use the software yet, I suspect I'm doing something wrong— for context I am totally new to Rust. I'm on macOS 10.15.6 and have successfully paired R+L joycons over bluetooth, and am able to see their live inputs from another simple controller utility. But when I try to use any of the joytk commands, I always get the same error:

⟩ target/debug/joytk ringcon monitor ~/D/F/c/joy 1 Error: Failed opening hid device

Is there a setup step I missed to make the paired controllers visible to the HID library? Any guidance you can provide is much appreciated. Thanks!

hoverbird commented 3 years ago

Oh, I forgot to mention- this was after commenting out some linux-specific code that was preventing compilation, but which is maybe also supposed to target macOS as well as linux? here is the error I get with a clean checkout of master:

   Compiling joytk v0.1.0 (/Fitness Gaming/code/joy/joytk)
error[E0433]: failed to resolve: use of undeclared crate or module `relay`
  --> joytk/src/main.rs:64:21
   |
64 |                     relay::relay(device, r)?;
   |                     ^^^^^ use of undeclared crate or module `relay`

error: aborting due to previous error
Yamakaky commented 3 years ago

I pushed to fix the compilation issue.

Unfortunately, the error messages for hidapi are pretty limited. I also don't have a mac for testing. Some things to try:

What other utility do you use?

As for the relaying, it should work on mac but not sure. The pairing is not implemented, so you have to do the pairing using https://github.com/Yamakaky/joycontrol/blob/capture-text-file/scripts/relay_joycon.py then run my relay.

hoverbird commented 3 years ago

Aha, you guessed it right on the first try! I had paired a Left and a Right Joycon at the same time. Pairing with only a Right controller and the code works fine. Thanks for your help @Yamakaky !

hoverbird commented 3 years ago

Hi again! I'm definitely making progress now, but hit another snag. The joycon is found, and I am getting what looks like good accelerometer, gyro etc. information from joytk monitor... unfortunately, joytk ringcon monitor just streams "Flex value:0" and joytk ringcon stored-flex returns "Ringcon initialisation... Error: no accessory connected"

This is with the joycon connected to a Ringcon when I paired it to the mac... is there a step I need to do to tell the joycon explicitly to behave as if it's connected to a ringcon? Thanks again for all your help, I can't wait to use this software, it's going to be so cool!

Yamakaky commented 3 years ago

Interesting, I don't think I ever tested with two joycons. I don't see why it wouldn't work. Are you sure the tool doesn't create a fake device or something? I have to add a command to list the devices, maybe it will help.

As for the ringcon, could you use the relay command to record a trace? You first need to use the python script to pair the switch, which only supports Linux so some adaptation will be needed. Ping upstream if you need help. After that, my relay should work fine.

hoverbird commented 3 years ago

I'm now just testing with a single joycon, and no other tools. I will try to get relay working and report back!

Yamakaky commented 3 years ago

The main adaptation point is https://github.com/Yamakaky/joycontrol/blob/capture-text-file/scripts/relay_joycon.py#L97-L102. I think the rest should be ok, it may even work on windows.

You could try to comment these lines and see if the fix is not needed on Mac.