Xarcade2Jstick – Map your Xarcade Tankstick to Game Pads and use it with RetroPie

IMG_2165_480The 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.

Functionalities and 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:
xarcade2jstick1The 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.

The following diagram shows the program flow of Xarcade2Jstick:

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.

Installation and Usage

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

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:

  1. 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.
  2. 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.

Check Also

Quick Installation Script for the ControlBlock

We realized that the installation of the ControlBlock driver could be simplified. Therefore, we created …

  • Miggy

    Does this only work with the Tankstick? What about the DualJoystick?

    • For the development of Xarcade2Jstick I only had a Tankstick available. However, the keyboard outputs seem to be the same so that Xarcade2Jstick should also work with a DualStick.
      It would be great if you could test this out. In case it does not work out-of-the-box I could try to extend Xarcade2Jstick accordingly with your feedback!

  • RetroPiMan8

    Great work – thanks! I did run into some probs: ran though the install directions for Xarcade2Jstick and it it now works for certain systems (arcade), but not for others. Tried the Setup script afterwards, and although recognized, when auto-config ran, each button was “Timed Out”. Also, for those that worked, COIN + Start are Exit commands for P1 and P2 – anyone else have these issues or are able to solve? Additionally, are there any ideas for hotkeys on the tankstick? Thanks again.

    • There already comes a config-file with the RetroPie-Setup Script for the RetroArch-based emulators. So there should be no need for running the auto-config from within the Setup Script again. It might be overwritten now, though.

      For which systems is it working and for which not?

      • RetroPiMan8

        Seems like only only the arcade and master systems work. Others resort back to the keyboard controls. I am able to use the COIN 2 + Player2 exit command on some that are not recognizing the tankstick. Tried updating source/binaries which later showed “Enable Xarcade2Jstick” on the setup script. Tried that and then running the install commands again for Xarcade2Jstick but no luck. Any ideas?

      • RetroPiMan8

        To specify, only coin-insert and GG systems work, all else falls back onto the keyboard.

      • The RetroArch-based emulators (e.g., SNES, NES, Genesis/Megadrive) should also work, if you have the file Xarcade-to-GamepadDevice.cfg (see https://github.com/retropie/RetroPie-Setup/blob/master/supplementary/RetroArchConfigs/Xarcade-to-GamepadDevice.cfg) located in /home/pi/RetroPie/emulators/RetroArch/configs/

      • Shibo

        I recently picked up an X-Arcade dual stick (2 player, not the tank stick) and have been having some config issues. I attempted to use the Xarcade2Jstick, but that did not appear to work for the dual stick controller. Additionally, configuring this seems rather troublesome on its own. I have most buttons working, but it is not perfect yet.

        I have seen other posts from you (or another mod), such as the post below, looking for help to possibly extend Xarcade2Jstick to support the dual stick and I would be happy to help.

        Another question though:
        I do see the Xarcade-to-GamepadDevice.cfg in the appropriate directory, does this override the config files you can setup in ~/RetroPie/configs/all/* when launching using an Xarcadestick or is it simply a reference file for (example) default values?

      • Yes, the settings in Xarcade-to-GamepadDevice.cfg override the settings in ~/RetroPie/configs/all/retroarch.cfg. However, this is only a RetroArch function and works only, e.g., for SNES, NES, Genesis/Megadrive, FBA. You can see that this function is working when starting a ROM and the emulator says on the bottom screen that it is using Xarcade-to-… .

        For further work on the support for the DualStick, let us switch to the according forum post at http://blog.petrockblock.com/forums/topic/retropie-not-recognizing-xarcade-dual-tank-stick/#post-9953.

  • AnthonyG

    Ok, so I tried the commands above and got zilch, said there was no such thing as the link you have posted. Is there someplace else that this is hosted? I’ve downloaded things just fine from Github before but I guess this just doesn’t work for me or is no longer there.

    To make a long story short, I have an X-Arcade Tankstick I’d like to mount my Raspberry Pi B+ in but I’m having some trouble getting all the controls to work, found out that Cave Story was pretty much just fine but Doom/etc just wasn’t having it. This is my first little jog into both Raspberry Pi hardware and Linux software, I’m even having trouble getting Tightvnc to run on startup… I know, pretty bad.

    • AnthonyG

      Alright, apparently I can’t get tightvnc to run on startup otherwise EmulationStation refuses to start and I was missing part of the link when trying to download the files. So…I got it, I think. Now I just have to hook up the controller and actually try it. If anyone else has got this to work (emulationstation control and in the individual emulators) I could probably use some help.

  • kwoodrg

    I cannot get the trackball to work at all. It works as a mouse in X, but doesn’t do anything at all in MAME. There seems to be no way to use a trackball for MAME in RetroPie at all.

    • Vincent Gill

      I am getting the same problem, the trackball works in scummvm environment just not in mame? is there a config setting I am missing

      • Calimetjohn

        Wondering if u figured the trackball out yet? I’m having the same issue

  • Robert Haddad

    Does this work with RetroPie 2.3? Because the X-Arcade works (Player 1 only) before I install Xarcade2Jstick then stops working in ES altogether after. Am I missing something? Thanks in advance

    • Xarcade2Jstick maps the inputs of the Tankstick to gamepad devices under Linux. That means that you have to re-configure ES for the gamepad devices after switching to Xarcade2Jstick.

      • Robert Haddad

        How do I do that on RetroPie 2.3?
        I’ve tried to run ./esconfig.py which works in the command line and I’ve done “Register RetroArch controller from RetroPie-Setup, but once I get back to ES none of the controls work

  • Pete

    I have a Raspberry Pi 2 running RetroPie 2.6.0 RP2 image. I have run the Xarcade2Jstick option on the menu of the RetroPie-Setup script. When I rebooted, it now recognizes two gamepads, but it wants me to configure them (Press Up, Down, etc.). When I did that, now MAME does not recognize any of the other buttons. What am I doing wrong? Do I even need to configure them?


    • Do you have an Xarcade Tankstick connected to the RPi? Or some other model? Depending on the configuration, Xarcade2Jstick emulates two gamepads or a virtual MAME keyboard. That might also be a cause for what you observe …

      • Pete

        Thank you for the reply.

        I have a Raspberry Pi 2 Model B running RetroPie 2.6 for the Pi2. I updated the debian software and the RetroPie scripts before I ran the Xarcade2Jstick option.

        When I first boot, I am asked (I am assuming by EmulationStation) to configure Joystick 1 – and I did that. It worked fine. I was then taken to ES and was able to use the joystick and buttons I had setup to navigate the menu and run MAME. I selected a ROM and went into the game. Once in the game, none of the other buttons worked – Player 1, Player 2, etc. I was not able to insert a coin or start a game.

        I hooked the USB keyboard back up to the Pi and was able to use the buttons on the keyboard to insert coins (5) and start a game (1).

        The problem might be me – maybe I don’t know how to use the virtual keyboard or I have missed some configuration step in setting up the other buttons on the Tank.

        As a side note, once I was in the game, the joysticks were great. It definitely had the arcade feel. Can’t wait to get the other buttons working.

      • jac818

        Did you ever get a fix for the coin and player buttons?

      • Calimetjohn

        Do u know if there is a way to get the tankstick trackball to work with golden tee in advmame? I can go back and forth but it is really jerky and the cursor for mouse is always on the screen. Seems like when the cursor get to top or bottom of screen it stops working.

  • Frank Branham

    I’ve just started playing with the Pi2 and RetroPie for a few days. It does look like this driver is essential for classic cart systems, but I’m finding that mame4all behaves better with this disabled. (Especially as this driver kills the Tankstick’s trackball support.)

    Any idea how to enable this just for libretro-based emulators? Perhaps an option to runcommand.sh?

  • Joe

    I have this setup, but i want to remap per emulator (I know how to bring up the menu for that) My question is is there a file/document that tells me which button on the tankstick is which virtual joustick button?

  • Joe Scott Volpe

    Is there a solution similar to this for 4 x arcade joysticks?

  • Spikep

    I’ve had retropie working for a month now with 2 xbox 360 controllers except it never worked with any mame ROM’s, I didn’t dig in to it too much, considering I was getting a Xgaming Tankstick. I disconnected the Xbox 360 controllers and now I have the xgaming tankstick connected. Raspberry Pi 2 with retropie recognizes the tankstick and it works with NES and other consoles. Just not with MAME ROMS.

    After 6 hours of reading, I’m still not sure what the heck I’m missing. Any clues?

  • Dolf Muccillo

    Does this work under RetroPie 3.6 and Raspberry Pi 3? I have followed the instructions precisely and it doesn’t seem to work. Any help would be appreciated. Would love to see this TankStick support built-in to RetroPie. 🙂

    • THG

      I used the git command to snag it. It recognizes both sides now, but it leads to a different problem.

  • THG

    I followed the directions, and both sticks work now. However, the select+start bail out of a game no longer works (it worked while the system recognized the X-Arcade as a keyboard). Needless to say, this is a problem, and I would love some help with this.

    Raspberry Pi 3 on Retropi 3.6

    Current map has the Start button as the Player buttons (1st and 2nd player), and the Select button as the “Modify” buttons on either side of the housing.

    • Jake Pearson

      I’m having the same issue. Did you come up with a workaround?

      • THG

        Hey guys, I’m on the phone so I have to keep it short. Basically I Uninstalled the script and the driver, and used it as a keyboard, then manually adjusted the retroarch configuration files in each emulator folder.

        Works like a dream now.

      • Mike

        I was able to get around this by modifying the retroarch.cfg file to use button 6 instead of button 8 for the hotkey enable button. From what I understand, the Xarcade2Jstick code uses the combination of Start+Select to send a TAB button press so the system never sees the exit command but a TAB command instead.

      • JohnnyPickleBreath

        hi mate I know this is an old thread but I’m trying to setup a tankstick with trackball for my brothers arcade cabinet and going slightly insane. Any chance you can share the config files as i’m not much of the coding type?


      • THG

        # Key to exit RetroArch cleanly.
        input_exit_emulator = num4
        input_enable_hotkey = num3

        # Keyboard input, Joypad and Joyaxis will all obey the “nul” bind, which disables the bind completely,
        # rather than relying on a default.
        input_player1_a = z
        input_player1_b = shift
        input_player1_y = ctrl
        input_player1_x = alt
        input_player1_start = num1
        input_player1_select = num3
        input_player1_l = space
        input_player1_r = x
        input_player1_left = left
        input_player1_right = right
        input_player1_up = up
        input_player1_down = down
        input_player1_l2 = c
        input_player1_r2 = num5
        # input_player1_l3 =
        # input_player1_r3 =

        input_player2_a = e
        input_player2_b = w
        input_player2_y = a
        input_player2_x = s
        input_player2_start = num2
        input_player2_select = num4
        input_player2_l = q
        input_player2_r = leftbracket
        input_player2_left = d
        input_player2_right = g
        input_player2_up = r
        input_player2_down = f
        input_player2_l2 = rightbracket
        input_player2_r2 = num6
        # input_player2_l3 =
        # input_player2_r3 =

      • JohnnyPickleBreath

        wow sorry for the late reply mate . I don;t use disqus as much as I used to. But thank you very much! so did you enter that via the emulation stain or by putty to the PI?

      • Anthony

        I ran into the same problem with a Pi3 on Latest Retropie over the weekend. Fixed it by adding a keyboard to the retropie configuration and mapping buttons 1 and 2 to select and start, I then hacked the Xarcade2Jstick code to send 1 and 2 when the select and start buttons are pressed. It works 100% like this but it is a complete hack. You can find details on what I did here:

        Still works once the keyboard is removed you just add it so that you can setup the key bindins in retroPie

    • peter rubino

      Same here can’t figure it out

  • dsstrainer

    I have a ps2/usb Tankstick. When I plug it into my pi and do sudo lsinput it doesn’t show as “XGaming X-Arcade”, It shows as “HID 1241:1122”
    So when I run the service, it doesn’t find the tank stick.
    How do I get it to find the correct name for this?

    • dsstrainer

      Turns out i was only connecting the mouse ball, not the joysticks with the DB9 to usb connector. Working great now

  • Jean-Francois Gosselin

    Does it work only with the tankstick ? Meaning does it work with the regular two joystick X Arcade ?

  • Domenico Russomanno

    I need some serious help with this…. is there a step by step walk through from start to finish for a complete noob using a mac. Do i stop after sudo make install??
    Sorry, just finding it a bit hard to understand

  • Domenico Russomanno

    Has anyone got this actually working properly functioning? I mean with the trackball and being able to exit MAME games properly? This is driving me crazy!!

    • Domenico Crisan

      Did you find any solution on this? I couldn’t find any information on how to get this damn trackball to work with RetroPie!

  • Daniel Deering

    So I followed the instructions and it works except I can’t exit the roms. Any ideas on what I should do to the config files?

  • Will Wear

    Installed and enabled in the retropie-setup script. Still just sees the X-Arcade as a keyboard. What am I missing?

%d bloggers like this:
Skip to toolbar