I had recently setup Batocera on my Rasberry pi 4 so that my kids could play console games, unfortunately i later found out that Wii emulation was too heavy for the rpi4 and decided to instead setup Moonlight so that they play the Wii remotely. Unfortunately, the Wii controller can’t be emulated as gamepad as it would lose the sensors ability, the solution was to use something like VirtualHere to passthrough the USB device (Dolphin Bar).
Batocera doesn’t come with VirtualHere installed nor available for arm devices, so i downloaded the executable file from here and uploaded it to the rpi.
./vhusbdarm &
Installed VirtualHere Client on the gaming machine and that’s it! Unfortunately, for more than 1 controller you need to purchase a license so i’m currently looking into running usbip which seems quite outdated but it’s free…
###Update on 2024-07-02 14:00
After further looking into this, i found out Batocera comes pretty much locked for any modifications and that pacman (it’s running aarch64 archlinux ) is only used for Batocera content (emulators, etc…). Since VirtualHere was able to run without being installed, running it just from the binary i thought of trying the same with the usbip.
The way this works is, the server runs on the device where the controllers are connected (in this case the rpi running Batocera) and the Client runs on the machine that the games will be streamed from.
##USB passthrough on the server Upon searching the github batocera’s code i found out that it shipped with the usbip modules so i just had to edit /etc/modules.conf and add the list of modules:
usbip-core
usbip-host
vhci-hcd
Now i just have to start the usbip daemon on boot, this is done via /userdata/system/custom.sh
:
#!/bin/bash
/bin/usbipd -D
Now that the daemon is running, i’ll need to bind the devices to passthrough: 1st, connect the devices and find the busid:
usbip list -l
It should return something like:
# usbip list -l
- busid 1-1.1 (25a7:0163)
Areson Technology Corp : unknown product (25a7:0163)
Where the busid is 1-1.1, now bind to daemon:
usbip bind -b 1-1.1
That’s done on the server side.
##USB passthrough on the Client
For the lack of options i had to use an outdated client for this one usbip-win, all i had to do was to extract the files, open a command line in the directory and run:
usbip-win.exe install -w
Then to attach the controller:
usbip.exe attach -r server-ip --busid=<your-controller-busid>
and you should get something like:
succesfully attached to port
I’ve only gone as far as testing the wiimote for a couple minutes and the performance seemed reliable, will need to try out with multiple devices and see how that works in the future.
Note: Not sure if the binds will persist throughout reboots.
##Batocera-moonlight Multiple devices
I have two machines running sunshine for remote access, one is my main machine for gaming and the other a VM for movies. I was trying to add both of them to the batocera but whenever i paired one device, the other would cause the first device options to disappear. Batocera-moonlight also doesn’t seem to discern from devices if the IP is not specified. So i went into ssh and looked at what the batocera-moonlight script was doing, the steps are:
batocera-moonlight pair <ip>
PIN number is provided, fed into the sunshine webface, successfully paired returns.
batocera-moonlight init
init is suppose to run the following function:
createRomLinks () {
rm -f $moonlight_gamesnames
rm -rf $moonlight_romsdir/* $moonlight_romsdir/.* 2>/dev/null
listGames | while read line
do
filename=$(echo $line | sed 's/[^ A-Za-z0-9._-]/-/g')
echo "$filename$SEPERATOR$line" >> $moonlight_gamesnames
touch "$moonlight_romsdir/${filename}.moonlight"
done
}
because there are no IP distinction, the init command uses the first IP that’s picked up (mDNS) so only one device ends up being added while the previous devices are removed. I had written some code to accomodate the different IPs but at some point i went to edit the code and found the file had been reset so right now i have nothing but i temporarily fixed the issue by commenting the first two lines of code when pairing the second device.
Something like this:
createRomLinks () {
#rm -f $moonlight_gamesnames
#rm -rf $moonlight_romsdir/* $moonlight_romsdir/.* 2>/dev/null
listGames | while read line
do
filename=$(echo $line | sed 's/[^ A-Za-z0-9._-]/-/g')
echo "$filename$SEPERATOR$line" >> $moonlight_gamesnames
touch "$moonlight_romsdir/${filename}.moonlight"
done
}