How to arbitrarily manipulate key events in X
meingbg at gmail.com
Mon Mar 22 07:44:06 PDT 2010
The intention/problem is as follows:
I've written a small app that among other things allows me to let any
key act as both a modifier key and a character key at the same time.
(see http://github.com/meingbg/keyboa )
Now, I'd like to plug it into X.
Basically, I want a way to run a program that (as portably as possible) can
1) receive all key events (keysym press/release) from the keyboard
that are about to be sent to X and intercept these so that X will not
2) send key events to X in a manner that makes it impossible for
applications to distinguish these events from real keyboard events
(and without re-intercepting the key events sent).
I suspect people writing accessibility extensions would face a similar problem.
One possible solution to #2 (that requires the XTest extension) is to:
1) add the keysym to the keymap if it is not already there
2) convert the keysym into the corresponding keycode and shift state
for the current keymap
3) use XTestFakeKeyEvent to send it to the server
I do not have any solution to #1. I've thought about reading
/dev/console and somehow use the current keyboard driver to convert
the scancodes to keycodes, and from there go through the keymap to get
keysyms. However, reading /dev/console prevents switching to terminal
mode (ctrl-alt-1) and may require root privileges.
Any suggestions on how to solve #1 or improve #2? Any help is appreciated.
More information about the xorg