Skip to contentSkip to conversation

Fix shift key for graphical vnc display

PATCH In review Kasai Takanori 2 participants 3 messages Jul 20, 2007 – Jul 23, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix shift key for graphical vnc display

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.

Best Regards,

--
Takanori Kasai

# HG changeset patch
# User [email protected]
# Date 1184920858 -32400
# Node ID 4fdd61d2134594aea67e9cc2450d8d15810358bc # Parent 1f348e70a5affdea9b44c1e39cd5ef094ad4a0bf [qemu] Fix shift key for graphical vnc displays

tools/ioemu/keymaps.c +16 -0
diff -r 1f348e70a5af -r 4fdd61d21345 tools/ioemu/keymaps.c
@@ -49,6 +49,7 @@ typedef struct {
     int extra_count;
     struct key_range *keypad_range;
     struct key_range *numlock_range;
+    struct key_range *shift_range;
 } kbd_layout_t;
 
 static void add_to_key_range(struct key_range **krp, int code) {
@@ -127,6 +128,10 @@ static kbd_layout_t *parse_keyboard_layo
 			add_to_key_range(&k->numlock_range, keysym);
 			fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
 		    }
+		    if (rest && strstr(rest, "shift")) {
+			add_to_key_range(&k->shift_range, keysym);
+			fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);
+		    }
 
 		    /* if(keycode&0x80)
 		       keycode=(keycode<<8)^0x80e0; */
@@ -205,3 +210,14 @@ static int keysymIsNumlock(void *kbd_lay
 	    return 1;
     return 0;
 }
+
+static int keysymIsShift(void *kbd_layout, int keysym)
+{
+    kbd_layout_t *k = kbd_layout;
+    struct key_range *kr;
+
+    for (kr = k->shift_range; kr; kr = kr->next)
+	if (keysym >= kr->start && keysym <= kr->end)
+	    return 1;
+    return 0;
+}
tools/ioemu/vnc.c +84 -8

130 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 8 lines · Kasai Takanori

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.

Quoted 4 lines

VNC client qemu-dm & GuestOS
--------------+-----------------------

   ja             en-us               ==> NG
   en-us          en-us               ==> OK

I thought the idea of the 'keymap' entry in the vfb config was that you would setup 'qemu-dm' & the GuestOS to be 'ja' too. Trying to make the 'ja' -> 'en-us' conversion work doesn't sound like the kind of thing that would ever work in the general case. Does the 'ja' -> 'ja' case currently work ?

Dan.

Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
#2 lore raw

Re: [PATCH] [IOEMU] Fix shift key for graphical vncdisplay

Hi Daniel,

Thank you for reply.

Quoted 5 lines

I thought the idea of the 'keymap' entry in the vfb config was that you would setup 'qemu-dm' & the GuestOS to be 'ja' too. Trying to make the 'ja' -> 'en-us' conversion work doesn't sound like the kind of thing that would ever work in the general case. Does the 'ja' -> 'ja' case currently work ?

This problem occurs when the keyboard on the VNCClient is different.

The keyboard is different when connecting it usually via VNCServer of Dom0. The VNCClient is transmitted to qemu-dm in the state of shift of en-us. It is necessary to convert it from en-us to ja.

The keyboard cannot be correctly input with virt-manager of RHEL5. Because even if everything is set to Japanese keyboard, the VNCClient of Dom0 inputs it with en-us.

Client Machine    Dom0        Dom0         Dom0      HVM
 (VNCClient)    (VNCServer)  (VNCClient)   qemu-dm   GuestOS
---------------+------------+------------+----------+-----------
   ja              ja          en-us        ja        ja
                                         (keymap=ja)

Therefore, it is usual that the keyboard of VNCClient and qemu-dm is different. We are very embarrassed being not able to do a correct input by this problem.

Best Regards,

--
Takanori Kasai