All of lore.kernel.org
 help / color / mirror / Atom feed
* make the CtrlR and CtrlL modifier output different keys
@ 2009-09-18  5:13 Xiangfu Liu
  2009-09-18  6:10 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Xiangfu Liu @ 2009-09-18  5:13 UTC (permalink / raw)
  To: linux-input

[-- 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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: make the CtrlR and CtrlL modifier output different keys
  2009-09-18  5:13 make the CtrlR and CtrlL modifier output different keys Xiangfu Liu
@ 2009-09-18  6:10 ` Dmitry Torokhov
  2009-09-18  6:46   ` Xiangfu Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2009-09-18  6:10 UTC (permalink / raw)
  To: Xiangfu Liu; +Cc: linux-input

On Fri, Sep 18, 2009 at 01:13:17PM +0800, Xiangfu Liu wrote:
> 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.

You should be able to do what you want by loading proper keymap; no need
to adjust the keyboard code (especially in a way that does not make
sense for other devices).

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: make the CtrlR and CtrlL modifier output different keys
  2009-09-18  6:10 ` Dmitry Torokhov
@ 2009-09-18  6:46   ` Xiangfu Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Xiangfu Liu @ 2009-09-18  6:46 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

Dmitry Torokhov wrote:
> On Fri, Sep 18, 2009 at 01:13:17PM +0800, Xiangfu Liu wrote:
>> 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.
> 
> You should be able to do what you want by loading proper keymap; no need
> to adjust the keyboard code (especially in a way that does not make
> sense for other devices).
> 
yes. I saw your last email. it's work on. I revert the code in our kernel
repos. thanks again.

Best Regards
-- 
Xiangfu Liu
Email: xiangfu at qi-hardware dot com
Web: http://www.qi-hardware.com
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-18  6:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-18  5:13 make the CtrlR and CtrlL modifier output different keys Xiangfu Liu
2009-09-18  6:10 ` Dmitry Torokhov
2009-09-18  6:46   ` Xiangfu Liu

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.