The Xarcade Tankstick is a nicely designed and very robustly constructed arcade game controller. It offers buttons and joysticks for two players together with start and coin buttons, an arcade trackball, and dedicated pinball buttons.
Being asked, if RetroPie could have in-built support for the Xarcade Tankstick I started to dig into this controller which, in the end, lead to the development of Xarcade2Jstick, a user-space daemon that lets the Tankstick register as two individual game pads on a Linux computer. It integrates seamless in a RetroPie installation and, thus, makes the usage of a Tankstick with RetroPie extremely easy.
The next part describes the motivation for the work on Xarcade2Jstick. Afterwards the functionalities and architecture of Xarcade2Jstick are explained. It is described how to download, build and install the driver. After that, details about the support of Xarcade2Jstick by the RetroPie and especially the RetroPie-Setup Script are given.
The user-space driver Xarcade2Jstick
The Linux kernel registers the joysticks and the buttons of the Xarcade Tankstick as a single USB keyboard device. If you are connecting the according USB connector for the arcade trackball with your host machine, the kernel registers it as an USB mouse.
Because a keyboard is probably the most basic input device for a computer and every emulator supports the keyboard as input device this approach gives the user a huge amount of freedom regarding the configuration and application of the Tankstick when used with emulators. There is, however, at least one situation, in which it would be of advantage when the Tankstick would be registered as, say, two game pad devices instead of a single keyboard. More specifically, I came into this situation when I thought about a way for switching automatically to the Tankstick as input device when it is connected to a computer with a RetroPie installation: The front-end EmulationStation looks for game pad devices for its assisted input configuration. Also, all emulated systems that rely on the RetroArch emulator make use of the auto-configuration functionality. This function loads an input configuration depending on the currently connected game pads. Last but not least some other emulators like PiFBA come with a ready-to-go game pad configuration.
These points were the motivation for developing Xarcade2Jstick. The next section describes the functions and also gives a brief overview about its software architecture.
The use cases for the Xarcade2Jstick daemon are as following:
- Detect a connected Xarcade Tankstick
When starting, the tool detects a connected Xarcade Tankstick.
- Map Xarcade Tankstick event to game pad event
The tool listens to the events of the Tankstick and maps every received event to an according game pad event.
- Map alternative function event to keyboard event
If certain button combinations are pressed on the Tankstick, alternative keyboard events are generated.
The following diagram shows the dependencies between the modules:
The Xarcade Tankstick is abstracted by the module “input_xarcade”. The input_xarcade” module, in turn, is using the Linux “input” module. These modules are responsible for capturing the original keyboard events from the Tankstick. Most of the keyboard events are mapped to corresponding game pad events. Certain key combinations are mapped to keyboard presses: COIN1+Start1 is mapped to TAB and COIN2+START2 is mapped to ESC. These virtual game pad and keyboard presses are abstracted by the modules “uinput_gamepad” and “uinput_kbd”. These two modules are using the Linux “uninput” module for realizing these user-space input events.
First of all, the Xarcade Tankstick is identified and opened exlusively by Xarcade2Jstick. Afterwards, two game pads and a keyboard are registered via the uinput module. Then the main loop is started. It consists of reading the events of the Xarcade device and of mapping the events to the virtual game pads and the keyboard.
The following installation and usage manual is taken from the Github site of the tool:
If you would like to download the current version of Xarcade2Jstick from its Github repository, you can use this command:
git clone https://github.com/petrockblog/Xarcade2Jstick
Building and Installation
To build Xarcade2Jstick follow these commands:
cd Xarcade2Jstick make
If everything went fine you can install with the command
sudo make install
Installation as Service
You can install Xarcade2Jstick as daemon with this command:
sudo make installservice
Xarcade2Jstick looks for an Xarcade device when it is started. That means you need to connect your Xarcade before Xarcade2jstick is started. When using Xarcade2jstick as a service, you could shutdown the RPi, connect the Xarcade and start your Rpi again.
Uninstalling the service and/or the binary
You can uninstall the daemon with this command:
sudo make uninstallservice
You can uninstall the binary with this command:
sudo make uninstall
Support in the RetroPie-Setup Script
If you would like to use Xarcade2Jstick in combination with a RetroPie installation you have at least two options:
- You can follow the steps as described above from the terminal. Xarcade2Jstick can easily be built and installed with the Makefile that comes with its sources.
- You can use the RetroPie-Setup Script for downloading, building, and installing Xarcade2Jstick. The RetroPie-Setup Script got updated recently to support the Xarcade2Jstick configuration from within the “Setup” menu. Furthermore, it contains a configuration file for the auto-config functionality of RetroArch.
RetroPie is fully prepared to seamlessly work with Xarcade2Jstick.
If you would like the Xarcade Tankstick to be registered as two individual game pads on a Linux machine, the program Xarcade2Jstick might be a solution for you. It exclusively captures the original keyboard events and maps these to the corresponding game pad events. Furthermore, the Shift-key functionality is also made available by Xarcade2Jstick, so that virtual keyboard presses of TAB and ESC are still possible.
Xarcade2Jstick can easiliy be installed and can also be installed and configured with the RetroPie-Setup Script.