Meorge / JoyConUnityInputSystem

9 stars 4 forks source link

Weird button value change while sending Rumble #1

Closed Atreijii closed 6 months ago

Atreijii commented 6 months ago

The value of the pressed button (no matter what button is used) changes randomly from 0-1 when sending Rumble:

https://github.com/Meorge/JoyConUnityInputSystem/assets/74182883/f2a47077-1b0b-4f02-b6ee-2c3c0c2e9a4c

Code:

  private void Update()
    {
        if (SwitchControllerHID.current.buttonSouth.wasPressedThisFrame)
        {
            SwitchControllerHID.current.Rumble(SwitchControllerRumbleProfile.CreateNeutral());
        }
    }

The project was tested on Unity 2022.3.19f and updated with the help of this fork: https://github.com/thomasduhamel/Switch-Controller-for-Unity

Meorge commented 6 months ago

Thanks for posting this! I merged that fork in to take a look at the issue with a modern version of Unity, but unfortunately right now for some reason it seems to not be picking up my Pro Controller being connected to the computer (it shows up in the Input Debugger, but not in the other editor windows, and SwitchControllerHID.current is always returning null).

I'll try to dive deeper into it when I have more time in the future - just wanted to add a little update on my first look into it.

Edit: A little bit of good news - it looks like it may be specifically the Pro Controller that doesn't work, as I tried with my pair of Joy-Cons and they did indeed work. So at least it's not totally broken for me 😅

Atreijii commented 6 months ago

Thank you for looking into this! I find that using BetterJoy or even Steam in the background helps with the controller pairing.

Meorge commented 6 months ago

Ok good news, I think! I was able to replicate the issue and, I think, implement a fix for it. The fix is now pushed to my copy of the repository. It seems to fix the problem with holding the button down and seeing the flickering input value, but I'm hoping the fix doesn't cause issues elsewhere 😅

Atreijii commented 6 months ago

Awesome, thanks for the fix! I will try it out!