input-remapper/README.md

132 lines
4.3 KiB
Markdown
Raw Normal View History

2020-11-26 22:45:24 +00:00
<h1 align="center">Key Mapper</h1>
2020-11-26 22:34:52 +00:00
2020-11-29 16:47:18 +00:00
<p align="center">A tool to change and program the mapping of your input device buttons.</p>
2020-11-26 21:19:30 +00:00
<p align="center"><img src="readme/pylint.svg"/> <img src="readme/coverage.svg"/></p>
2020-11-22 20:43:22 +00:00
2020-11-29 09:42:20 +00:00
<p align="center"><img src="readme/screenshot.png"/></p>
2020-11-26 22:58:29 +00:00
<br/>
2020-10-31 18:21:17 +00:00
2020-11-26 22:52:58 +00:00
## Usage
2020-11-29 13:07:25 +00:00
To open the UI to modify the mappings, look into your applications menu
and search for 'Key Mapper' in settings. You can also start it via
`key-mapper-gtk`. It works with both Wayland and X11.
2020-11-29 12:55:37 +00:00
2020-11-29 17:54:15 +00:00
If stuff doesn't work, check the output of `key-mapper-gtk -d` and feel free
to open up an issue here.
2020-11-29 20:15:49 +00:00
##### Macros
2020-11-27 20:27:15 +00:00
It is possible to write timed macros into the center column:
2020-11-28 21:59:07 +00:00
- `k(1).k(2)` 1, 2
- `r(3, k(a).w(500))` a, a, a with 500ms pause
- `m(Control_L, k(a).k(x))` CTRL + a, CTRL + x
2020-12-05 11:17:36 +00:00
- `k(1).h(k(2)).k(3)` writes 1 2 2 ... 2 2 3 while the key is pressed
2020-11-27 20:27:15 +00:00
Documentation:
2020-11-28 19:28:15 +00:00
- `r` repeats the execution of the second parameter
2020-11-28 21:54:22 +00:00
- `w` waits in milliseconds
2020-11-28 19:28:15 +00:00
- `k` writes a single keystroke
- `m` holds a modifier while executing the second parameter
- `h` executes the parameter as long as the key is pressed down
2020-11-27 20:31:03 +00:00
- `.` executes two actions behind each other
2020-11-27 20:27:15 +00:00
2020-12-05 12:11:45 +00:00
Syntax errors are shown in the UI on save. each `k` function adds a short
delay of 10ms that can be configured in `~/.config/key-mapper/config`.
2020-12-04 17:48:31 +00:00
2020-12-05 22:47:31 +00:00
##### Key Names
Run `key-mapper-service --key-names` for a list of supported keys for
2020-12-05 22:46:58 +00:00
the middle column. Examples:
2020-11-27 20:55:14 +00:00
- Alphanumeric `a` to `z` and `0` to `9`
- Modifiers `Alt_L` `Control_L` `Control_R` `Shift_L` `Shift_R`
2020-12-04 13:39:40 +00:00
- Mouse buttons `BTN_LEFT` `BTN_RIGHT` `BTN_MIDDLE` `BTN_SIDE` ...
2020-12-03 19:49:51 +00:00
- Multimedia keys `KEY_NEXTSONG` `KEY_PLAYPAUSE` ...
2020-12-02 17:13:21 +00:00
##### Gamepads
2020-12-03 20:39:09 +00:00
Tested with the XBOX 360 Gamepad.
- Joystick movements will be translated to mouse movements
- The second joystick acts as a mouse wheel
- Buttons can be mapped to keycodes or macros
2020-12-03 20:39:44 +00:00
- The D-Pad only works as two buttons - horizontal and vertical
2020-12-02 17:13:21 +00:00
2020-11-29 12:55:37 +00:00
## Installation
2020-12-04 21:19:57 +00:00
The tool shows and logs if there are issues, but usually, independent of the
method, you should add yourself to the `input` and `plugdev` groups so that
you can read information from your devices. You have to start the application
via sudo otherwise. You may also need to grant yourself write access to
`/dev/uinput` to be able to inject your programmed mapping.
2020-11-29 12:55:37 +00:00
There is a shortcut for configuring this stuff:
2020-11-29 12:55:37 +00:00
```bash
sudo key-mapper-service --setup-permissions
# now log out and back in
2020-11-29 12:55:37 +00:00
```
2020-11-29 12:57:30 +00:00
##### Manjaro/Arch
2020-11-29 12:55:37 +00:00
```bash
pacaur -S key-mapper-git
```
2020-11-29 20:13:38 +00:00
##### Ubuntu/Debian
2020-11-22 21:07:54 +00:00
2020-11-02 19:55:17 +00:00
```bash
2020-11-29 20:13:38 +00:00
wget "https://github.com/sezanzeb/key-mapper/releases/"\
2020-12-04 21:10:06 +00:00
"download/0.2.0/python3-key-mapper_0.2.0-1_all.deb"
2020-12-04 21:10:26 +00:00
sudo dpkg -i python3-key-mapper_0.2.0-1_all.deb
2020-11-01 20:32:06 +00:00
```
2020-12-03 17:43:36 +00:00
##### Git/pip
2020-12-04 21:21:10 +00:00
Depending on your distro, maybe you need to use both methods with `--force`
2020-12-03 19:56:47 +00:00
to get all your files properly in place and overwrite a previous installation
of key-mapper.
2020-12-03 17:43:36 +00:00
```bash
2020-12-03 19:56:47 +00:00
# method 1
2020-12-03 17:43:36 +00:00
sudo pip install git+https://github.com/sezanzeb/key-mapper.git
2020-12-03 19:56:47 +00:00
# method 2
2020-12-03 17:43:36 +00:00
git clone https://github.com/sezanzeb/key-mapper.git
cd key-mapper && sudo python3 setup.py install
```
2020-11-26 22:46:06 +00:00
## Roadmap
2020-10-26 22:45:22 +00:00
2020-11-22 21:04:30 +00:00
- [x] show a dropdown to select valid devices
2020-11-19 00:45:12 +00:00
- [x] creating presets per device
- [x] renaming presets
2020-11-22 21:04:30 +00:00
- [x] show a mapping table
2020-11-15 11:15:58 +00:00
- [x] make that list extend itself automatically
2020-11-22 21:03:44 +00:00
- [x] read keycodes with evdev
- [x] inject the mapping
2020-11-10 22:21:19 +00:00
- [x] keep the system defaults for unmapped buttons
2020-11-19 00:45:12 +00:00
- [x] button to stop mapping and using system defaults
2020-11-15 00:35:35 +00:00
- [x] highlight changes and alert before discarding unsaved changes
2020-11-26 23:00:21 +00:00
- [x] automatically load presets on login for plugged in devices
2020-11-22 20:43:22 +00:00
- [x] make sure it works on wayland
2020-11-28 23:28:46 +00:00
- [x] support timed macros, maybe using some sort of syntax
2020-11-29 19:55:14 +00:00
- [x] add to the AUR, provide .deb file
2020-12-03 22:11:56 +00:00
- [x] basic support for gamepads as keyboard and mouse combi
2020-12-05 10:58:29 +00:00
- [x] executing a macro forever while holding down the key
2020-12-03 22:14:10 +00:00
- [ ] map D-Pad and Joystick directions as buttons, joystick purpose via config
2020-12-03 19:46:36 +00:00
- [ ] automatically load presets when devices get plugged in after login
2020-12-04 20:57:27 +00:00
- [ ] option to write hwdb configs for lower level mappings ([Remapping keys using hwdb files](https://www.reddit.com/r/linux_gaming/comments/k3h9qv/remapping_keys_using_hwdb_files/))
2020-12-05 09:26:27 +00:00
- [ ] mapping a combined button press to a key
2020-11-29 15:24:44 +00:00
## Tests
```bash
pylint keymapper --extension-pkg-whitelist=evdev
sudo pip install . && coverage run tests/test.py
2020-11-30 21:42:53 +00:00
coverage combine && coverage report -m
2020-11-29 15:24:44 +00:00
```
2020-12-02 19:48:23 +00:00
2020-12-04 17:50:20 +00:00
To read events, `evtest` is very helpful. Add `-d` to `key-mapper-gtk`
2020-12-05 22:47:40 +00:00
to get debug output.