Kelboy Launcher - joystick.py - scrummvm cursor - big contrast

All controllers in one, joystick.py

Eight buttons, a crosshair and a joystick can go a long way with the right software
Bit
02-11-2020
Kelboy Launcher - joystick.py - scrummvm cursor - big contrast

Context

Anyone who lived in the 90's and the console wars loves the format adopted by the Kelboy 2. A format made for the hand, with all the buttons at the fingertips, but it is not surprising that with the amount of options that exist in the middle of 2020 we are short.

In this sense, the kelboy-launcher has a possibility implemented and that is to configure the inputs to emulate certain hardware that does not exist, allowing us to recreate the feeling we had in front of a retro platform in our DIY.

Image

How it works?

As we have explained in previous articles, an important part of the kelboy-launcher is related to the joystick.py, in this part special movements have been programmed and related to custom command outputs.

An example is the temporary battery display, fast mute, or brightness control:

Extracto del control del brillo - joystick.py

This code is static, and cannot be changed, so it raises the problem that when customizing these types of controls, a user must have the option to configure them.

In addition, this does not work so simply, we could have programmed something as simple as asking the kernel-level input to raise the mouse, but if the user stops pressing the program, they do not have to know in what coordinates it is. As there is no physical hardware in the form of a touchpad or similar and by default it does not have a graphical environment started, the kelboy needs a different control.

To solve this type of problem, a virtual device has been programmed in python controlled from joystick.py, and also this type of development allows us to know which processes are open and consequently execute what we want. To enable this type of control, it was necessary to think of a way for the user to customize configurations and, if they did not wish, to have default controls.

These settings are handled by the existing process, so if an application closes at least the part of the launcher in charge of it (joystick.py) will not work.

All these configurations can be personalized by the user, for this this control has been programmed dynamically so that an inexperienced user can, depending on their needs, control and change the controls of a specific process.

Image

These settings are all in:

/home/pi/.kelboy-launcher/joystick.json

The settings are in json format. An example:

[
    {
        "process": "pico8",
        "keys": [
            {
                "key": "UP",
                "callback": [
                    "KEY_UP"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "DOWN",
                "callback": [
                    "KEY_DOWN"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "LEFT",
                "callback": [
                    "KEY_LEFT"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "RIGHT",
                "callback": [
                    "KEY_RIGHT"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "A",
                "callback": [
                    "KEY_X"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "B",
                "callback": [
                    "KEY_C"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "X",
                "callback": [
                    "KEY_S"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "START",
                "callback": [
                    "KEY_ENTER"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "SELECT",
                "callback": [
                    "KEY_LEFTCTRL",
                    "KEY_Q"
                ],
                "type": "EV_KEY"
            },
            {
                "key": "MOUSE",
                "callback": [],
                "type": "EV_ABS"
            }
        ]
    }
]

Además se han proporcionado una programación de controles por defecto para que las funcionalidades programadas en el kelboy-launcher (como puede ser el control del reproductor externo mpv) sigan estando controladas con los controles de la kelboy, usando los cursores y botones.

Launcher
This article is considered part of offered documentation by Lemoncrest products.
Comments
Page 1Page 1ear iconeye iconFill 23text filevr