Support us on Patreon to keep GamingOnLinux alive. This ensures all of our main content remains free for everyone with no article paywalls. Just good, fresh content! Alternatively, you can donate through PayPal, Liberapay or Buy us a Coffee. You can also buy games using our partner links for GOG and Humble Store.
Python key remapping software quit working on upgrade
Page: 1/2»
  Go to:
TherinS 19 May, 2019
Hello there!

New to forums but followed the site for a few years now. I have used the Belkin Nostromo n50 and n52 and the Razer Tartarus on both W and Linux for a number of years, but since I upgraded my box from Ubuntu 16.04 to 18.04 my remapping software does not function as its supposed to. I can tell it is doing some kind of mapping because the n52 has LED lights that I can map to any key and they do indeed blink when I use them, but the keys do not function when remapped to standard US keyboard keys.

I have tested this on a fresh Ubuntu MATE 18.04 install and a live USB 16.04 version on a laptop, thus verified its not just my installation.

The Python program is called Pystromo and has been around since about 2008, but the creator of the program no longer wishes to help with troubleshooting or anything. It seems to me that either something in the newer kernel dealing with input has changed or it could be with Python itself (libraries or some such). The original code was for Python 2, and another person on Github has a repo with (supposedly) Python3 compliant code but it does not work for me with either 16.04 or 18.04, returning some error messages in the terminal about unable to find modules.

I am no coder or programmer so I have no idea what might be the cause nor how to apply a fix. I am asking for help or a kind pointing-out where to ask for help getting this program to function correctly. Here is a link to my Github page where you can find copies of the original programs and a few blank map files you can use to test with. I will upload some simplified instructions soon to help with installing and using Pystromo, as the instructions included in the tar.gz file jump around alot.

Pystromo should work with ANY USB device as long as it is wired or the "lsusb" command recognizes it because Pystromo uses the USB ID to apply the remapped keys. For example, I found I could remap the buttons on my Razer Mamba wireless mouse, but there is no pass-through for the LED so it can only act as keyboard button presses when moving the mouse around. For any other USB device I think it should work great, maybe even for a USB keypad device (imagine one key bound to CTRL-ALT-T and another to type "sudo apt update" and "return" key, or entering alias names).

I eagerly await your replies or questions....
tuubi 19 May, 2019
Any sort of error output you could give us? Or maybe you've submitted a detailed bug report we could take a look at? "It does not work" and "returning some error messages in the terminal about unable to find modules" are not very helpful.

As a first step, you could try installing the missing python 3 module dependencies with apt, or if that fails, pip. You might also want to try running the script as root if you didn't already. This could be an uinput permissions issue.
whizse 19 May, 2019
  • Supporter
Poked around the Python 3 port, but it seems to have been an effort that was started but never completed. A lot of basic stuff like the ioctl stuff needing bytes and not python strings, wouldn't expect it to work at all.
TherinS 20 May, 2019
I realize that detailed error messages might be in order, however, the 0.6.0 (Python2) version does NOT return any error messages at all. It works just fine in Ubuntu / Ubuntu MATE 16.04; it is only since the upgrade to 18.04 that it appears to not output anything to text files or a terminal (following the same install instructions and using the same .map files that worked fine in the 16.04 install).

The 0.6.1 version returns error like the following:

changes to pystromo files
----- v61
Map picker Zenity script runs fine untill last lines,
where it loads the selected map file using

The following errors occured with these actions:

Run as is, the following error occurs:

Traceback (most recent call last):
  File "./", line 22, in <module>
    from lib import mapping
  File "/home/steveum-ssd/software/Pystromo-master/pystromo/lib/", line 7, in <module>
    from config import _BaseConfig
ImportError: cannot import name '_BaseConfig'

===== STEPS TAKEN =====

1)put "python" at end of file home/steveum-ssd/.config/caja/scripts before ./
    Result= error after 'import ioctl' from import devices
    about no module named ioctl


Traceback (most recent call last):
  File "./", line 23, in <module>
    from lib import devices
  File "/home/steveum-ssd/software/Pystromo-master/pystromo/lib/", line 10, in <module>
    import ioctl
ImportError: No module named ioctl
** END**

2)put "#!/usr/bin/env python3" at beginning of 
    Result=same as first error
3)-put "#!/usr/bin/env python3" at beginning of
    Result=same as first error

Whizse noted above that the python3 version (0.6.1) apparently has some missing/erroneous code in it, so that may explain why that version fails. Perhaps someone would be willing to poke further and make the 0.6.1 (Python3) version work? That would future proof the program, as Python2 is being slowly phased out.

I am unfamiliar enough with Python that I was unaware modules could be installed like normal packages; I thought the entire Python library was installed by default. To back my assumption, I just now opened Synaptic on this Ubuntu 18.04 box and searched for the package "ioctl"; there were no matching results for that name specifically.

Please let me know what other info you might need to help me with this, but running the program and checking the results for yourself might be the best way, as I cannot reply with what error messages it throws when there are none. I do appreciate your replies though and I wish to continue this exchange.
tuubi 20 May, 2019
I wouldn't be surprised if this was all about security. The software might be used as a crude keylogger. Did you already try my other suggestion?

