Davidobot / BetterJoy

Allows the Nintendo Switch Pro Controller, Joycons and SNES controller to be used with CEMU, Citra, Dolphin, Yuzu and as generic XInput
Other
3.82k stars 338 forks source link

[ENHANCEMENT] Support Switch Display Output over USB #910

Open JeremyEastham opened 2 years ago

JeremyEastham commented 2 years ago

Is your feature request related to a problem? Please describe. No problems here! I love this project's ease of use.


Describe the solution you'd like This may well be outside the scope of this project and may be quite an undertaking, but I think it would be amazing if I could plug the Switch into my laptop and use it as a bigger screen. It would make for a great portable setup to be able to just take the Switch and a USB Type-C cord and be able to have a portable 11", 15.6", or even 17" screen to go with it. Ideally, you could plug the Switch in and the laptop would provide power to the Switch and use the Switch Dock protocol to act as a virtual HDMI output over USB and render in a fullscreen window. This should be possible to implement since the Switch only uses the Type-C port on the bottom to stream content to the Dock.


If this is outside the scope of this project I might start a project of my own for this purpose. I am knowledgeable in C#, but I have never written a driver before so please help me find a direction to start:


If there is another project that accomplishes this purpose I would love to hear about it. I searched for one and could not find anything like this that didn't require homebrew software to be installed on the Switch.

Davidobot commented 2 years ago

I think your best bet is a capture card or homebrew.

I don't think it's possible to make a USB C port an "HDMI in" port via software, which is what would be required to support this application. I think the necessary hardware is just physically lacking.

You've probably already come across this but: https://github.com/exelix11/SysDVR

spacepill0w commented 2 years ago

That's probably impossible. Like Davidobot said, you can't make a USB port an HDMI-in. The hardware just isn't there. Even between two laptops, you can't use one computer's screen as a second screen for the other. It just doesn't work, unless for whatever reason there's an HDMI-In port on one device for some reason. An HDMI-in port has to be its own thing, and you can't use a dongle or any software to get around that. Theoretically, you could probably buy some parts, remove your laptop's screen, and treat it as a portable monitor, but I don't know how to go about doing that, or if it would even work.

The best you could realistically do is SysDVR, or buy a portable monitor. The latter is costly though and unless you get a great deal buying used or something, probably not worth it. Good luck!

JeremyEastham commented 2 years ago

I would agree that under normal circumstances that a USB port cannot act as an HDMI input. However, this is not what I would need to achieve. When the Switch is plugged into the Dock, it serializes its video output and sends it to the Dock over the USB-C port. The Dock then sends that information over the HDMI port to a TV or monitor.

If my suggestion were to be implemented, the Switch would send that same serialized video over USB-C and the driver would render the video instead of passing it along to an HDMI output. The "virtual HDMI output" that I was referring to is simply an abstraction of the laptop's role as a video output device. The actual HDMI protocol might not even be used, depending on the structure of the messages that the Switch sends to the Dock.

spacepill0w commented 2 years ago

Hm, neat. To be perfectly honest, that much is out of my scope of knowledge, and (though this is completely up to Davidobot) probably outside the scope of Betterjoy. I wish you luck in any development though. You've got a pretty cool idea.

Davidobot commented 2 years ago

According to this the switch uses DisplayPort-over-USB-C.

Here's the kicker:

What's tricky is that Nintendo's entry conditions are proprietary. The Switch doesn't even try to negotiate DP Alt Mode unless the thing it's talking to identifies itself as a Nintendo product, which is why many of the 3rd party docks that support display just fake their VID:PID to be like the Nintendo Dock's.

People have used a raspberry pi as a capture device before (but it had an HDMI in): https://www.mzyy94.com/blog/2020/05/11/play-nintendo-switch-on-smartphone/ (and related github)

JeremyEastham commented 2 years ago

Looking into this further, I also have concerns over power. Since the Dock is 15v/2.6a and a standard USB port only supplies 5v/0.5a, I'm worried that the Switch would try to draw too much power if it thinks that it's docked. I also read a couple of horror stories about people who had to do a system restore after a particular C# lib messed up their USB drivers.

I may revisit this later, but for now, it appears that this would require a much more complex solution than I anticipated.