diff --git a/readme/development.md b/readme/development.md index e67a443c..60301af7 100644 --- a/readme/development.md +++ b/readme/development.md @@ -1,7 +1,8 @@ # Development Contributions are very welcome, I will gladly review and discuss any merge -requests. +requests. This file should give an overview about some notable internals of +key-mapper. ## Roadmap @@ -148,6 +149,18 @@ readme/capabilities.md Modify `should_map_as_btn` +## How it works + +It uses evdev + +1. It grabs a device (e.g. /dev/input/event3), so that the key events won't reach X11/Wayland anymore [source](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/injector.py#L182) +2. Reads the events from it (`evtest` can do it, you can also do `cat /dev/input/event3` which yields binary stuff) [source](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/injector.py#L413) +3. Looks up the mapping if that event maps to anything [source](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/keycode_mapper.py#L421) +4. Injects the output event in a new device that key-mapper created (another new path in /dev/input, device name is suffixed by "mapped") [source](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/keycode_mapper.py#L227), [new device](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/injector.py#L324) +5. Forwards any events that should not be mapped to anything in another new device (device name is suffixed by "forwarded") [source](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/keycode_mapper.py#L232), [new device](https://github.com/sezanzeb/key-mapper/blob/0.7.0/keymapper/injection/injector.py#L342) + +This stuff is going on as a daemon in the background + ## Resources - [Guidelines for device capabilities](https://www.kernel.org/doc/Documentation/input/event-codes.txt)