All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]ioemu: fix altgr-insert behavior
@ 2010-09-02  9:34 Chun Yan Liu
  2010-09-02 16:21 ` Ian Jackson
  0 siblings, 1 reply; 7+ messages in thread
From: Chun Yan Liu @ 2010-09-02  9:34 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 3168 bytes --]

When access to a Xen DomU (Linux) from a VNC client in Windows, alt-gr key is not working properly. When Alt + another key pressed, vncserver receives Altgr down, Altgr up and key down messages in order, that causes incorrect output.
 
With following patch, when vncerver receives key down message, it first check if the keysym needs altgr modifer, if it needs altgr modifier but altgr is not 'down', sending altgr keycode before sending key keycode. 
 
diff -r 17723c0b042b keymaps.c
--- a/keymaps.c Thu Sep 02 16:40:39 2010 +0800
+++ b/keymaps.c Thu Sep 02 17:26:53 2010 +0800
@@ -51,6 +51,7 @@
     struct key_range *numlock_range;
     struct key_range *shift_range;
     struct key_range *localstate_range;
+    struct key_range *altgr_range;
 } kbd_layout_t;
 
 static void add_to_key_range(struct key_range **krp, int code) {
@@ -133,7 +134,11 @@
    add_to_key_range(&k->localstate_range, keycode);
    //fprintf(stderr, "localstate keysym %04x keycode %d\n", keysym, keycode);
       }
-
+      if (rest && strstr(rest, "altgr")) {
+   add_to_key_range(&k->altgr_range, keysym);
+   //fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
+      }
+ 
       /* if(keycode&0x80)
          keycode=(keycode<<8)^0x80e0; */
       if (keysym < MAX_NORMAL_KEYCODE) {
@@ -233,3 +238,16 @@
      return 0;
     return 1;
 }
+
+static inline int keysym_is_altgr(void *kbd_layout, int keysym)
+{
+    kbd_layout_t *k = kbd_layout;
+    struct key_range *kr;
+
+    for (kr = k->altgr_range; kr; kr = kr->next)
+        if (keysym >= kr->start && keysym <= kr->end){
+            return 1;
+ }
+    return 0;
+}
+
diff -r 17723c0b042b vnc.c
--- a/vnc.c Thu Sep 02 16:40:39 2010 +0800
+++ b/vnc.c Thu Sep 02 17:26:53 2010 +0800
@@ -1274,12 +1274,27 @@
     }
 }
 
+static void press_key_altgr_down(VncState *vs, int down)
+{
+    kbd_put_keycode(0xe0);
+    if (down){
+        kbd_put_keycode(0xb8 & 0x7f);
+        vs->modifiers_state[0xb8] = 1;
+    }
+    else {
+        kbd_put_keycode(0xb8 | 0x80);
+        vs->modifiers_state[0xb8] = 0;
+    }
+}
+
 static void do_key_event(VncState *vs, int down, uint32_t sym)
 {
     int keycode;
     int shift_keys = 0;
     int shift = 0;
     int keypad = 0;
+    int altgr = 0;
+    int altgr_keys = 0;
 
     if (is_graphic_console()) {
         if (sym >= 'A' && sym <= 'Z') {
@@ -1289,8 +1304,11 @@
         else {
             shift = keysym_is_shift(vs->kbd_layout, sym & 0xFFFF);
         }
+
+        altgr = keysym_is_altgr(vs->kbd_layout, sym & 0xFFFF);
     }
     shift_keys = vs->modifiers_state[0x2a] | vs->modifiers_state[0x36];
+    altgr_keys = vs->modifiers_state[0xb8];
 
     keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
     if (keycode == 0) {
@@ -1357,6 +1375,11 @@
     }
 
     if (is_graphic_console()) {
+
+        if (altgr && !altgr_keys) {
+            press_key_altgr_down(vs, down);
+        }
+
         /*  If the shift state needs to change then simulate an additional
             keypress before sending this one. Ignore for non shiftable keys.
         */

[-- Attachment #1.2: Type: text/html, Size: 5389 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: [PATCH]ioemu: fix altgr-insert behavior
  2010-09-02  9:34 [PATCH]ioemu: fix altgr-insert behavior Chun Yan Liu
@ 2010-09-02 16:21 ` Ian Jackson
  2010-09-03  3:10   ` 答复: " Chun Yan Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Jackson @ 2010-09-02 16:21 UTC (permalink / raw)
  To: Chun Yan Liu; +Cc: xen-devel

Chun Yan Liu writes ("[Xen-devel][PATCH]ioemu: fix altgr-insert behavior"):
> With following patch, when vncerver receives key down message, it
> first check if the keysym needs altgr modifer, if it needs altgr
> modifier but altgr is not 'down', sending altgr keycode before
> sending key keycode.
>  
> diff -r 17723c0b042b keymaps.c

Thanks, but this patch has been mangled somehow and won't apply.

> +   add_to_key_range(&k->altgr_range, keysym);
> +   //fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
> +      }

Can you try resending it as an attachment ?  Then I can review it
probably in context.

Thanks,
Ian.

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

* 答复: Re: [PATCH]ioemu: fix altgr-insert behavior
  2010-09-02 16:21 ` Ian Jackson
