Input: Add in-kernel input events transformation framework
Subsystems (2)
PATCH v2 1/1 Input: Add in-kernel input events transformation framework
This new driver allows to perform various input events transformations in kernel, e.g. remap one key (or combination) to another key.
The driver uses configfs (/sys/kernel/config/input_xfrm) and includes this small readme:
The transformation files (map, modmap) accept writes in this form:
<+/-> <keycode-map-from> <keycode-map-to>
Plus sign to add, and minus sign to remove an entry. Keycodes can be found in /usr/include/linux/input.h
For example, to remap KEY_LEFTMETA (125) to KEY_LEFTALT (56):
# echo + 125 56 > map Special mappings with a modifier key can be also created. For example, to remap capslock+left to home key: # echo 58 42 > modkeys # echo + 105 102 > modmap The first commands maps KEY_CAPSLOCK (58) to a modifier key, the second command creates the mapping. The second argument (42, which is KEY_LEFTSHIFT) to modkeys specifies the unmodifier key: when pressed together with the modifier key, the mappings will temporary turn off. That is, pressing capslock+leftshift will let use capslock as normal again.
So far it's not possible to switch keys, but if/when needed, it's pretty easy to implement: just need to create a virtual input device, and pass events through it.
Note that the other approach of these transformations would be to export input filters to the userland, then intercept events there, and pass the transformed events back (or to the uinput instance). But this needlessly requires too much efforts for the simple task.
---
In v2:
- Small fixup: subsys.su_mutex has to be initialized manually, I missed this part in the RFC.
drivers/input/misc/Kconfig | 10 + drivers/input/misc/Makefile | 1 + drivers/input/misc/input_xfrm.c | 428 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 439 insertions(+) create mode 100644 drivers/input/misc/input_xfrm.c
drivers/input/misc/Kconfig +10 -0
@@ -600,4 +600,14 @@ config INPUT_XEN_KBDDEV_FRONTEND To compile this driver as a module, choose M here: the module will be called xen-kbdfront. +config INPUT_XFRM + tristate "Input events transformation framework" + depends on CONFIGFS_FS + help + This driver allows to perform various input events transformations + in kernel, e.g. remap one key (or combination) to another key. + + To compile this driver as a module, choose M here: the + module will be called input_xfrm. + endif
drivers/input/misc/Makefile +1 -0
@@ -55,4 +55,5 @@ obj-$(CONFIG_INPUT_UINPUT) += uinput.o obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o +obj-$(CONFIG_INPUT_XFRM) += input_xfrm.o obj-$(CONFIG_INPUT_YEALINK) += yealink.o
drivers/input/misc/input_xfrm.c new file +428 -0
428 lines not on this page · raw message
Signature · 1 line
1.7.12