ScummVM Controller Help Needed
-
I am working on configuring my 3rd Retropie build. I have a 3B and a 4 already configured, both with bluetooth controllers. In both cases, ScummVM worked with the controller (for mouse movement) more or less out of the box.
This new one has some challenges. Let me explain...
I have a GPi Case 2 from Retroflag. It more or less looks like an old-school Gameboy, with a built-in gamepad. It also comes with a docking station to connect it to a larger display and USB devices. I have a USB keyboard and mouse connected to the dock, as well as a paired Xbox One bluetooth controller.
The idea is that when on the go, I would naturally use the built-in controller exclusively.
But when docked, I would use primarily the bluetooth Xbone controller and maybe the keyboard/mouse when needed. With the help of @meleu's joystick-selector scripts, I have it working for most systems. The Xbone becomes player one when it is connected and Retroarch defaults to the built-in otherwise.For ScummVM, I cannot seem to get it to recognize either controller.
Mouse and keyboard work fine when docked. But changing the joystick setting in the start.sh script, I can get the Xbone controller to be recognized, and move the pointer with the left stick, but the mouse pointer snaps to the upper left corner of the screen as soon as I let go. The built-in dpad never works as a mouse, but in the gui I can go up and down the list and start a game, or exit with Y.
Would love some help here.
-
I have successfully mapped the GPi Case 2 controls to the mouse for Scummvm. For those with similar challenges, here is what to do:
Required:
- USB C mouse -- I used a USB-C male to USB-A 3.0 female adapter
Steps:
- With GPi Case 2 un-docked connect a usb mouse
- Boot Retropie and open ScummVm launcher/main (i.e. not a game)
- In the launcher's Options menu, open the key mapping.
- First, map the “gui” controls up/down/left/right to something other than d-pad. I set them all as left shoulder. Failure to do this makes the system default these back to d-pad and undo your mouse mapping.
- Then map the virtual mouse directions to the d-pad.
- Make sure the other primary controls look okay, specifically a button to open the main in-game. Map any missing that you need.
Then, in most games, you will need to bring up the menu the first time and unmap the directionals from the d-pad. You must map another button instead, or else the mapping will be removed on restart. (Recommend 'select', which seems un-used elsewhere.)
By default, the d-pad would move the character around, not the mouse. Once removed, your d-pad will control the mouse. I found it very helpful to use right shoulder to slow the virtual mouse.
-
-
I have found a solution to the ScummVM challenge for the GPi Case 2.
It's important to understand the underlying problem. The built-in Retroflag controller is recognized as an XBOX 360 controller. Importantly, it is in the first position. When you have the GPi Case 2 on the dock, the controls are disabled, but the system still recognizes the controller in position 1.
@meleu's joystick-selector scripts work very well to re-order the importance/preference of connected controllers so that -- for Retroarch systems -- your connected Bluetooth can be dynamically set to the first position. (Though if you disconnect your Bluetooth controller, you usually have to reboot to change the pattern.) ScummVM though doesn't recognize the Retroarch order. If you view the /dev/shm/runcommand.log you will continue to see (as an example):
Executing: bash /home/pi/RetroPie/roms/scummvm/+Start\ ScummVM.sh "dig" Using game controller: X360 Controller
The solution I found is the script equivalent of unplugging the 'USB controller'. You'll note in the following scripts, that I only do this for ScummVM. As I said, the joystick-selector works great for me for the other systems. If you wanted to, you could certainly forego that method and use this way for all systems by removing the 'if' surround.
What I'm doing here is taking advantage of Retropie's runcommand scripts which execute before and after the emulator. Before ScummVM executes, the script will 'unplug' the X360 Controller, and after ScummVM closes it will plug it back in. (Conceptually.) One of the benefits here is that if anything screws up, reboot fixes it, so it is very low risk.
Here's what to do....
Using either F4 or remote PuTTY connection:
- Edit the script using sudo nano /opt/retropie/configs/all/runcommand-onstart.sh
- Add the following to the bottom :
if [ $2 == "scummvm" ] then export padName="Xbox Wireless Controller" export tmpfile="xpad-local.tmp" unset xpad read xpad < <(ls -l /sys/bus/usb/drivers/xpad/ | grep ">"| grep -v "module" | cut -d ":" -f 2 | cut -d " " -f2) read btPad < <(bluetoothctl devices | grep "$padName" | cut -d " " -f2 | xargs bluetoothctl info | grep "Connected" | cut -d " " -f2) echo "Found xpad at $xpad, emulator is $2" >&2 if [ $btPad == "yes" ] then echo "$padName is connected" >&2 else echo "No bluetooth controller" >&2 fi if [ -n "$xpad" ] && [ $btPad == "yes" ] then echo "ScummVM and Xpad found. Bluetooth controller is connected. Unbind xpad." >&2 echo $xpad | sudo tee /sys/bus/usb/drivers/usb/unbind > $tmpfile fi fi
- Make sure to change the padName variable to match how your Bluetooth controller is reported. If you aren't sure, execute this command: bluetoothctl devices to find out
- The last step is make the script executable (if it is not): sudo chmod +x /opt/retropie/configs/all/runcommand-onstart.sh
Now, let's set up the script for after the game exits:
- Edit the script using sudo nano /opt/retropie/configs/all/runcommand-onend.sh
- Add the following to the bottom :
export tmpfile="xpad-local.tmp" if [ -f "$tmpfile" ] then echo "Xpad rebind tmp file is found... rebinding" >&2 read xpadpath < $tmpfile echo $xpadpath | sudo tee /sys/bus/usb/drivers/usb/bind >&2 rm $tmpfile else echo "Temp file for xpad recovery not found" >&2 unset xpad read xpad < <(ls -l /sys/bus/usb/drivers/xpad/ | grep ">"| grep -v "module" | cut -d ":" -f 2 | cut -d " " -f2) if [ -n "$xpad" ] then echo "Xpad is active" >&2 else echo "Xpad is not mapped but rebind file not found. Reboot required. Verify script is correct" >&2 fi fi
- Again, we need to make the script executable (if it is not): sudo chmod +x /opt/retropie/configs/all/runcommand-onend.sh
Your controller should now be set up to work. Like above, in most games, you will need to bring up the menu the first time and unmap the directionals from the d-pad. You must map another button instead, or else the mapping will be removed on restart. (Recommend 'select', which seems un-used elsewhere.)
For me, the Xbox One wireless controller analog stick does not work right for mouse control, but the d-pad works fine. I blame the controller. I may ultimately try a different brand, but I'll need the script either way, as best I can tell.
Hope this helps!
If you want to learn more about the runcommand, documentation is here: https://retropie.org.uk/docs/Runcommand/ -
-
One point to note. On my GPi it looks like I could probably have hard-coded the value to unbind/bind the built in controller. But I felt it was taking a risk it wouldn't work right. So, instead, I use a temp file to pass the value between scripts.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.