input-remapper/readme/development.md

123 lines
4.3 KiB
Markdown
Raw Normal View History

2020-12-19 15:09:24 +00:00
# Development
2020-12-19 15:15:05 +00:00
Contributions are very welcome, I will gladly review and discuss any merge
requests.
2020-12-19 15:09:24 +00:00
## Roadmap
- [x] show a dropdown to select valid devices
- [x] creating presets per device
- [x] renaming presets
- [x] show a mapping table
- [x] make that list extend itself automatically
- [x] read keycodes with evdev
- [x] inject the mapping
- [x] keep the system defaults for unmapped buttons
- [x] button to stop mapping and using system defaults
- [x] highlight changes and alert before discarding unsaved changes
- [x] automatically load presets on login for plugged in devices
- [x] make sure it works on wayland
- [x] support timed macros, maybe using some sort of syntax
- [x] add to the AUR, provide .deb file
- [x] basic support for gamepads as keyboard and mouse combi
- [x] executing a macro forever while holding down the key using `h`
- [x] mapping D-Pad directions as buttons
2020-12-19 23:41:28 +00:00
- [x] configure joystick purpose and speed via the GUI
- [x] support for non-GUI TTY environments with a command to stop and start
- [x] start the daemon in such a way to not require usermod
2020-12-31 20:46:57 +00:00
- [x] mapping a combined button press to a key
2021-01-01 13:22:50 +00:00
- [x] add "disable" as mapping option
2021-01-01 21:20:33 +00:00
- [x] mapping joystick directions as buttons, making it act like a D-Pad
2021-01-05 18:33:47 +00:00
- [x] mapping mouse wheel events to buttons
2021-02-07 14:00:36 +00:00
- [x] automatically load presets when devices get plugged in after login (udev)
- [x] map keys using a `modifier + modifier + ... + key` syntax
2021-02-07 14:00:36 +00:00
- [ ] injecting keys that aren't available in the systems keyboard layout
2020-12-19 15:09:24 +00:00
## Tests
```bash
sudo pip install coverage
2020-12-19 15:09:24 +00:00
pylint keymapper --extension-pkg-whitelist=evdev
sudo pip install . && coverage run tests/test.py
coverage combine && coverage report -m
```
To read events, `evtest` is very helpful. Add `-d` to `key-mapper-gtk`
2020-12-19 15:12:55 +00:00
to get debug output.
## Releasing
2021-01-05 18:33:47 +00:00
ssh/login into a debian/ubuntu environment
2020-12-19 15:12:55 +00:00
```bash
./scripts/build.sh
```
2021-02-06 23:03:26 +00:00
This will generate `key-mapper/deb/key-mapper-0.6.1.deb`
2020-12-19 15:12:55 +00:00
## Badges
```bash
sudo pip install git+https://github.com/jongracecox/anybadge
./scripts/badges.sh
```
2020-12-19 15:14:01 +00:00
New badges, if needed, will be created in `readme/` and they
2020-12-19 15:14:01 +00:00
just need to be commited.
## Files
**gui**
- `bin/key-mapper-gtk` the executable that starts the gui. It also sends
2021-01-23 16:12:20 +00:00
messages to the service via dbus if certain buttons are clicked.
- `bin/key-mapper-gtk-pkexec` opens a password promt to grant root rights
2021-02-07 14:00:36 +00:00
to the GUI, so that it can read from devices
- `data/key-mapper.policy` configures pkexec
- `data/key-mapper.desktop` is the entry in the start menu
**cli**
- `bin/key-mapper-control` is an executable to send messages to the service
2021-01-23 16:12:20 +00:00
via dbus. It can be used to start and stop injection without a GUI.
2021-02-07 14:00:36 +00:00
**service**
2021-02-07 14:00:36 +00:00
- `bin/key-mapper-service` executable that starts listening for
commands via dbus and runs the injector when needed. It shouldn't matter how
it is started as long as it manages to start without throwing errors. It
usually needs root rights.
2021-01-23 16:12:20 +00:00
- `data/key-mapper.service` starts key-mapper-service automatically on boot
on distros using systemd.
- `data/keymapper.Control.conf` is needed to connect to dbus services started
2021-01-23 16:12:20 +00:00
by systemd from other applications.
2021-02-07 14:00:36 +00:00
**autoload**
2021-02-07 14:00:36 +00:00
- `data/key-mapper-autoload.desktop` executes on login and tells the systemd
2021-01-23 16:12:20 +00:00
service to stop injecting (possibly the presets of another user) and to
inject the users autoloaded presets instead (if any are configured)
2021-02-07 14:00:36 +00:00
- `data/key-mapper.rules` udev rule that sends a message to the service to
start injecting for new devices when they are seen for the first time.
**Example system startup**
1. systemd loads `key-mapper.service` on boot
2. on login, `key-mapper-autoload.desktop` is executed, which has knowledge
of the current user und doesn't run as root
2.1 it sends the users config directory to the service
2.2 it makes the service stop all ongoing injectings
2.3 it tells the service to start loading all of the configured presets
3. a bluetooth device gets connected, so udev runs `key-mapper.rules` which
tells the service to start injecting for that device if it has a preset
assigned. Works because step 2 told the service about the current users
config.
Communication to the service always happens via `key-mapper-control`
2020-12-26 15:45:29 +00:00
## Resources
[PyGObject API Reference](https://lazka.github.io/pgi-docs/)
2021-01-07 16:15:12 +00:00
[python-evdev](https://python-evdev.readthedocs.io/en/stable/)