input-remapper/README.md

129 lines
3.9 KiB
Markdown
Raw Normal View History

2020-11-26 20:37:15 +00:00
<h1 align="center">Key Mapper</h1>
2020-10-26 22:45:22 +00:00
2020-11-29 15:24:44 +00:00
<p align="center">A tool to change and program the mapping of your input device buttons.</p>
2020-11-26 20:37:15 +00:00
<p align="center"><img src="readme/pylint.svg"/> <img src="readme/coverage.svg"/></p>
2020-11-16 12:01:42 +00:00
2020-11-29 09:42:20 +00:00
<p align="center"><img src="readme/screenshot.png"/></p>
2020-11-26 23:00:21 +00:00
<br/>
2020-10-31 18:21:17 +00:00
2020-11-26 20:37:15 +00:00
## Usage
2020-11-01 20:32:06 +00:00
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 19:59:56 +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-12-04 17:48:31 +00:00
Syntax errors are logged to the console.
##### 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:31:58 +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-12-04 13:38:41 +00:00
for KEY and BTN names
2020-12-03 22:11:56 +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` ...
- Macro special keys `KEY_MACRO1` `KEY_MACRO2` ...
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
- 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-11-29 19:41:38 +00:00
After your installation, independent of the method, you should add yourself
2020-11-29 22:05:18 +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:41:38 +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 13:07:25 +00:00
##### Manjaro/Arch
2020-11-29 12:55:37 +00:00
```bash
pacaur -S key-mapper-git
```
2020-11-29 19:59:56 +00:00
##### Ubuntu/Debian
2020-11-22 21:03:44 +00:00
```bash
2020-11-29 19:59:56 +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
2020-12-03 19:56:47 +00:00
Depending on your distro, maybe you need to use both methods with --force
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 20:37:15 +00:00
## Roadmap
2020-10-26 22:45:22 +00:00
2020-11-22 21:03:44 +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:03:44 +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:41:38 +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
- [ ] map D-Pad and Joystick directions as buttons, joystick purpose via config
2020-11-26 23:00:21 +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
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:48:31 +00:00
To read events, `evtest` is very helpful. Add `-d` to `key-mapper-gtk`
to get debug outbut.