All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, dmitry.torokhov@gmail.com,
	linux-input@vger.kernel.org
Subject: [PATCH] Let keyboard notifiers modify key codes
Date: Wed, 7 Jan 2009 01:58:13 +0100	[thread overview]
Message-ID: <20090107005813.GA4987@const.famille.thibault.fr> (raw)

Make kbd_keycode() read param.value after calling the keyboard notification
chain, to let the callee change the translation on the fly. This for instance
permits to remap the physical positions of the keys independently of the
configured keymap, for e.g. single-handed people.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

--- linux/drivers/char/keyboard.c.orig	2009-01-07 00:48:46.000000000 +0100
+++ linux/drivers/char/keyboard.c	2009-01-07 01:02:05.000000000 +0100
@@ -1248,6 +1248,7 @@ kbd_keycode
 		kbd->slockstate = 0;
 		return;
 	}
+	keycode = param.value;
 
 	if (keycode >= NR_KEYS)
 		if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
@@ -1263,6 +1264,7 @@ kbd_keycode
 		param.value = keysym;
 		if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNICODE, &param) == NOTIFY_STOP)
 			return;
+		keysym = param.value;
 		if (down && !raw_mode)
 			to_utf8(vc, keysym);
 		return;
@@ -1282,6 +1284,7 @@ kbd_keycode
 
 	if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_KEYSYM, &param) == NOTIFY_STOP)
 		return;
+	keysym = param.value;
 
 	if (raw_mode && type != KT_SPEC && type != KT_SHIFT)
 		return;
--- linux/Documentation/input/notifier.txt.orig	2008-04-17 12:14:30.000000000 +0200
+++ linux/Documentation/input/notifier.txt	2009-01-07 01:04:16.000000000 +0100
@@ -21,7 +21,8 @@
 
 For each kind of event but the last, the callback may return NOTIFY_STOP in
 order to "eat" the event: the notify loop is stopped and the keyboard event is
-dropped.
+dropped.  The callee can also modify param.value so as to change the key
+translation.
 
 In a rough C snippet, we have:
 
@@ -33,18 +34,26 @@
 		notifier_call_chain(KBD_UNBOUND_KEYCODE,&params);
 		return;
 	}
+	keycode = param.value;
+
+	...
 
 	if (unicode) {
 		param.value = unicode;
 		if (notifier_call_chain(KBD_UNICODE,&params) == NOTIFY_STOP)
 			return;
+		keysym = param.value;
 		emit unicode;
 		return;
 	}
 
+	...
+
 	params.value = keysym;
 	if (notifier_call_chain(KBD_KEYSYM,&params) == NOTIFY_STOP)
 		return;
+	keysym = params.value;
+
 	apply keysym;
 	notifier_call_chain(KBD_POST_KEYSYM,&params);
 }

             reply	other threads:[~2009-01-07  0:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-07  0:58 Samuel Thibault [this message]
2009-01-09 21:23 ` Re (hello?): [PATCH] Let keyboard notifiers modify key codes Samuel Thibault
2009-01-09 21:23   ` Samuel Thibault
2009-01-09 21:35   ` Alan Cox
2009-01-09 21:43     ` Samuel Thibault
2009-01-09 21:43       ` Samuel Thibault
2009-01-09 22:01       ` Alan Cox
2009-01-09 22:23         ` Samuel Thibault
2009-01-09 22:23           ` Samuel Thibault
2009-01-12 22:36           ` Derek Fawcus
2009-01-12 22:36             ` Derek Fawcus
2009-01-12 22:51             ` Samuel Thibault
2009-01-12 22:51               ` Samuel Thibault
2009-01-13  1:06               ` Derek Fawcus
2009-01-13  1:06                 ` Derek Fawcus
2009-01-13  1:45                 ` Samuel Thibault
2009-01-13  1:45                   ` Samuel Thibault
2009-01-15  7:40       ` Pavel Machek
2009-01-15  7:40         ` Pavel Machek
2009-01-16 19:36         ` Samuel Thibault
2009-01-16 19:36           ` Samuel Thibault

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=20090107005813.GA4987@const.famille.thibault.fr \
    --to=samuel.thibault@ens-lyon.org \
    --cc=akpm@linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.