From: "Mathias Laurenz Baumann" <marenz@supradigital.org>
To: linux-input@vger.kernel.org
Subject: Modifying keycodes or scancodes of keyboard devices
Date: Tue, 11 Sep 2012 17:21:31 +0200 [thread overview]
Message-ID: <op.wkg8x5kq486orv@labs03> (raw)
Hello,
I want to write a kernel module that hooks in somewhere between the
keyboard driver and whatever
uses the resulting key events (e.g. evdev or xkb).
My goal is to modify the keycodes or scancodes (whatever works best and is
least amount of work)
reported to the next function in the input processing chain, with the
intended result of
modifying the keyboard layout.
I could of course just use xkb and create a custom mapping, but my
experience with those is that
many applications have trouble with some mappings. One example is the
neo-layout[1] which provides
alternative mappings for the arrow keys or the navigation keys like pos1,
end, return and the
numblock, only activated when a certain modifier is active (e.g. AltGr).
Many programs have trouble
when those alternatives are used.
My idea is to do that mapping on a level deeper than xkb can provide, thus
avoiding those problems and faking
a keyboard that has that layout in hardware, at least from the point of
view of xkb.
I have no experience with kernel hacking, but I did some reading and..
well here is my idea:
There are the functions input_set_keycode[0] and input_get_keycode which
sound like they do what I want to do.
So I figured, I write a simple kernel module that just calls these
functions with the mappings I want to do.
Trouble is, they also want a pointer to the device that this concerns.
That is of course a reasonable thing to require for that function, just
that I have no idea where to get that from.
I couldn't find any function that would return me a list of the input
devices.
I also saw input_grab_* and input_inject_* which sounds like it could also
be used for my purpose .. but input_set_keycode seemed more reasonable ....
So my questions are:
* Is this approach feasible? Would it work?
* If yes, where to I get the struct input_dev* device, or a list of them,
from?
* If no, what approach do you suggest?
--Marenz
[0]
http://kernel.org/doc/htmldocs/device-drivers/API-input-set-keycode.html
[1] http://neo-layout.org
next reply other threads:[~2012-09-11 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 15:21 Mathias Laurenz Baumann [this message]
2012-09-12 20:49 ` Modifying keycodes or scancodes of keyboard devices Bruno Prémont
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=op.wkg8x5kq486orv@labs03 \
--to=marenz@supradigital.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).