Is there a way to map ABXY buttons to the key that I want?

First of all, thanks to commuinty member for helping us, especially @Rex for building a wonderful bookworm distro.

When I press ABXY buttons in the normal OS environment, nothing happens, but as you guys know, they work in games.

I’m using his bookworm lite with Xfce, and I want to map uConsole’s ABXY buttons to other keys(keyboards) that I want.

If you guys know any ways to do this?

Thanks.

No one else has answered so I will give a try. Short answer, no. Longer answer the keyboard is an Arduino sketch and you can modify it as you want. Maybe there is a linux way to change the game buttons to something else but I am not aware of it.
I am looking to make some changes myself. In particular I want to change the ball click to left click and remap middle click to something else.

1 Like

I was able to catch button events using python.

import evdev
from evdev import InputDevice, categorize, ecodes
import subprocess

device = InputDevice('/dev/input/event5')

for event in device.read_loop():
    if event.type == ecodes.EV_KEY:
        key_event = categorize(event)
        if key_event.keystate == key_event.key_down:
            if 'BTN_TRIGGER' in key_event.keycode:
                subprocess.run(["setfont", "/usr/share/consolefonts/Lat7-TerminusBold24x12.psf.gz"])
            elif key_event.keycode == 'BTN_THUMB':
                subprocess.run(["setfont", "/usr/share/consolefonts/Lat7-TerminusBold20x10.psf.gz"]) 

Not sure about Xfce. I’m using it in tty0.

3 Likes

Oh, that’s cool. I’ll try it!
Thank you.

I tried your method and it caught the keyboard input well, but not ABXY buttons.
Did it catch game buttons in your environment(tty0)?

Did it catch game buttons in your environment(tty0)?

Yes. There are different input devices for different keyboard parts. And they could have different names on different systems. ‘/dev/input/event5’ was for ABXY on the stock Raspbian that I had at the time. And LR were on event4 I think. And now I have different mapping on Debian 12, but the method works without any issues.

Python evdev lib has ways to deal with multiple devices but I just tried all available devices. There are some examples:
https://python-evdev.readthedocs.io/en/latest/tutorial.html#reading-events-from-multiple-devices-using-asyncio

I’ve checked it again and was able to catch events from the qwerty part, the arrows, LR, ABXY and even BTN_MIDDLE (which is the button under the trackball).

1 Like