Support us on Patreon to keep GamingOnLinux alive. This ensures we have no timed articles and no paywalls. Just good, fresh content! Alternatively, you can donate through Paypal, Flattr and Liberapay!
  Go to:
Python key remapping software quit working on upgrade
TherinS commented on 19 May 2019 at 7:33 am UTC

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 https://github.com/TherinS/Pystromo 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 commented on 19 May 2019 at 8:41 am UTC

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 commented on 19 May 2019 at 9:06 pm UTC

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 commented on 20 May 2019 at 4:21 am UTC

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:


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

The following errors occured with these actions:

Run as is, the following error occurs:

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

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

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

** FULL TEXT OF ERROR **

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

2)put "#!/usr/bin/env python3" at beginning of 
/home/steveum-ssd/software/Pystromo-master/pystromo/lib/devices.py
    Result=same as first error
3)-put "#!/usr/bin/env python3" at beginning of
/home/steveum-ssd/software/Pystromo-master/pystromo/lib/ioctl.py
    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 commented on 20 May 2019 at 6:37 am UTC

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?

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 commented on 20 May 2019 at 10:17 am UTC

It's an old software (2008) no longer under active developed.
Try a more recent keymapper like Antimicro:
https://github.com/AntiMicro/antimicro
no more under development but more recent.
Or if you have a Steam controller, use sc-controller:
https://github.com/kozec/sc-controller

TherinS commented on 21 May 2019 at 2:02 am UTC

@tuubi:

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?

@legluondunet:
Yes, I ran

$ sudo ./pystromo-remap.py -m ./custom_maps/n52-KFtest.map

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 commented on 22 May 2019 at 12:19 am UTC

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.

pystromo-remap.py -v -v -v -v -m test.map
Using output: <lib.devices.OutputDevice object at 0x7fa55b4bf050>
Loading mappings
test.map
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 commented on 22 May 2019 at 6:34 am UTC

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 commented on 24 May 2019 at 2:49 am UTC

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:

https://github.com/TherinS/Pystromo

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.

Patola commented on 24 May 2019 at 3:47 pm UTC

Hi, TherinS. I want to help you on that, but you said antimicro only works with hand held controllers? Well, not true. I use it for my entire HOTAS set with 4 very different devices: a Thrustmaster Warthog Stick, a Throttle Saitek X52 Pro, a panel MFD F-16 and a nameless chinese three-pedal USB device. I think it's worth trying with the latest version.

Where I am right now I don't have access to my PC but I will try and look at pystromo at night.

  Go to:

Due to spam you need to Register and Login to comment.


Or login with...

Livestreams & Videos
Community Livestreams
See more!
Popular this week
View by Category
Contact
Latest Comments
Latest Forum Posts