|
| 1 | +# remotegamepad |
| 2 | + |
| 3 | +Remote Gamepad allows you or your friends to use any browser-supported gamepad |
| 4 | +to mimic a Nintendo Switch Pro Controller by using a Raspberry Pi as a relay. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +## How It Works |
| 9 | + |
| 10 | +* Web browsers have a [Gamepad API](https://caniuse.com/gamepad). You can check if your gamepad/controller is supported at [Gamepad Tester](https://gamepad-tester.com/). |
| 11 | +* Inexpensive devices such as the Raspberry Pi Zero W are capable of imitating a Nintendo Switch Pro Controller when placed in OTG/USB gadget mode. |
| 12 | +* Remote Gamepad provides some glue between the two by setting up button mapping and sending a stream of controller data to the Raspberry Pi which in turn will relay it to the Switch via USB. |
| 13 | + |
| 14 | +If you have a capture card and a low latency way to share the video stream, you |
| 15 | +can game with friends who don't have a Switch over the Internet. Map/redirect a |
| 16 | +port on your router/gateway to port 8085 on your Raspberry Pi and have your |
| 17 | +friend connect to it with their browser. |
| 18 | + |
| 19 | +## Requirements |
| 20 | + |
| 21 | +* Nintendo Switch |
| 22 | +* Nintendo Switch Dock |
| 23 | +* Raspberry Pi Zero W, Raspberry Pi 4 Model B, or other board cable of OTG mode+network |
| 24 | +* Browser support for your controller/gamepad |
| 25 | + |
| 26 | +## Pi Setup |
| 27 | + |
| 28 | +Enable dwc2 USB controller driver |
| 29 | + |
| 30 | + echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt |
| 31 | + |
| 32 | +Enable needed kernel modules |
| 33 | + |
| 34 | + echo "dwc2" | sudo tee -a /etc/modules.d/dwc2.conf |
| 35 | + echo "libcomposite" | sudo tee -a /etc/modules.d/libcomposite.conf |
| 36 | + |
| 37 | +Reboot for changes to take effect |
| 38 | + |
| 39 | + sudo reboot |
| 40 | + |
| 41 | +Download [add_procon_gadget.sh](https://gist.github.com/mzyy94/60ae253a45e2759451789a117c59acf9#file-add_procon_gadget-sh) |
| 42 | +and run it with root privileges. By default the resulting device, `/dev/hidg0` can only be used by root. You should chown/chmod like so: |
| 43 | + |
| 44 | + sudo chown root:dialout /dev/hidg0 |
| 45 | + sudo chmod 660 /dev/hidg0 |
| 46 | + |
| 47 | +If you're going to be using the setup long-term, a udev rule should be used instead. |
| 48 | + |
| 49 | +## Launch |
| 50 | + |
| 51 | +[Download the release](https://github.com/jolan/remotegamepad/releases), extract it, |
| 52 | +`cd` into the directory and run `./remotegamepad` |
| 53 | + |
| 54 | +Or get the source: |
| 55 | + |
| 56 | + go get -u -v github.com/jolan/remotepamepad |
| 57 | + |
| 58 | +And then build and run it: |
| 59 | + |
| 60 | + cd ~/go/src/github.com/jolan/remotegamepad && go build && ./remotegamepad |
| 61 | + |
| 62 | +Or cross-compile it and then copy everything to the Raspberry Pi: |
| 63 | + |
| 64 | + env GOOS=linux GOARCH=arm GOARM=6 go build |
| 65 | + |
| 66 | +The binary expects to find `webroot` in the same directory that is run from. |
| 67 | + |
| 68 | +Finally, enter the URL to your Raspberry Pi (e.g. http://192.0.2.53:8085) into your browser. |
| 69 | + |
| 70 | +## Adding A Profile For A Controller |
| 71 | + |
| 72 | +1. Go to https://gamepad-tester.com/. |
| 73 | +2. Copy/paste the full controller name and annotate the button layout for your controller in gamepadStateSend(). |
| 74 | +3. Add shortname to gamepadShortName(). |
| 75 | + |
| 76 | +## Limitations |
| 77 | + |
| 78 | +* Non-Switch controllers cannot be used to wake the system from sleep. |
| 79 | +* Starting a session requires the Switch to be out of sleep mode. |
| 80 | +* At the moment, the supported controller list is hardcoded and tiny. |
| 81 | +* Can only use a single gamepad per computer (seems to be a browser limitation). |
| 82 | +* Every remote gamepad requires their own Raspberry Pi/relay device. |
| 83 | + |
| 84 | +## Roadmap |
| 85 | + |
| 86 | +* Add profiles for common controllers like Wii U, DualShock, Xbox 360, etc. |
| 87 | +* Add button mapping dialog for controllers using the default profile. |
| 88 | +* Improve binary release with systemd service, config/logging options, udev rule, etc. |
| 89 | +* Code cleanup. |
| 90 | +* Add mouse/keyboard support. |
| 91 | +* Test on non-Chrome browsers to check for bugs/quirks. |
| 92 | +* Determine if multiple controllers-on-a-single is possible. |
| 93 | +* Add audio/video streaming support. |
| 94 | +* Maybe support consoles other than the Switch one day. |
| 95 | + |
| 96 | +## Acknowledgements |
| 97 | + |
| 98 | +@mzyy94 - remotegamepad borrows much of the functionality from his work. |
| 99 | + |
| 100 | +* https://github.com/mzyy94/nscon |
| 101 | +* https://github.com/mzyy94/ns-remote |
| 102 | +* https://mzyy94.com/blog/2020/03/20/nintendo-switch-pro-controller-usb-gadget/ |
| 103 | +* https://mzyy94.com/blog/2020/04/17/nintendo-switch-audio-uac-gadget/ |
| 104 | +* https://mzyy94.com/blog/2020/05/11/play-nintendo-switch-on-smartphone/ |
| 105 | +* https://mzyy94.com/blog/2020/05/12/raspberry-pi-hdmi-edid-cec/ |
| 106 | + |
| 107 | +Thanks to others for precursor/similar/inspiring work: |
| 108 | + |
| 109 | +* @dekuNekum - https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering |
| 110 | +* @shinyquagsire23 - https://github.com/shinyquagsire23/HID-Joy-Con-Whispering |
| 111 | +* @Xfennec - https://gist.github.com/Xfennec/e1215febb15b40c21bf029b38a31640b |
| 112 | +* @mumumusuc - https://github.com/mumumusuc/pi-joystick |
| 113 | +* @omakoto - https://github.com/omakoto/raspberry-switch-control |
| 114 | +* @mart1nro - https://github.com/mart1nro/joycontrol |
| 115 | +* @javmarina - https://github.com/javmarina/Nintendo-Switch-Remote-Control |
| 116 | +* @ndeadly - https://github.com/ndeadly/MissionControl |
| 117 | +* Parsec - https://www.youtube.com/watch?v=uTlwVyWobRc |
| 118 | + |
| 119 | +## License |
| 120 | + |
| 121 | +[GPL v3](LICENSE) |
0 commit comments