Quake 2 with gyro aiming using a Switch controller
-
If you use your RPi with a Switch Pro Controller or joycons, this will allow you to play Quake II with motion aiming, like Splatoon, Breath of the Wild and many other console games.
Requires dkms-hid-nintendo to work, so people that followed these instructions to make their controllers work are ready.
This has been tested with an original Pro Controller, wired and wireless, and with two joycons in "combined mode" (using joycond), where only gyro in the right joycon is used.Installation
Enter RetroPie-Setup, go to "packages" -> "experimental" -> "yquake2", and install it, or update it to (at least) version 8.30 if you haven't done it yet. Binaries are available, no need to compile on your side.
Before starting the game, you must provide a "gamecontrollerdb.txt" file with the SDL2 controller mappings of axis and buttons. If you don't know where to get it, see the end of this post, in the section gamecontrollerdb.txt, and save it as a text file with that very name; that should work for most official Switch controllers. If it doesn't, comment here.
This file must be copied in the~/.yq2/
directory, or the game directory (/opt/retropie/ports/yquake2/
).Run the game, and it should detect the controller right away (read "troubleshooting" if it doesn't). Go into "options" -> "customize gamepad" -> "gyro options", and calibrate the gamepad by leaving it alone in a flat, stable surface and choosing "calibrate". If it fails, move it a little bit (to wake it up? I don't know) and try again. Inside "customize gamepad" menu you can customize buttons, "alt" buttons (functions of the same buttons while you have the "modifier" button pressed), and more. After that, just start a game.
You can change sensitivities from the "gyro options" menu, which uses a "natural scale", meaning that in 1.0 sensitivity, a 90º turn left with your controller will make your character do a 90º turn left, while in 2.0 sensitivity will do a 180º turn. Enjoy!
Known problems
- Calibration fails at the start: It seems that the "second joystick" have to be active a little bit to remind the game it's there. The normal "sensor" version of this implementation doesn't have this problem.
- Drifting view: No matter how much you calibrate your gyro, you'll see that there's a very small "drifting", your in-game view moves slowly in one direction. Blame the "second joystick" for it; joystick axes have integer values, and sensors give values in floating point, so precision is missed in this implementation; it doesn't hinder the experience IMHO. Again, "sensor" version doesn't have this.
- IMU detection with more than one controller: If you try this with two Switch controllers connected, you may find one gamepad works with the game but uses the gyro of the other one. As the only thing that gives away their functionality is the name, and I still don't know the order in which SDL2 reads the controllers, it's very hard to associate one gamepad with its corresponding IMU sensors. So, don't test your luck, and use only one controller (one Switch controller, at least) when playing Q2. And yeah, it doesn't happen in the other version, since sensors are easily associated with their controller.
Troubleshooting
-
Gamepad inputs not detected: gamecontrollerdb.txt must exist either in the game directory or the user directory (~/.yq2/). If the one included doesn't work, a more complete version is available here:
https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
Note that it must comply with the SDL2 2.0.10 standard, meaning it must NOT include "misc1", "paddle" or any other unrecognized button for this SDL2 version. -
Gyro not working: check if the "second joystick" exists and works. In command line, do
ls /dev/input/
and you should have at leastjs0
andjs1
when having a single controller connected. Usejstest /dev/input/js1
and check the joystick's name, it should end in "IMU". When you "waggle" it, axes 3, 4 and 5 should have their values changed for an instant. If you're missing something from here, remember if you followed these instructions to make your controller working, because you need dkms-hid-nintendo for this.
Please comment if there's something missing or unclear, and please take a look at Yamagi Quake 2 version 8.20 in other platforms, which includes my "sensor" version of this gyro implementation; it supports DualShock 4 and more gamepads on Windows, Linux and MacOS. Happy fragging with motion controls!
EDIT November 2023: Included officially in YQ2 8.30, with binaries available in RetroPie.
gamecontrollerdb.txt
# Nintendo Switch controllers with correct button labels - single Joy-Cons excluded # Linux only, SDL 2.0.10 format (no misc/paddle buttons). # The "Fightpad Pro" might be wrong, needs verification. Some of these might not have a gyroscope. # Adapted from https://github.com/gabomdq/SDL_GameControllerDB 030000000d0f00008501000015010000,Hori Switch Split Pad Pro,a:b1,b:b0,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,platform:Linux, 050000000d0f0000f600000001000000,Horipad Switch Pro Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, 060000004e696e74656e646f20537700,Nintendo Switch Combined Joy-Cons,a:b1,b:b0,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, 060000007e0500000620000000000000,Nintendo Switch Combined Joy-Cons,a:b1,b:b0,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, 060000007e0500000820000000000000,Nintendo Switch Combined Joy-Cons,a:b1,b:b0,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, 050000004c69632050726f20436f6e00,Nintendo Switch Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, 03000000d620000013a7000011010000,Nintendo Switch PowerA Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 03000000d620000011a7000011010000,Nintendo Switch PowerA Core Plus Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 030000007e0500000920000000026803,Nintendo Switch Pro Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux, 030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, 050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, 050000007e0500000920000001800000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, 030000006f0e00008001000011010000,PDP Faceoff Nintendo Switch Pro Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 030000006f0e00008701000011010000,PDP Rock Nintendo Switch Candy Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, 030000006f0e00008501000011010000,PDP Nintendo Switch Fightpad Pro,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b0,platform:Linux, 030000006f0e00008701000011010000,Rock Candy Switch Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
-
Even if no one cares, I'm happy to announce that the "sensor" version finally made it to the master branch of Yamagi, ready for the next release.
EDIT: Included in Yamagi 8.20, for all platforms that support at least SDL 2.0.14.
Direct Windows link:
https://deponie.yamagi.org/quake2/windows/quake2-8.20.zipRemember to calibrate gyro the first time you play. It can be done in Options -> customize gamepad -> gyro options.
-
This has been updated, and now includes Flick Stick control mode:
You must select it in the "options" menu -> "gamepad" -> "sticks config" -> "layout" option.
Southpaw variant available, just like the rest of the layouts.
Just wanted to post, because it's probably the first game with this control method available in a Pi. Works with no issues in a RPi3B+.
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.