Emulate Nintendo Switch USB Controller with Raspberry Pi
Credit: This project heavily relies on https://github.com/mzyy94/nscon.
- Raspberry Pi Zero W (Supposedly, it works with a regular pi 4, via the USB-C port.)
-
Install libcomposites for the USB gadget mode. (From https://github.com/milador/RaspberryPi-Joystick)
echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt echo "dwc2" | sudo tee -a /etc/modules echo "libcomposite" | sudo tee -a /etc/modules
-
Install on the raspberry pi
go get -v -u -t github.com/omakoto/raspberry-switch-control/nscontroller/cmd/...
-
Create the USB gadget. Do it once after every reboot.
sudo $HOME/go/src/github.com/omakoto/raspberry-switch-control/scripts/switch-controller-gadget
-
Plug in the Raspberry Pi to the Switch. If using a Pi Zero, just connect via the micro-USB cable.
-
Connect a joystick (only the following ones are supported and tested) to a host PC.
- Nintendo Pro controller
- X-Box One controller
- PS4 controller
-
On the host PC, install the software:
go get -v -u -t github.com/omakoto/raspberry-switch-control/nscontroller/cmd/...
-
On the host PC, run it:
nsfrontend -j /dev/input/js0 -o >(ssh pi@$PI_ADDRESS go/bin/nsbackend)
-
Press
[enter]
on the console to finish.
- Autofire on/off
- Macro
- Control switch from a smart phone
- https://www.kernel.org/doc/html/v4.13/driver-api/usb/gadget.html
- https://github.com/milador/RaspberryPi-Joystick
- https://www.rmedgar.com/blog/using-rpi-zero-as-keyboard-setup-and-device-definition
- https://github.com/wchill/SwitchInputEmulator
- https://sourceforge.net/projects/linuxconsole/
- https://github.com/progmem/Switch-Fightstick
- https://sourceforge.net/p/linuxconsole/code/ci/master/tree/utils/jstest.c
- http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/group___group___std_descriptors.html