From: "Kasai Takanori" Subject: [PATCH] [IOEMU] Fix shift key for graphical vnc display Date: Fri, 20 Jul 2007 18:45:35 +0900 Message-ID: <169b01c7cab2$de557380$dab2220a@VF03007L> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_168D_01C7CAFE.28B73DF0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_168D_01C7CAFE.28B73DF0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=original Content-Transfer-Encoding: 7bit Hi All, There is a problem in the input of the key in the VNC connection on the HVM domain. When client's keyboard is not the same as the kind of the keyboard of qemu-dm and GuestOS, it is not possible to input it correctly. VNC client qemu-dm & GuestOS --------------+----------------------- ja en-us ==> NG en-us en-us ==> OK Originally, the same keysym-code between client and qemu-dm is transmitted. However, even if it is the same character, the state of shift is different according to the kind of keyboard. ex. "=" charactor --------------------- en-us : "=" ja : shift + "-" Therefore, it is necessary to handle the state of the shift by setting qemu-dm and GuestOS. There is information on whether shift is necessary for each key for the keymap of qemu-dm. ex. VNC client : ja qemu-dm & GuestOS : en-us input key : "=" event client to qemu-dm : shift(push) >> "="(push) >> "="(release) >> shift(release) event qemu-dm to guest : shift(push) >> shift(release) >> "="(push) >> "="(release) >> shift(push) >> shift(release) This patch handled the state of shift from the set keymap. When client's keyboard is not same as the kind of qemu-dm/GuestOS, it is possible to input it correctly. It was confirmed to input it correctly mutually with this patch between en-us and ja. Signed-off-by: Takanori Kasai Best Regards, -- Takanori Kasai ------=_NextPart_000_168D_01C7CAFE.28B73DF0 Content-Type: application/octet-stream; name="fix-ioemu-vnc-shift-key.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fix-ioemu-vnc-shift-key.patch" # HG changeset patch=0A= # User kasai.takanori@jp.fujitsu.com=0A= # Date 1184920858 -32400=0A= # Node ID 4fdd61d2134594aea67e9cc2450d8d15810358bc=0A= # Parent 1f348e70a5affdea9b44c1e39cd5ef094ad4a0bf=0A= [qemu] Fix shift key for graphical vnc displays=0A= =0A= Signed-off-by: Takanori Kasai =0A= =0A= diff -r 1f348e70a5af -r 4fdd61d21345 tools/ioemu/keymaps.c=0A= --- a/tools/ioemu/keymaps.c Tue Jul 10 11:10:38 2007 +0100=0A= +++ b/tools/ioemu/keymaps.c Fri Jul 20 17:40:58 2007 +0900=0A= @@ -49,6 +49,7 @@ typedef struct {=0A= int extra_count;=0A= struct key_range *keypad_range;=0A= struct key_range *numlock_range;=0A= + struct key_range *shift_range;=0A= } kbd_layout_t;=0A= =0A= static void add_to_key_range(struct key_range **krp, int code) {=0A= @@ -127,6 +128,10 @@ static kbd_layout_t *parse_keyboard_layo=0A= add_to_key_range(&k->numlock_range, keysym);=0A= fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);=0A= }=0A= + if (rest && strstr(rest, "shift")) {=0A= + add_to_key_range(&k->shift_range, keysym);=0A= + fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);=0A= + }=0A= =0A= /* if(keycode&0x80)=0A= keycode=3D(keycode<<8)^0x80e0; */=0A= @@ -205,3 +210,14 @@ static int keysymIsNumlock(void *kbd_lay=0A= return 1;=0A= return 0;=0A= }=0A= +=0A= +static int keysymIsShift(void *kbd_layout, int keysym)=0A= +{=0A= + kbd_layout_t *k =3D kbd_layout;=0A= + struct key_range *kr;=0A= +=0A= + for (kr =3D k->shift_range; kr; kr =3D kr->next)=0A= + if (keysym >=3D kr->start && keysym <=3D kr->end)=0A= + return 1;=0A= + return 0;=0A= +}=0A= diff -r 1f348e70a5af -r 4fdd61d21345 tools/ioemu/vnc.c=0A= --- a/tools/ioemu/vnc.c Tue Jul 10 11:10:38 2007 +0100=0A= +++ b/tools/ioemu/vnc.c Fri Jul 20 17:40:58 2007 +0900=0A= @@ -915,12 +915,69 @@ static void press_key(VncState *vs, int =0A= kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) | 0x80);=0A= }=0A= =0A= +static void press_key_shift_down(VncState *vs, int down, int keycode)=0A= +{=0A= + if (down)=0A= + kbd_put_keycode(0x2a & 0x7f);=0A= +=0A= + if (keycode & 0x80)=0A= + kbd_put_keycode(0xe0);=0A= + if (down)=0A= + kbd_put_keycode(keycode & 0x7f);=0A= + else=0A= + kbd_put_keycode(keycode | 0x80);=0A= +=0A= + if (!down)=0A= + kbd_put_keycode(0x2a | 0x80);=0A= +}=0A= +=0A= +static void press_key_shift_up(VncState *vs, int down, int keycode)=0A= +{=0A= + if (down) {=0A= + if (vs->modifiers_state[0x2a])=0A= + kbd_put_keycode(0x2a | 0x80);=0A= + if (vs->modifiers_state[0x36]) =0A= + kbd_put_keycode(0x36 | 0x80);=0A= + }=0A= +=0A= + if (keycode & 0x80)=0A= + kbd_put_keycode(0xe0);=0A= + if (down)=0A= + kbd_put_keycode(keycode & 0x7f);=0A= + else=0A= + kbd_put_keycode(keycode | 0x80);=0A= +=0A= + if (!down) {=0A= + if (vs->modifiers_state[0x2a])=0A= + kbd_put_keycode(0x2a & 0x7f);=0A= + if (vs->modifiers_state[0x36]) =0A= + kbd_put_keycode(0x36 & 0x7f);=0A= + }=0A= +}=0A= +=0A= static void do_key_event(VncState *vs, int down, uint32_t sym)=0A= {=0A= int keycode;=0A= + int shift_keys =3D 0;=0A= + int shift =3D 0;=0A= +=0A= + if (is_graphic_console()) {=0A= + if (sym >=3D 'A' && sym <=3D 'Z') {=0A= + sym =3D sym - 'A' + 'a';=0A= + shift =3D 1;=0A= + }=0A= + else {=0A= + shift =3D keysymIsShift(vs->kbd_layout, sym & 0xFFFF);=0A= + }=0A= + }=0A= + shift_keys =3D vs->modifiers_state[0x2a] | = vs->modifiers_state[0x36];=0A= =0A= keycode =3D keysym2scancode(vs->kbd_layout, sym & 0xFFFF);=0A= - =0A= + if (keycode =3D=3D 0) {=0A= + fprintf(stderr, "Key lost : keysym=3D0x%x(%d)\n", sym, sym);=0A= + return;=0A= + }=0A= +=0A= /* QEMU console switch */=0A= switch(keycode) {=0A= case 0x2a: /* Left Shift */=0A= @@ -929,11 +986,15 @@ static void do_key_event(VncState *vs, i=0A= case 0x9d: /* Right CTRL */=0A= case 0x38: /* Left ALT */=0A= case 0xb8: /* Right ALT */=0A= - if (down)=0A= + if (down) {=0A= vs->modifiers_state[keycode] =3D 1;=0A= - else=0A= + kbd_put_keycode(keycode & 0x7f);=0A= + }=0A= + else {=0A= vs->modifiers_state[keycode] =3D 0;=0A= - break;=0A= + kbd_put_keycode(keycode | 0x80);=0A= + }=0A= + return;=0A= case 0x02 ... 0x0a: /* '1' to '9' keys */ =0A= if (down && vs->modifiers_state[0x1d] && = vs->modifiers_state[0x38]) {=0A= /* Reset the modifiers sent to the current console */=0A= @@ -943,9 +1004,14 @@ static void do_key_event(VncState *vs, i=0A= }=0A= break;=0A= case 0x45: /* NumLock */=0A= - if (!down)=0A= + if (down) {=0A= + kbd_put_keycode(keycode & 0x7f);=0A= + }=0A= + else { =0A= vs->modifiers_state[keycode] ^=3D 1;=0A= - break;=0A= + kbd_put_keycode(keycode | 0x80);=0A= + }=0A= + return;=0A= }=0A= =0A= if (keycodeIsKeypad(vs->kbd_layout, keycode)) {=0A= @@ -967,6 +1033,18 @@ static void do_key_event(VncState *vs, i=0A= }=0A= =0A= if (is_graphic_console()) {=0A= + /* If the shift state needs to change then simulate an = additional=0A= + keypress before sending this one.=0A= + */=0A= + if (shift && !shift_keys) {=0A= + press_key_shift_down(vs, down, keycode);=0A= + return;=0A= + }=0A= + else if (!shift && shift_keys) {=0A= + press_key_shift_up(vs, down, keycode);=0A= + return;=0A= + }=0A= +=0A= if (keycode & 0x80)=0A= kbd_put_keycode(0xe0);=0A= if (down)=0A= @@ -1021,8 +1099,6 @@ static void do_key_event(VncState *vs, i=0A= =0A= static void key_event(VncState *vs, int down, uint32_t sym)=0A= {=0A= - if (sym >=3D 'A' && sym <=3D 'Z' && is_graphic_console())=0A= - sym =3D sym - 'A' + 'a';=0A= do_key_event(vs, down, sym);=0A= }=0A= =0A= ------=_NextPart_000_168D_01C7CAFE.28B73DF0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_NextPart_000_168D_01C7CAFE.28B73DF0--