@ 2010-09-03  3:10   ` Chun Yan Liu
  2010-09-08  2:21     ` Chun Yan Liu
  2010-09-10  1:52     ` Chun Yan Liu
  0 siblings, 2 replies; 7+ messages in thread
From: Chun Yan Liu @ 2010-09-03  3:10 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 871 bytes --]



>>> Ian Jackson <Ian.Jackson@eu.citrix.com> 2010/9/3 0:21 >>>
Chun Yan Liu writes ("[Xen-devel][PATCH]ioemu: fix altgr-insert behavior"):
> With following patch, when vncerver receives key down message, it
> first check if the keysym needs altgr modifer, if it needs altgr
> modifier but altgr is not 'down', sending altgr keycode before
> sending key keycode.
>  
> diff -r 17723c0b042b keymaps.c

Thanks, but this patch has been mangled somehow and won't apply.

> +   add_to_key_range(&k->altgr_range, keysym);
> +   //fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
> +      }

Can you try resending it as an attachment ?  Then I can review it
probably in context.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

[-- Attachment #1.2: Type: text/html, Size: 1308 bytes --]

[-- Attachment #2: altgr_keymap.patch --]
[-- Type: text/plain, Size: 2710 bytes --]

diff -r 17723c0b042b keymaps.c
--- a/keymaps.c	Thu Sep 02 16:40:39 2010 +0800
+++ b/keymaps.c	Thu Sep 02 17:26:53 2010 +0800
@@ -51,6 +51,7 @@
     struct key_range *numlock_range;
     struct key_range *shift_range;
     struct key_range *localstate_range;
+    struct key_range *altgr_range;
 } kbd_layout_t;
 
 static void add_to_key_range(struct key_range **krp, int code) {
@@ -133,7 +134,11 @@
 			add_to_key_range(&k->localstate_range, keycode);
 			//fprintf(stderr, "localstate keysym %04x keycode %d\n", keysym, keycode);
 		    }
-
+		    if (rest && strstr(rest, "altgr")) {
+			add_to_key_range(&k->altgr_range, keysym);
+			//fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
+		    }
+	
 		    /* if(keycode&0x80)
 		       keycode=(keycode<<8)^0x80e0; */
 		    if (keysym < MAX_NORMAL_KEYCODE) {
@@ -233,3 +238,16 @@
 	    return 0;
     return 1;
 }
+
+static inline int keysym_is_altgr(void *kbd_layout, int keysym)
+{
+    kbd_layout_t *k = kbd_layout;
+    struct key_range *kr;
+
+    for (kr = k->altgr_range; kr; kr = kr->next)
+        if (keysym >= kr->start && keysym <= kr->end){
+            return 1;
+	}
+    return 0;
+}
+
diff -r 17723c0b042b vnc.c
--- a/vnc.c	Thu Sep 02 16:40:39 2010 +0800
+++ b/vnc.c	Thu Sep 02 17:26:53 2010 +0800
@@ -1274,12 +1274,27 @@
     }
 }
 
+static void press_key_altgr_down(VncState *vs, int down)
+{
+    kbd_put_keycode(0xe0);
+    if (down){
+        kbd_put_keycode(0xb8 & 0x7f);
+        vs->modifiers_state[0xb8] = 1;
+    }
+    else {
+        kbd_put_keycode(0xb8 | 0x80);
+        vs->modifiers_state[0xb8] = 0;
+    }
+}
+
 static void do_key_event(VncState *vs, int down, uint32_t sym)
 {
     int keycode;
     int shift_keys = 0;
     int shift = 0;
     int keypad = 0;
+    int altgr = 0;
+    int altgr_keys = 0;
 
     if (is_graphic_console()) {
         if (sym >= 'A' && sym <= 'Z') {
@@ -1289,8 +1304,11 @@
         else {
             shift = keysym_is_shift(vs->kbd_layout, sym & 0xFFFF);
         }
+
+        altgr = keysym_is_altgr(vs->kbd_layout, sym & 0xFFFF);
     }
     shift_keys = vs->modifiers_state[0x2a] | vs->modifiers_state[0x36];
+    altgr_keys = vs->modifiers_state[0xb8];
 
     keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
     if (keycode == 0) {
@@ -1357,6 +1375,11 @@
     }
 
     if (is_graphic_console()) {
+
+        if (altgr && !altgr_keys) {
+            press_key_altgr_down(vs, down);
+        }
+
         /*  If the shift state needs to change then simulate an additional
             keypress before sending this one. Ignore for non shiftable keys.
         */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* 答复: Re: [PATCH]ioemu: fix altgr-insert behavior
  2010-09-03  3:10   ` 答复: " Chun Yan Liu
