XITRIX / Moonlight-Switch

Moonlight port for Nintendo Switch
779 stars 47 forks source link

[Feature Request] Emulate Switch Pro Controller or Dualshock 4 for Gyro #49

Closed 4K045M closed 4 months ago

4K045M commented 2 years ago

Thank you for your brilliant work so far! Would it be possible to let the Switch show up as an Switch Pro Controller or Dualshock 4 with Gyro/Motion Support on Windows? Or maybe another Way to send Gyro Data? It would be Awesome to use that feature for Gyro Aiming etc. I think SkyNX and Chiaki for Switch have Gyro Features. Cheers!

XITRIX commented 2 years ago

Hi, all that project works on Moonlight's library and as I know there is no way of transferring gyro data with it, I'll investigate that question, but I think it will be not possible so far :(

4K045M commented 2 years ago

OK, I read something on the subject too. You probably already know about this: https://virtualhere.com/ Could this be a tool to integrate? Another workaround could be to convert gyro data to left stick movement. But a hotkey could be added to avoid permanent movement. Similar to, for example, The Last of us 2, in which Gyro Aiming is only activated if you hold down R2. Then you have a combination of gyro and left stick aiming. I can imagine that something like this is not so easy to create. There seems to be a lot of demand in this regard when you google the subject. Someone in the Moonlight-NX thread at GBAtemp once posted this link on the topic: http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-1:the-gyro-is-a-mouse

XITRIX commented 2 years ago

Thanks for the post, it was very interesting read, gyro->mouse is really good solution that is probably easier to implement. I cannot guarantee that I'll implement it any time soon, but I'll definitely will try to do it in future

dkswedens commented 2 years ago

I would love this feature too, perhaps something that could be run outside of moonlight? Using UDP or what not - if switch gyro is exposed one could create a server app that works along with moonlight and feed it to the host pc - im just thinking out loud.

I guess.. gyro and microphone is really whats holding moonlight back, er.. cloud / stream gaming in general - would be so much better with it. I would love to try this application out but without gyro there's no go. currently stuck using android moonlight with virtualhere - would absolutely love to use CFW instead.

Thanks for contributing to the community!

XITRIX commented 2 years ago

Wow, does android version supprots gyro? If it is I could investigate it's source code and try to replicate the same on Switch.

Talking about microphone, it's a bit more complicated. As I understand, Switch's minijack doesn't have physical support for mic, cause even in android OS it doesn't work either...

dkswedens commented 2 years ago

I'm afraid it doesn't, I use virtualhere to pass the joycons from the android switch to the host pc to get gyro - however, on android steam link sees the switch gyro but the axis are all messed up where "left and right" translates to output up and down.

I think skyNX? has somewhat of a gyro function but I could be wrong. There's also a guy (https://github.com/Moehammered/switch-remote-play) who have stated to work on gyro - perhaps a collab is in order for quicker works?

On android the switch minijack doesn't work but with the upcoming update of android lineage os 18? it will be supported as its already come on linux version.

Minijack works on HOS so theoretically it should be the same on CFW?

pdaian commented 6 months ago

wanted to bump this and update it with some info :) thanks for all the hard work on this port, I use it regularly. I am however a heavy user of the gyro controls on the Android/Switch moonlight, it's one of the things that keeps me booting into Android regularly. I'd love to have this feature in the Switch port and think it could work even better, as you likely have access to in-joycon gyros etc.

I'm also a dev and was looking into what it takes to add this. The base commit to add the feature to moonlight-qt, supported by Sunshine, is here: https://github.com/moonlight-stream/moonlight-qt/commit/9af58af5e4aa536083ad62997135c1f9c03430ec#diff-9fda58d6e87ead7394ef139de1ec8e87311a747a647535042575cb2c662f50d5

I think that, along with Chiak or SkyNX's code for polling the gyro, should be fairly doable to combine into a motion controls module. It should just require sending the raw polling rate and data over the controller interface. Any gyro tweaking / mouse or stick emulation / etc can be handled by SteamInput or one of the many driver-level tools on the host side.

Figured I'd dump the info here since I have a huge backlog and I will probably eventually do this for my own usecase if nobody else does, but it may literally be years...

XITRIX commented 6 months ago

Thanks for the info, in case it's already supported by official moonlight and sunshine it's much more possible that I'll implement it in Switch version.

Technically I'll need to add gyro forwarding from SDL\GLFW to Borealis and then pass this data to moonlight-core, sounds not so complicated but ... I don't want to guess :D

XITRIX commented 4 months ago

Implemented in v1.0

pdaian commented 4 months ago

thanks, this is really amazing work!