Quoting: tuubiYou might also want to try running the script as root if you didn't already. This could be an uinput permissions issue.
If that's the case, you might be able to solve it by adding an udev rule (like steam controller users had to do at some point I think).
legluondunet 20 May, 2019
It's an old software (2008) no longer under active developed.
Try a more recent keymapper like Antimicro:
no more under development but more recent.
Or if you have a Steam controller, use sc-controller:
TherinS 21 May, 2019

Yes, I tried both apt and pip install ioctl, one of the "cannot find" errors the 0.6.1 version displayed and no such package was found in Ubuntu 18.04.

When you talk about permissions, you may be on to something. Do I need to add the user to a udev rules setting somewhere? As stated in the installation script and the 0.6.0.tar.gz package on installing Pystromo (which are both available in my Github link), there is a step that looks like the following:

echo 'uinput' >> /etc/modules
modprobe uinput
cp $install_path/pystromo/config/52-pystromo-debian.rules /etc/udev/rules.d/
udevadm control --reload-rules
udevadm trigger

If I need to add the user to a group to have udev rules access, what is the command to do that?
When I type $ groups I get this:
adm cdrom sudo dip plugdev games lpadmin sambashare

There is no udev group so what should I add myself to?

Yes, I ran
$ sudo ./ -m ./custom_maps/
and had no different effect: only the remapping of the keys to light up the LEDs on my Nostromo n52 had any effect. Any other normal keyboard keys resulted in no discernable output.
Antimicro does not support anything but hand held controllers, I have found. No support for Belkin/Razer gameboards.
I do not have a Steam controller, just a Madcatz, XBox 360 and PS4 controllers. Thanks for the suggestion though.

The thing is that I have been using Pystromo to remap the keys on my Nostromo n50, n52, and Razer Tartarus in Ubuntu 12.04, 14.04, and 16.04, plus older versions of PCLinuxOS and Linux Mint and it has worked fine until Ubuntu 18.04 and the latest PCLinuxOS. Again, I verified on my 16.04-to-18.04 upgrade box, a fresh 18.04 Ubuntu MATE install, and a live USB of Ubuntu MATE that the 0.6.0 version does do SOMETHING, but only outputs LED lights changing. I then tried a live USB of Ubuntu MATE 16.04 and it indeed worked exactly like I expected, with all key remapping working just fine. To me that could mean a kernel/Python2 change with the way permissions or input are handled or a location of where the file(s) is supposed to go.

Feel free to visit the Github page I mentioned in my first post and use the easy install script, but check the readme first in case you don't like where I have it install stuff. I will upload some simplified instructions for making .map files for devices in the next couple days.

Thanks and looking forward to replies...
whizse 22 May, 2019
  • Supporter
I set it up with a USB keyboard and a very simple .map file (translating tab presses to ones). It seems to be reading the events and doing the translation successfully, but injecting the events have no effect. -v -v -v -v -m
Using output: <lib.devices.OutputDevice object at 0x7fa55b4bf050>
Loading mappings
Using device: <InputDevice "ultraxkeyboard" on 3 device nodes>
Incoming event: <Event timestamp=1558482457.31721, type='EV_KEY', code='KEY_TAB', value=1>
Outgoing event: <Event timestamp=1558482457.32799, type='EV_KEY', code='KEY_1', value=1>
Incoming event: <Event timestamp=1558482457.397204, type='EV_KEY', code='KEY_TAB', value=0>
Outgoing event: <Event timestamp=1558482457.407962, type='EV_KEY', code='KEY_1', value=0>

grep'ing through the source, it doesn't look like it's using UI_SET_KEYBIT, not sure if that's the problem?
TherinS 22 May, 2019
Additionally, as whizse noted above, I've found that any USB device that is recognized by the kernel upon plugging in (like keyboards and in this case the Nostromo/Razer devices) will return input function per the instructions. Again, using a version of Ubuntu/derivative older than 18.04 should enable full functions of Pystromo.

(I still need to upload decent instructions for configuring new devices but until then they can be found with a web search.)

An example of something that does not have a driver loaded by the kernel is the Logitech G13 gameboard. You can see it is recognized by doing "$ lsusb" but there is no driver so it does not respond at all in my tests. There are a couple of projects for that and I can link to them if there is interest.
TherinS 24 May, 2019
To make it easier to test and show how well Pystromo works/worked on Ubuntu BEFORE 18.04, I uploaded some installation and configuration documents on my Github page here:

If anyone has some suggestions for getting it to work on 18.04, please reply here. You can easily run this in a live session and test it out. The install script I have on my page makes it easy to install and the documentation I added should help alot in getting it set up. I don't want to have to put a bounty on Bountysource .com to get this working but I will if that is the best bet.
riusma 24 May, 2019
I don't think that it will help but seeing that it's Razer related have you looked at OpenRazer (Tartarus seems suported) and its related applications (I don't know if key remapping is available with them)? :S:

Edit: sorry I don't think that any of the applications linked to OpenRazer is able to perform key remapping, and I'm under impression that it's not actually possible because of lack of support for such a feature in OpenRazer daemon (I may be wrong). :|

Edit(2): @TherinS, ok just see your comment on Github / Polychromatic... forget my post!
While you're here, please consider supporting GamingOnLinux on:

Patreon, Liberapay or PayPal Donation.

We have no adverts, no paywalls, no timed exclusive articles. Just good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register

Or login with...
Sign in with Steam Sign in with Twitter Sign in with Google
Social logins require cookies to stay logged in.