@ 2010-09-08  2:21     ` Chun Yan Liu
  2010-09-10  1:52     ` Chun Yan Liu
  1 sibling, 0 replies; 7+ messages in thread
From: Chun Yan Liu @ 2010-09-08  2:21 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1094 bytes --]

Ian, what do you think of the patch?  The altgr problem annoys spanish keyboard users much, many characters cannot be input. So, I hope it can be applied. If it's rejected, please let me know the reason. Thanks. 
- Chunyan

>>> Ian Jackson <Ian.Jackson@eu.citrix.com> 2010/9/3 0:21 >>>
Chun Yan Liu writes ("[Xen-devel][PATCH]ioemu: fix altgr-insert behavior"):
> With following patch, when vncerver receives key down message, it
> first check if the keysym needs altgr modifer, if it needs altgr
> modifier but altgr is not 'down', sending altgr keycode before
> sending key keycode.
>  
> diff -r 17723c0b042b keymaps.c

Thanks, but this patch has been mangled somehow and won't apply.

> +   add_to_key_range(&k->altgr_range, keysym);
> +   //fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
> +      }

Can you try resending it as an attachment ?  Then I can review it
probably in context.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

[-- Attachment #1.2: Type: text/html, Size: 1579 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* [PATCH]ioemu: fix altgr-insert behavior
  2010-09-03  3:10   ` 答复: " Chun Yan Liu
  2010-09-08  2:21     ` Chun Yan Liu
@ 2010-09-10  1:52     ` Chun Yan Liu
  2010-09-10 17:42       ` Ian Jackson
  1 sibling, 1 reply; 7+ messages in thread
From: Chun Yan Liu @ 2010-09-10  1:52 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1346 bytes --]

Ian, attachment is the patch, the same as I've sent in previous mail. I don't know if you've received it before, so I send it again. Please have a review, thanks. 
Any problem, please let me know. Thanks a lot.

>>> Chun Yan Liu 2010/9/8 10:21 >>>
Ian, what do you think of the patch?  The altgr problem annoys spanish keyboard users much, many characters cannot be input. So, I hope it can be applied. If it's rejected, please let me know the reason. Thanks. 
- Chunyan

>>> Ian Jackson <Ian.Jackson@eu.citrix.com> 2010/9/3 0:21 >>>
Chun Yan Liu writes ("[Xen-devel][PATCH]ioemu: fix altgr-insert behavior"):
> With following patch, when vncerver receives key down message, it
> first check if the keysym needs altgr modifer, if it needs altgr
> modifier but altgr is not 'down', sending altgr keycode before
> sending key keycode.
>  
> diff -r 17723c0b042b keymaps.c

Thanks, but this patch has been mangled somehow and won't apply.

> +   add_to_key_range(&k->altgr_range, keysym);
> +   //fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
> +      }

Can you try resending it as an attachment ?  Then I can review it
probably in context.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

[-- Attachment #1.2: Type: text/html, Size: 1879 bytes --]

[-- Attachment #2: altgr_keymap.patch --]
[-- Type: text/plain, Size: 2710 bytes --]

diff -r 17723c0b042b keymaps.c
--- a/keymaps.c	Thu Sep 02 16:40:39 2010 +0800
+++ b/keymaps.c	Thu Sep 02 17:26:53 2010 +0800
@@ -51,6 +51,7 @@
     struct key_range *numlock_range;
     struct key_range *shift_range;
     struct key_range *localstate_range;
+    struct key_range *altgr_range;
 } kbd_layout_t;
 
 static void add_to_key_range(struct key_range **krp, int code) {
@@ -133,7 +134,11 @@
 			add_to_key_range(&k->localstate_range, keycode);
 			//fprintf(stderr, "localstate keysym %04x keycode %d\n", keysym, keycode);
 		    }
-
+		    if (rest && strstr(rest, "altgr")) {
+			add_to_key_range(&k->altgr_range, keysym);
+			//fprintf(stderr, "altgr keysym %04x keycode %d\n", keysym, keycode);
+		    }
+	
 		    /* if(keycode&0x80)
 		       keycode=(keycode<<8)^0x80e0; */
 		    if (keysym < MAX_NORMAL_KEYCODE) {
@@ -233,3 +238,16 @@
 	    return 0;
     return 1;
 }
+
+static inline int keysym_is_altgr(void *kbd_layout, int keysym)
+{
+    kbd_layout_t *k = kbd_layout;
+    struct key_range *kr;
+
+    for (kr = k->altgr_range; kr; kr = kr->next)
+        if (keysym >= kr->start && keysym <= kr->end){
+            return 1;
+	}
+    return 0;
+}
+
diff -r 17723c0b042b vnc.c
--- a/vnc.c	Thu Sep 02 16:40:39 2010 +0800
+++ b/vnc.c	Thu Sep 02 17:26:53 2010 +0800
@@ -1274,12 +1274,27 @@
     }
 }
 
+static void press_key_altgr_down(VncState *vs, int down)
+{
+    kbd_put_keycode(0xe0);
+    if (down){
+        kbd_put_keycode(0xb8 & 0x7f);
+        vs->modifiers_state[0xb8] = 1;
+    }
+    else {
+        kbd_put_keycode(0xb8 | 0x80);
+        vs->modifiers_state[0xb8] = 0;
+    }
+}
+
 static void do_key_event(VncState *vs, int down, uint32_t sym)
 {
     int keycode;
     int shift_keys = 0;
     int shift = 0;
     int keypad = 0;
+    int altgr = 0;
+    int altgr_keys = 0;
 
     if (is_graphic_console()) {
         if (sym >= 'A' && sym <= 'Z') {
@@ -1289,8 +1304,11 @@
         else {
             shift = keysym_is_shift(vs->kbd_layout, sym & 0xFFFF);
         }
+
+        altgr = keysym_is_altgr(vs->kbd_layout, sym & 0xFFFF);
     }
     shift_keys = vs->modifiers_state[0x2a] | vs->modifiers_state[0x36];
+    altgr_keys = vs->modifiers_state[0xb8];
 
     keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
     if (keycode == 0) {
@@ -1357,6 +1375,11 @@
     }
 
     if (is_graphic_console()) {
+
+        if (altgr && !altgr_keys) {
+            press_key_altgr_down(vs, down);
+        }
+
         /*  If the shift state needs to change then simulate an additional
             keypress before sending this one. Ignore for non shiftable keys.
         */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: [PATCH]ioemu: fix altgr-insert behavior
  2010-09-10  1:52     ` Chun Yan Liu
@ 2010-09-10 17:42       ` Ian Jackson
  2010-09-13  2:49         ` 答复: " Chun Yan Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Jackson @ 2010-09-10 17:42 UTC (permalink / raw)
  To: Chun Yan Liu; +Cc: xen-devel

Chun Yan Liu writes ("[Xen-devel][PATCH]ioemu: fix altgr-insert behavior"):
> Ian, attachment is the patch, the same as I've sent in previous
> mail. I don't know if you've received it before, so I send it
> again. Please have a review, thanks.

Thanks.  I've taken a look and I'll apply it but I need a
Signed-Off-By.

You do it like this:
   Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
except with your name and email address.  This indicates that you are
certifying the code as suitable (copyright-wise and so on) for
inclusion in Xen.  You can find the precise meaning in the Linux
upstream kernel tree (Documentation/SubmittingPatches, copy below).

Thanks,
Ian.

>From Documentation/SubmittingPatches:

       Developer's Certificate of Origin 1.1

       By making a contribution to this project, I certify that:

       (a) The contribution was created in whole or in part by me and I
           have the right to submit it under the open source license
           indicated in the file; or

       (b) The contribution is based upon previous work that, to the best
           of my knowledge, is covered under an appropriate open source
           license and I have the right under that license to submit that
           work with modifications, whether created in whole or in part
           by me, under the same open source license (unless I am
           permitted to submit under a different license), as indicated
           in the file; or

       (c) The contribution was provided directly to me by some other
           person who certified (a), (b) or (c) and I have not modified
           it.

       (d) I understand and agree that this project and the contribution
           are public and that a record of the contribution (including all
           personal information I submit with it, including my sign-off) is
           maintained indefinitely and may be redistributed consistent with
           this project or the open source license(s) involved.

--

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

* 答复: Re: [PATCH]ioemu: fix altgr-insert behavior
  2010-09-10 17:42       ` Ian Jackson
@ 2010-09-13  2:49         ` Chun Yan Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Chun Yan Liu @ 2010-09-13  2:49 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 2708 bytes --]

Thank you, Ian. The complete patch description:
 
When access to a Xen DomU (Linux) from a VNC client in Windows, alt-gr key is not working properly with Spanish keyboard. When Alt + another key pressed, vncserver receives Altgr down, Altgr up and key down messages in order, that causes incorrect output.
 
With following patch, when vncerver receives key down message, it first check if the keysym needs altgr modifer, if it needs altgr modifier but altgr is not 'down', sending altgr keycode before sending key keycode. 
 
Signed-off-by: Chunyan Liu <cyliu@novell.com>
 
Thanks,
Chunyan

>>> Ian Jackson <Ian.Jackson@eu.citrix.com> 2010/9/11 1:42 >>>
Chun Yan Liu writes ("[Xen-devel][PATCH]ioemu: fix altgr-insert behavior"):
> Ian, attachment is the patch, the same as I've sent in previous
> mail. I don't know if you've received it before, so I send it
> again. Please have a review, thanks.

Thanks.  I've taken a look and I'll apply it but I need a
Signed-Off-By.

You do it like this:
   Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
except with your name and email address.  This indicates that you are
certifying the code as suitable (copyright-wise and so on) for
inclusion in Xen.  You can find the precise meaning in the Linux
upstream kernel tree (Documentation/SubmittingPatches, copy below).

Thanks,
Ian.

>From Documentation/SubmittingPatches:

       Developer's Certificate of Origin 1.1

       By making a contribution to this project, I certify that:

       (a) The contribution was created in whole or in part by me and I
           have the right to submit it under the open source license
           indicated in the file; or

       (b) The contribution is based upon previous work that, to the best
           of my knowledge, is covered under an appropriate open source
           license and I have the right under that license to submit that
           work with modifications, whether created in whole or in part
           by me, under the same open source license (unless I am
           permitted to submit under a different license), as indicated
           in the file; or

       (c) The contribution was provided directly to me by some other
           person who certified (a), (b) or (c) and I have not modified
           it.

       (d) I understand and agree that this project and the contribution
           are public and that a record of the contribution (including all
           personal information I submit with it, including my sign-off) is
           maintained indefinitely and may be redistributed consistent with
           this project or the open source license(s) involved.

--

[-- Attachment #1.2: Type: text/html, Size: 4188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

end of thread, other threads:[~2010-09-13  2:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02  9:34 [PATCH]ioemu: fix altgr-insert behavior Chun Yan Liu
2010-09-02 16:21 ` Ian Jackson
2010-09-03  3:10   ` 答复: " Chun Yan Liu
2010-09-08  2:21     ` Chun Yan Liu
2010-09-10  1:52     ` Chun Yan Liu
2010-09-10 17:42       ` Ian Jackson
2010-09-13  2:49         ` 答复: " Chun Yan 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.