XITRIX / Moonlight-Switch

Moonlight port for Nintendo Switch
975 stars 51 forks source link

[Bug] GYRO data provides in radians instead of degrees #149

Open jdin opened 7 months ago

jdin commented 7 months ago

First of all, thanks for the great tool!

Everything works fine for me except gyro. I have the latest release of Moonlight-Switch (1.0.0) in combination with Sunshine 0.22.2 on my switch OLED. And gyro works fine if I use it on the console itself for native games. I have forced DS4 as a controller on the sunshine side. And my switch is indeed recognised as a playstation controller but still no gyro.

These are the logs from sunshine:

[2024:04:01:14:11:19]: Warning: ControllerNumber [] not allocated
[2024:04:01:14:11:19]: Info: Gamepad 0 will be DualShock 4 controller (manual selection)
[2024:04:01:14:11:19]: Warning: Gamepad 0 is emulating a DualShock 4 controller, but the client gamepad doesn't have motion sensors active
[2024:04:01:14:11:19]: Warning: Gamepad 0 is emulating a DualShock 4 controller, but the client gamepad doesn't have a touchpad
[2024:04:01:14:11:19]: Warning: Unexpected new pointer 0 for event 4. Did the client drop a down/hover event?
[2024:04:01:14:11:19]: Warning: Unexpected new pointer 0 for event 4. Did the client drop a down/hover event?

I have spent already quite some time investigating but no luck. Did I forget to do something?

Switch OLED Moonlight-Switch: v1.0.0 Sunshine: 0.22.2

lvzhaobing commented 7 months ago

+1 I have the same problem.

orcavia commented 7 months ago

Is gyro even supported? I don't think so, But would be much better if we have gyro support. I'm not expert but since moonlight android it's support gyro, i think it's possible to get on switch.

jdin commented 7 months ago

Yes it should be as of version 1.0. it is stated in a Readme . There are commits for that and there was a feature request for that which is already closed as implemented.

lvzhaobing commented 7 months ago

Hi,recently, I verified that using gyroscopes with two Joy-Cons connected directly to the Nintendo Switch (NS) can sometimes yield gyro data. The gyroscopic fluctuations in the movement of the controllers seem to be much smaller than those of a normal Switch Pro controller. After streaming to a PC through Moonlight and then Sunshine, the controllers can be emulated as DS4 controllers and mapped for mouse movement using the Steam client. It's important to note that the gyro calibration option in the Steam settings needs to be used once for calibration.

However, sometimes things don't go as smoothly. During gameplay, there may be sudden confusion in gyro data, causing the mouse on the PC to constantly drift towards the bottom of the screen, making normal usage impossible.

lvzhaobing commented 7 months ago

The most likely reason is that the configuration of Sunshine on the PC side cannot persist well; whenever I forcibly change the controller emulation to DS4, it inexplicably reverts to the default settings, including changes I've made to the display language, which always become ineffective. So, before starting the streaming, make sure to check whether the Input Config options of Sunshine are still valid. i74gbon6Qd

XITRIX commented 7 months ago

So, I found one thing to improve and one issue in Gyro implementation:

As improvement, I started to report gamepad "Features" with gyro support so Sunshine could select PS4 controller as default automatically.

Also I realised that Switch reports Gyro values in radians while Sunshine should receive values in degrees, so I've started to convert them.

You can try this improvements in this build

orcavia commented 7 months ago

So, i tried that's build it has improvement than before but very rough,shacking,jaggy? (i don't know how describe in english) but surely its still unusable for now, hopefully it can be improved thanks for your hardwork thoug. :)

XITRIX commented 7 months ago

Why GitHub has no crying emoji as reaction, because I want to cry 😭

jackazz86 commented 7 months ago

Wait, wait. I tried the new build with gyro improvement too. The sensitivity issue is now fixed, way better than before and previous release. Can be definetely be improved even further and smoother that this but it's now way more usable than before.

About the roughness mentioned here, I believe the bottleneck might be HOS itself: i tried playing with gyro in front of my PC monitor where I stream from and there was almost no visible lag: the input lag and roughness seemed to be on the switch side. I might record an example of a gaming session if it proves to be useful.

Thank you once again for the amazing work!

jackazz86 commented 6 months ago

I’ve done more gyro testing throughout the weekend and I gotta say the improvement is noticeable. Playing through steam input and adding some smoothness actually makes it very good. Can definitely be improved concerning smoothness. When docked, instead, pro controller doesn’t register any gyro input. What was the issue with user orcavia to say it was unusable? It’s working pretty good on my end right now.

XITRIX commented 6 months ago

For pro controller I probably didn’t create a gyro profile for it, only for joycons, need to check it

jackazz86 commented 6 months ago

Sorry it was a Steam issue. Pro controller gyro is working. My bad.

At the same time, I noticed a strange behavior with pressing and holding multiple buttons. I was playing Helldivers 2 (but tried other games): holding a button and pressing another button or moving the right or left stick in combination (as sometimes happen for weapon wheels in games) produces strange results. It seems like the main button is pressed and released constantly.

Lb/rb + other buttons or x/y + left/right stick doesn’t work. The sequence Interrupts while pressing buttons or moving sticks in combination.

been using latest beta with gyro improvement.

XITRIX commented 6 months ago

Yes, for buttons I probably messed with something, in gamepad tester I saw that buttons constantly flickers on holding them. I think something wrong with my implementation of gamepad features notification

XITRIX commented 6 months ago

More fixes here, test it please

Nope, not this, but this

orcavia commented 6 months ago

Woah, that's build fixed my problem, Previously i bit struggle when i want to sprint by pressing L3 I thought it was my controller. 😅 But now I use that to build its work as intended now i can run flawlessly, Thanks a lot for this fix! 👍

jackazz86 commented 6 months ago

Last build is working perfect! Buttons issue is fixed. Thank you very much 😊 this homebrew app, now with correct gyro support, has become amazing. Been playing Helldivers 2 on my sofa handheld @ 10mbps and it’s been an almost flawless experience.

jdin commented 6 months ago

Indeed, the new build is perfect. I have tested it a bit and all the problems that I have faced in the previous build are gone. I will test it further and let you know if I see anything ...

XITRIX commented 6 months ago

So, could I declare this issue as "Ready for Release"?

jackazz86 commented 6 months ago

So, could I declare this issue as "Ready for Release"?

Gyro works very good now. The only remaining thing that comes to my mind is the following: when detached, the joycon transmitting gyro coordinates currently is the left one. While in other switch games and fps (such as Doom, Wolfenstein etc) gyro movement is normally assigned to the right joycon. If you have time to spare and want to include this change, it might be a nice addition.

john-ee commented 6 months ago

~More fixes here, test it please~

Nope, not this, but this

Hi, can I download this build and try it ? I don't understand the link and how I can test the build.

XITRIX commented 6 months ago

@john-ee, yes, you can.

You could open Actions tab in the top of the GitHub page, select latest build, and click on Moonlight-Switch.nro in Artifacts section