All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiangfu Liu <xiangfu.z@gmail.com>
To: linux-input@vger.kernel.org
Subject: make the CtrlR and CtrlL modifier output different keys
Date: Fri, 18 Sep 2009 13:13:17 +0800	[thread overview]
Message-ID: <4AB316ED.80005@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

Hi.

I want make the CtrlR and CtrlL output different keys.
like:

CtrlR + U = 7
CtrlR + U = Control + U.

so I modify the keyboard.c code. attach is the code.

give me some feedback about this patch.
thanks.


-- 
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com

[-- Attachment #2: 510-Fn-modifier-keys-work.patch --]
[-- Type: text/x-patch, Size: 3440 bytes --]

diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c
index 5859589..ddd7d3f 100644
--- a/arch/mips/jz4740/platform.c
+++ b/arch/mips/jz4740/platform.c
@@ -242,11 +242,11 @@ static struct platform_device jz_nand_device = {
  * don't define this. the keyboard and keyboard both work
  */
 
-#define KEY_QI_QI		KEY_F13
-#define KEY_QI_UPRED	KEY_RIGHTCTRL
+#define KEY_QI_QI	KEY_RIGHTCTRL
+#define KEY_QI_UPRED	KEY_RIGHTSHIFT
 #define KEY_QI_VOLUP	KEY_F15
 #define KEY_QI_VOLDOWN	KEY_F16
-#define KEY_QI_FN	KEY_F17
+#define KEY_QI_FN	KEY_RIGHTCTRL
 
 static const uint32_t qi_lb60_keymap[] = {
 	KEY(0, 0, KEY_F1),	/* S2 */
diff --git a/drivers/char/defkeymap.map b/drivers/char/defkeymap.map
index 25d05b4..497cfc2 100644
--- a/drivers/char/defkeymap.map
+++ b/drivers/char/defkeymap.map
@@ -113,9 +113,9 @@ keycode  43 = backslash        bar
 	control keycode  43 = Control_backslash
 	alt     keycode  43 = Meta_backslash  
 keycode  44 = z               
-	altgr   keycode  43 = nine
+	altgr   keycode  44 = nine
 keycode  45 = x               
-	altgr   keycode  43 = zero
+	altgr   keycode  45 = zero
 keycode  46 = c
 	altgr   keycode  46 = Hex_C   
 keycode  47 = v               
@@ -133,7 +133,7 @@ keycode  52 = period           greater
 keycode  53 = slash            question        
 	control keycode  53 = Delete          
 	alt     keycode  53 = Meta_slash      
-keycode  54 = Shift           
+keycode  54 = AltGr
 keycode  55 = KP_Multiply     
 keycode  56 = Alt             
 keycode  57 = space            space           
@@ -240,7 +240,7 @@ keycode  93 =
 keycode  94 =
 keycode  95 =
 keycode  96 = KP_Enter        
-keycode  97 = AltGr
+keycode  97 = Control
 keycode  98 = KP_Divide       
 keycode  99 = Control_backslash
 	control keycode  99 = Control_backslash
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 737be95..4cdd9ac 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -121,6 +121,8 @@ struct vt_spawn_console vt_spawn_con = {
 	.sig  = 0,
 };
 
+static int ctrlr = 0;
+
 /*
  * Variables exported for vt.c
  */
@@ -1133,6 +1135,60 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, unsigned char u
 }
 #endif
 
+static int qi_keymap(int keysym, int keycode, int up_flag)
+{
+	int ret;
+	ret = keysym;
+
+	if (up_flag && keycode == KEY_RIGHTCTRL) {
+		ctrlr = 0;
+		return ret;
+	}
+
+	if (ctrlr) {
+		switch (keycode) {
+		case KEY_SLASH:	/* 0 */
+			ret = 61488;
+			break;
+		case KEY_N:	/* 1 */
+			ret = 61489;
+			break;
+		case KEY_M:	/* 2 */
+			ret = 61490;
+			break;
+		case KEY_B:	/* 3 */
+			ret = 61491;
+			break;
+		case KEY_J:	/* 4 */
+			ret = 61492;
+			break;
+		case KEY_K:	/* 5 */
+			ret = 61493;
+			break;
+		case KEY_L:	/* 6 */
+			ret = 61494;
+			break;
+		case KEY_U:	/* 7 */
+			ret = 61495;
+			break;
+		case KEY_I:	/* 8 */
+			ret = 61496;
+			break;
+		case KEY_O:	/* 9 */
+			ret = 61497;
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (keycode == KEY_RIGHTCTRL) {
+		ctrlr = 1;
+	}
+
+	return ret;
+}
+
 static void kbd_rawcode(unsigned char data)
 {
 	struct vc_data *vc = vc_cons[fg_console].d;
@@ -1284,6 +1340,8 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 	if (raw_mode && type != KT_SPEC && type != KT_SHIFT)
 		return;
 
+	keysym = qi_keymap(keysym, keycode, !down);
+
 	(*k_handler[type])(vc, keysym & 0xff, !down);
 
 	param.ledstate = kbd->ledflagstate;

             reply	other threads:[~2009-09-18  5:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-18  5:13 Xiangfu Liu [this message]
2009-09-18  6:10 ` make the CtrlR and CtrlL modifier output different keys Dmitry Torokhov
2009-09-18  6:46   ` Xiangfu Liu

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=4AB316ED.80005@gmail.com \
    --to=xiangfu.z@gmail.com \
    --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 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.