Connect XBox 360 Wireless Controller to your Nintendo Switch

Nintendo Switch's default controller is good enough for gaming, but unfortunately after a while  the joycons would drift easily. As an alternative, this article will show how to use XBox 360 wireless controller (or any controller that are detectable by Linux OS) to control a Nintentdo Switch Console

Hardware Needed

A.
https://www.ebay.com/b/xbox-360-controller-pc-adapter/bn_7024868184
First you need a Xbox 360 to PC adapter.
B. https://www.ebay.com/itm/Raspberry-Pi-3-Model-B-Plus-1-4GHz-Quad-Core-64Bit-1GB-RAM-2018-Model-/261698200759
And a raspberry PI model 3B+. With a SD card containing Raspbian OS.
C. https://www.ebay.com/itm/xbox-360-controller-wireless-new/153989068162?hash=item23da76b582:g:bVQAAOSwsJFe-zPz
A Xbox  360 wireless controller.
D. And of course we also need a Nintendo Switch Console.

Fortunately I have all these items in my home. If you don't have A and B, you might better off just buy Mayflash Magic NS adapter (https://www.amazon.com/Mayflash-Magic-NS-Wireless-Controller-Nintendo/dp/B079B5KHWQ). I was going to buy Magic NS but order and delivery takes at least two days.. so I opt for the software solution using existing hardware.

Software Required

Install a Raspbian OS based on Debian 10 (buster) in the Raspberry Pi SD Card. As an alternative I were using  docker on Raspbian 9, and installed debian:10 image.


[ when using docker ]
docker run --net=host --privileged -v /var/run/dbus:/var/run/dbus -v /home/pi/joycontrol:/joycontrol -v /sys/class/bluetooth:/sys/class/bluetooth -v /dev/input:/dev/input -it debian:10 bash
The command above not needed if you already installed Raspbian 10.

Cloning the repo

Clone the git repository containing Pro Controller emulation code from https://github.com/yudhiwidyatama/joycontrol.  This repo is forked from https://github.com/mart1nro/joycontrol with additional evdev-based emulation.

git clone https://github.com/yudhiwidyatama/joycontrol

Installing libraries

Please make use these commands are run as root.

apt install python3-dbus libhidapi-hidraw0
cd joycontrol
pip3 install .
pip3 install evdev

These two command installs required libraries for running the  software. 

Running the software

Connect the XBox 360 to PC adapter to one of USB port. 

python3 run_controller_cli.py PRO_CONTROLLER

If the bluetooth pairing between the Nintendo Switch and the Pi is already done, in the next run we could skip the pairing/handshaking by using this syntax:

python3 run_controller_cli.py -r 60:6B:FF:37:02:30 PRO_CONTROLLER

Adjustments

The XBox controller's devices might be detected other than /dev/input/event2. Please check this directory for alternatives devices :
root@retropie:/# cd /dev/input/
root@retropie:/dev/input# ls -l
total 0
drwxr-xr-x 2 root root          160 Aug 16 14:02 by-id
drwxr-xr-x 2 root root          180 Aug 16 14:02 by-path
crw-rw---- 1 root messagebus 13, 64 Aug 16 14:02 event0
crw-rw---- 1 root messagebus 13, 65 Aug 16 14:02 event1
crw-rw---- 1 root messagebus 13, 66 Aug 16 14:02 event2
crw-rw---- 1 root messagebus 13, 67 Aug 16 14:02 event3
crw-rw---- 1 root messagebus 13, 68 Aug 16 14:02 event4
crw-rw---- 1 root messagebus 13, 69 Aug 16 14:02 event5
crw-rw---- 1 root messagebus 13, 63 Aug 16 14:02 mice
crw-rw---- 1 root messagebus 13, 32 Aug 16 14:02 mouse0
crw-rw---- 1 root messagebus 13, 33 Aug 16 14:02 mouse1

Change line 288 of run_controller_cli.py  if neccessary :

 device = evdev.InputDevice("/dev/input/event2")

Result

Using a Raspberry Pi 3B+, running Raspbian 9 with Debian 10 under docker, we were able to obtain throughput of 250 to 500+ events per second. This quite nice considering native Xbox 360 polling rate of 8ms.




Comments

tejaswini said…
I think I have never watched such online diaries ever that has absolute things with all nuances which I need. So thoughtfully update this ever for us.
data scientist course in malaysia
360DigiTMGNoida said…
This is my first time visit here. From the tremendous measures of comments on your articles.I deduce I am not only one having all the fulfillment legitimately here!
iot course in noida
360DigiTMG said…
I see the best substance on your blog and I unbelievably love getting them.
training provider in malaysia
Bhavana said…
I was looking at a portion of your posts on this site and I consider this site is really enlightening! Keep setting up..
https://360digitmg.com/course/project-management-professional-pmp
Hey amigos, it is incredible composed piece completely characterized, proceed with the great work continually.
360DigiTMG data analytics course

Popular posts from this blog

Long running process in Linux using PHP

Reverse Engineering Reptile Kernel module to Extract Authentication code

SAP System Copy Lessons Learned