Luma3DS input redirection on Linux

:warning: Depending on locality, what you're doing may be considered illegal! Please be aware of your local laws and statutes regarding modification of hardware and use of third-party software on commercial devices before committing to this guide!

:information_source: You will need to already have modified your Nintendo 3DS / 2DS console with Luma3DS custom firmware before continuing. This guide will not teach you how to do this, only what to do after the fact. Research, take your time and you won't brick your console. Promise.

Huh?

Yeah, Nintendo 3DS stuff. A little bit off-colour compared to my strictly Linux presentations but I figured I would share this here because it's my circle of influence, and there is probably some overlap for people with Linux systems and modified hardware. Fortunately, Nintendo consoles before the Switch and after the Gamecube are very easily modded through software alone, which is an attirbute you will have no doubt taken advantage of for your 3DS before following this guide because this is reporting on an aspect of that software known as input redirection.

About input redirection

The general idea is this; Both the console and your PC (in this case, client) are connected via the same Wi-Fi SSID. Using your router (or routing capabilities of your gateway) you can then (in theory) use any device to control the 3DS through your PC. While I had not figured out screen sharing yet, if you have an older model (non-new) then this and FTP transfer is all you can do using your PC anyway.

It is especially handy if you want to play a 3DS title using real, native hardware, yet not use the 3DS gamepad because for some people, it's an ergonomics nightmare. It allows for enhanced comfort, potentially enhanced gameplay and an overall better experience without needing to hack in a USB port for plugging an external controller in. (Not certain if a kit exists for that, but it probably does.)

Possibility of NNID ban

Expand if you're concernedGoing to get this one out of the way right now; Luma3DS does some spooky scary voodoo magic to validate your title against Nintendo's servers so it appears like you are playing an actual cartridge. This also requires your title's ticket (basically an authentication token), and so long you are ripping your own games with GodMode9 you shouldn't ever encounter any NNID issues. This thread does not, and never will advocate piracy. I will leave it to the moderation team on how to deal with piracy-related concerns. Using custom firmware, and any feature of it, by itself is not tantamount to piracy unless the end-user exercises it for this purpose. If you are caught playing with an illegal copy of a 3DS title, you're on your own, and probably out of luck.

How to install

An automated build script will be provided for this at the end if you don't feel like following directions shown here.

Required software

You will have to install the following to make this work, as you will need it to acquire and build from the Git repository software for this express purpose:
sudo apt install -y git libqt5gamepad5-dev qtbase5-dev qt5-make

Optional software

The following isn't really optional if you use DirectInput controllers, as the input redirection client relies on XInput controllers but you'll probably want to install this regardless to evaluate and use non-XInput controllers:
sudo apt install -y evtest xboxdrv

Making it happen

With the requirements above met, you can now continue to fetch and build the software:

# Optional steps for neatness
mkdir -p ~/git && cd ~/git
# Fetching source
git clone https://github.com/TuxSH/InputRedirectionClient-Qt.git
cd ./InputRedirectionClient-Qt
# Building
export QT_SELECT=5
qmake && make

Some voodoo magic will appear on the screen, and will proddice an executable named InputRedirectionClient-Qt within the repository directory. You can move this anywhere and execute it; to test after following the above steps, and provided you didn't change directories you can just open it with this right now:
./InputRedirectionClient-Qt

Specifying to use current path isn't necessary, InputRedirectionClient-Qt works too!

Automated build file

After you clone the repository, visit here and right-click on Raw, and save as inside of the clone location.

After having done that, sudo chmod +x it and execute. Script will pull in required dependencies stated above and build the program for you.

If you have an XInput-compatible device, you're good to go! SImply power on and connect. If not, however...

Using DirectInput HIDs

Have a joypad but it's not sanctioned by Microsoft? No problem! If you installed the optional components then you can do the following:

Testing if the controller exists

Simply run evtest. Your joypad should come up, here's an example from my computer:

$ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event12:	Twin USB Joystick
/dev/input/event13:	Twin USB Joystick
Select the device event number [0-13]: 

Bear in mind the device event number. You'll need that for later. This will clearly be different, and you may have to modify the following shown below.

Using the controller as an XInput device

I am using a cheap adapter for PlayStation 2 controllers. Use whatever you want, just know what's provided here may not work for you.

Once you've determined the input number, (continuing from the previous subsection's example) you'll want to use this:
xboxdrv --evdev /dev/input/event12 --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_RZ=x2,ABS_Z=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y --axismap -Y1=Y1,-Y2=Y2 --evdev-keymap BTN_TOP=x,BTN_TRIGGER=y,BTN_THUMB2=a,BTN_THUMB=b,BTN_BASE3=back,BTN_BASE4=start,BTN_BASE=lb,BTN_BASE2=rb,BTN_TOP2=lt,BTN_PINKIE=rt,BTN_BASE5=tl,BTN_BASE6=tr --mimic-xpad --silent

No, I won't cover how to modify the above. Sorry! Look it up yourself or use xboxdrv's man page,

Yeah, it's stupidly long but it works. xboxdrv is also stupidly non-intuitive, but them's the breaks. If using a completely different joypad, you'll most likely need to change the above.

Pairing PC to 3DS

After all of that effort, you will want to do the following:

At the console

Don't forget, this is for Luma3DS, a custom firmware for the Nintendo 3DS. Any stock 3DS can't do any of this! This applies to most Luma3DS versions, instrctions are for current revision as of this writing, 9.1.

  1. Hold L and D-Pad down, then press Select to bring up Rosalina menu.
  2. Select Miscellaneous options...
  3. Select Start InputRedirection.
    • This will often fail if enabling this is done too quickly! Give your console a minute after powering on first.
  4. Press B twice to return at Rosalina menu root.
  5. Take note of the IP address shown at the upper right.
  6. Press B again to exit Rosalina menu.

At your computer

  1. If necessary, enable xboxdrv in terminal first.
  2. Open InputRedirectionClient-Qt.
  3. Type in the IP address from your console at the text input box.
  4. Test with your controller.

If the controller from your PC manipulates the 3DS, congratulations you did it. Play your games using your preferred input method and pwn some noobs with your newfound powers.

Sources


User acheronuk from irc.freenode.net/#kubuntu-offtopic for helping me build the above

This:


Via: