Commit graph

9 commits

Author SHA1 Message Date
cmitu
eb0686e96f joy2key: allow selecting the non-SDL version
There are 2 (uinput) related changes here:

* The SDL2/Uinput based Joy2Key is too slow for Pi1/0 devices, so allow the user to choose the older version. The older version is simpler since it doesn't need or load SDL2/Uinput, thus faster to load on those systems. By default, on ARMv6 devices the old version will be configured.

* The Uinput based event generation of keyboard events is not able to trigger the `runcommand` menu when launching images splash is done via `feh`, since the image display will get always have focus and thus the keybord events will not reach the `runcommand` terminal. So, in order for the `runcommand` menu to work after the splash image, make sure we stop `feh` before launch, just like `fbi` is stopped on non-desktop systems.
2024-10-28 19:18:14 +00:00
cmitu
35ed85ed13 joy2key: add udev rule for /dev/uinput permissions
Add an udev rule to give the `input` group write access to `/dev/uinput` in order for the python uinput device(s) can be created.
2024-10-16 16:15:43 +01:00
cmitu
5237c45ea6 joy2key: ensure the install user is part of 'input' group
On RaspiOS, the install user is part of the `input` group by default, but on Ubuntu is not. Add it during install so that `joy2key` can work as regular user (i.e. as part of `runcommand`).
2024-10-16 04:26:58 +01:00
cmitu
d417e06978 joy2key: use 'uinput' for emitting keyboard events
Recent Linux kernels (6.2+) have the ability to disable the 'TIOCSTI' ioctl, thus rendering unusable the method of sending keyboard events to the controlling terminal via `fcntl.ioctl` [1]. Not all distributions have left it enabled currently, but Ubuntu 24.04 has it enabled, affecting the `runcommand` ability to generate keyboard events for a joystick.

Use the `python-uinput` module to create a virtual keyboard and send the proper events through it, without relying on the 'curses' or 'fcntl' modules. Now, since the new module doesn't know about Termios codes, which were used previously, I've added a translation table to accomodate scripts using those capability codes. The `python-uinput` uses the Linux event codes [2].

The new method needs the `uinput` Linux kernel module to be loaded beforehand - so add the module to be automatically loaded. The user also needs to be part of the 'input' group, otherwise they won't be able to use the `uinput` interface -  RetroPie doesn't automate that, but assumes the installation user belongs to that group.

We also don't need the `termios`/`fnctl` calls, so the terminal handling part has been removed, simpplifying a bit the code.

OTHER changes:
 - the device path (/dev/jsX) is now ignored. It hasn't been working since the switch to SDL2 for input processing, but was still parsed for compatibility with the old version.
 - when invoking with the debug (--debug|-d) parameter, the script now runs in the foreground, instead of forking and running in the background. It's easier when running it to diagnose issues; running with debugging enabled should not be used for regular usage.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=83efeeeb3d04b22aaed1df99bc70a48fe9d22c4d
[2] https://github.com/tuomasjjrasanen/python-uinput/blob/master/src/ev.py
2024-10-12 06:52:59 +01:00
cmitu
0786eab335 joy2key: refactor stop action
Modified the 'stop' action to use `start-stop-daemon` [1] instead of a simple `pkill`.

The advantage is that we don't need to use `sleep` to ensure the script is stopped, since `start-stop-daemon` monitors the process and will exit when is stopped. The `retry` action is to send a SIGKILL after 1 second, to ensure the process is stopped.

The modification will shorten the time it takes to 'stop' the joystick handling utility, since we don't have to wait - unconditionally - for 1 sec every stop. This will shorten the runtime of `runcommand` .

[1] https://man7.org/linux/man-pages/man8/start-stop-daemon.8.html. Since it's part of `dpkg`, it's basically present on every Debian based system.
2024-01-23 04:38:05 +00:00
cmitu
d6cede74de joy2key,wifi: add an on-screen keyboard dialog
Currently, the WiFi configuration from RetroPie menu needs a keyboard for configuring a connection.
Added a `python` script to display on-screen keyboard which can be operated with `joy2key` and the gamepad, which allows entering the WiFi network/key/password without a keyboard.

The script accepts keyboard input, so it's suited for both keyboard and joystick input. It's using the `urwid` library (https://urwid.org).

The WiFi scriptmodule was modified to use the new OSK script instead of the `dialog` based inputboxes.

Additional modifications to the WiFi module:
 - added a confirmation step before removing the WiFi config and stopping the WiFi
 - added an info message during the WiFi scanning (instead of having a black screen)
 - removed the check for the pass length, it's done by the new OSK script
 - reformatted a bit the 'country' warning

NOTE: I've tested the new OSK script with smaller displays, but anything less than 40 cols will not be displayed fully. The OSK keyboard will scroll horizontally (when there's no more space on screen), but this is non-intuitive and might confuse users. _If_ we need to accomodate an even smaller screen size, then the OSK display area should be probably changed to accomodate that (i.e. less letters on a 'keyboard' row).
2021-12-07 15:10:50 +00:00
Jools Wills
8957344ccc joy2key - start/stop joy2key on module install/removal 2021-08-04 00:03:32 +01:00
Jools Wills
3f01c51848 joy2key - remove ini config allowing overriding of joy2key script
There has been no user reports of issues, and fron my own testing I have found no issues why
we may need to force the old version apart from if the python library isn't available.
2021-08-04 00:03:32 +01:00
Jools Wills
50ed2e781e joy2key - split out into standalone module and rework helper code
Move much of the helpers.sh start/stop logic and default parameters to a joy2key wrapper script.

Switch runcommand.sh to use new wrapper script

Add tab button to "y" key for use in edit dialogs

Remove runcommand $md_inst on update. If old joy2key is present in runcommand install, trigger joy2key module install.

Remove system.sh python3-sdl2 dependency check - moved to joy2key_depends
2021-08-04 00:03:32 +01:00