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
|
|
|
|
2020-11-26 23:36:05 +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-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
|
2020-11-27 20:31:03 +00:00
|
|
|
- `.` executes two actions behind each other
|
2020-11-27 20:27:15 +00:00
|
|
|
|
2020-11-30 15:22:17 +00:00
|
|
|
##### Names
|
|
|
|
|
2020-12-03 19:03:53 +00:00
|
|
|
For a list of supported keystrokes and their names for the middle column,
|
|
|
|
check the output of `xmodmap -pke`
|
2020-11-27 20:55:14 +00:00
|
|
|
|
2020-11-30 15:22:17 +00:00
|
|
|
- Alphanumeric `a` to `z` and `0` to `9`
|
|
|
|
- Modifiers `Alt_L` `Control_L` `Control_R` `Shift_L` `Shift_R`
|
|
|
|
|
2020-11-30 18:40:17 +00:00
|
|
|
If you can't find what you need, consult
|
|
|
|
[linux/input-event-codes.h](https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h)
|
2020-11-30 15:22:17 +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-11-30 15:22:17 +00:00
|
|
|
- Macro special keys `KEY_MACRO1` `KEY_MACRO2` ...
|
|
|
|
|
2020-12-02 17:13:21 +00:00
|
|
|
##### Gamepads
|
|
|
|
|
|
|
|
Tested with the XBOX 360 Gamepad. Joystick movements will be translated
|
2020-12-02 20:21:21 +00:00
|
|
|
to mouse movements. Buttons can be mapped to keycodes or macros. D-Pad
|
2020-12-02 20:45:27 +00:00
|
|
|
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-11-29 19:41:38 +00:00
|
|
|
After your installation, independent of the method, you should add yourself
|
2020-11-30 13:36:53 +00:00
|
|
|
to the `input` and `plugdev` groups so that you can read information from your
|
|
|
|
devices. You have to start the application via sudo otherwise.
|
2020-11-29 12:55:37 +00:00
|
|
|
|
|
|
|
```bash
|
2020-11-29 13:25:44 +00:00
|
|
|
sudo usermod -a -G plugdev,input $USER
|
2020-11-29 19:44:59 +00:00
|
|
|
# log out and back in or restart, the two groups should be visible with:
|
2020-11-29 17:54:15 +00:00
|
|
|
groups
|
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/"\
|
|
|
|
"download/0.1.0/python3-key-mapper_0.1.0-1_all.deb"
|
|
|
|
sudo dpkg -i python3-key-mapper_0.1.0-1_all.deb
|
2020-11-01 20:32:06 +00:00
|
|
|
```
|
|
|
|
|
2020-12-03 17:43:36 +00:00
|
|
|
##### Git/pip
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# you may need to use --force to overwrite an existing source installation
|
|
|
|
sudo pip install git+https://github.com/sezanzeb/key-mapper.git
|
|
|
|
# or
|
|
|
|
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 19:46:52 +00:00
|
|
|
- [x] support gamepads as keyboard and mouse combi
|
2020-12-03 19:46:36 +00:00
|
|
|
- [ ] automatically load presets when devices get plugged in after login
|
2020-11-29 15:24:44 +00:00
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
|
|
|
```bash
|
|
|
|
pylint keymapper --extension-pkg-whitelist=evdev
|
2020-12-02 13:36:17 +00:00
|
|
|
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
|
|
|
|
|
|
|
To read events, `evtest` is very helpful.
|