From: "Kasai Takanori" Subject: [PATCH] [PVFB] Fix shift key for graphical vnc display Date: Fri, 20 Jul 2007 18:54:06 +0900 Message-ID: <16af01c7cab3$eb813a20$dab2220a@VF03007L> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_16AC_01C7CAFF.59495D80" 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_16AC_01C7CAFF.59495D80 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 PV domain. When client's keyboard is not the same as the kind of the keyboard of PVFB and GuestOS, it is not possible to input it correctly. This patch handled the state of shift from the set keymap. When client's keyboard is not same as the kind of PVFB/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 ----- Original Message ----- From: "Kasai Takanori" To: "xen-devel" Sent: Friday, July 20, 2007 6:45 PM Subject: [Xen-devel] [PATCH] [IOEMU] 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. > > Signed-off-by: Takanori Kasai > > Best Regards, > > -- > Takanori Kasai > ------=_NextPart_000_16AC_01C7CAFF.59495D80 Content-Type: application/octet-stream; name="fix-vncfb-shift-key.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fix-vncfb-shift-key.patch" # HG changeset patch=0A= # User kasai.takanori@jp.fujitsu.com=0A= # Date 1184920987 -32400=0A= # Node ID e7bdc3a8c5b2977f00aec1e01637314add6927df=0A= # Parent 4fdd61d2134594aea67e9cc2450d8d15810358bc=0A= [PVFB] Fix shift key for vnc display=0A= =0A= Signed-off-by: Takanori Kasai =0A= =0A= diff -r 4fdd61d21345 -r e7bdc3a8c5b2 tools/xenfb/vncfb.c=0A= --- a/tools/xenfb/vncfb.c Fri Jul 20 17:40:58 2007 +0900=0A= +++ b/tools/xenfb/vncfb.c Fri Jul 20 17:43:07 2007 +0900=0A= @@ -55,11 +55,46 @@ unsigned char keycode_table[512];=0A= unsigned char keycode_table[512];=0A= =0A= static void *kbd_layout;=0A= +uint8_t modifiers_state[256];=0A= =0A= static int btnmap[] =3D {=0A= BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_SIDE,=0A= BTN_EXTRA, BTN_FORWARD, BTN_BACK, BTN_TASK=0A= };=0A= +=0A= +static void press_key_shift_down(struct xenfb* xenfb, int down, int = scancode)=0A= +{=0A= + if (down)=0A= + xenfb_send_key(xenfb, 1, keycode_table[0x2a]);=0A= +=0A= + if (xenfb_send_key(xenfb, down, keycode_table[scancode]) < 0)=0A= + fprintf(stderr, "Key %d %s lost (%s)\n",=0A= + scancode, "down", strerror(errno));=0A= +=0A= + if (!down)=0A= + xenfb_send_key(xenfb, 0, keycode_table[0x2a]);=0A= +}=0A= +=0A= +static void press_key_shift_up(struct xenfb* xenfb, int down, int = scancode)=0A= +{=0A= + if (down) {=0A= + if (modifiers_state[0x2a])=0A= + xenfb_send_key(xenfb, 0, keycode_table[0x2a]);=0A= + if (modifiers_state[0x36])=0A= + xenfb_send_key(xenfb, 0, keycode_table[0x36]);=0A= + }=0A= +=0A= + if (xenfb_send_key(xenfb, down, keycode_table[scancode]) < 0)=0A= + fprintf(stderr, "Key %d %s lost (%s)\n",=0A= + scancode, "down", strerror(errno));=0A= +=0A= + if (!down) {=0A= + if (modifiers_state[0x2a])=0A= + xenfb_send_key(xenfb, 1, keycode_table[0x2a]);=0A= + if (modifiers_state[0x36])=0A= + xenfb_send_key(xenfb, 1, keycode_table[0x36]);=0A= + }=0A= +}=0A= =0A= static void on_kbd_event(rfbBool down, rfbKeySym keycode, rfbClientPtr = cl)=0A= {=0A= @@ -75,14 +110,75 @@ static void on_kbd_event(rfbBool down, r=0A= rfbScreenInfoPtr server =3D cl->screen;=0A= struct xenfb *xenfb =3D server->screenData;=0A= int scancode;=0A= -=0A= - if (keycode >=3D 'A' && keycode <=3D 'Z')=0A= + int shift =3D 0;=0A= + int shift_keys =3D 0;=0A= +=0A= + if (keycode >=3D 'A' && keycode <=3D 'Z') {=0A= keycode +=3D 'a' - 'A';=0A= -=0A= - scancode =3D keycode_table[keysym2scancode(kbd_layout, keycode)];=0A= + shift =3D 1;=0A= + }=0A= + else {=0A= + shift =3D keysymIsShift(kbd_layout, keycode);=0A= + }=0A= + shift_keys =3D modifiers_state[0x2a] | modifiers_state[0x36]; =0A= +=0A= + scancode =3D keysym2scancode(kbd_layout, keycode);=0A= if (scancode =3D=3D 0)=0A= return;=0A= - if (xenfb_send_key(xenfb, down, scancode) < 0)=0A= +=0A= + switch(scancode) {=0A= + case 0x2a: /* Left Shift */=0A= + case 0x36: /* Right Shift */=0A= + case 0x1d: /* Left CTRL */=0A= + case 0x9d: /* Right CTRL */=0A= + case 0x38: /* Left ALT */=0A= + case 0xb8: /* Right ALT */=0A= + if (down)=0A= + modifiers_state[scancode] =3D 1;=0A= + else=0A= + modifiers_state[scancode] =3D 0;=0A= + xenfb_send_key(xenfb, down, keycode_table[scancode]); =0A= + return;=0A= + case 0x45: /* NumLock */=0A= + if (!down)=0A= + modifiers_state[scancode] ^=3D 1;=0A= + xenfb_send_key(xenfb, down, keycode_table[scancode]);=0A= + return;=0A= + }=0A= +=0A= + if (keycodeIsKeypad(kbd_layout, scancode)) {=0A= + /* If the numlock state needs to change then simulate an additional=0A= + keypress before sending this one. This will happen if the user=0A= + toggles numlock away from the VNC window.=0A= + */=0A= + if (keysymIsNumlock(kbd_layout, keycode)) {=0A= + if (!modifiers_state[0x45]) {=0A= + modifiers_state[0x45] =3D 1;=0A= + xenfb_send_key(xenfb, 1, keycode_table[0x45]);=0A= + xenfb_send_key(xenfb, 0, keycode_table[0x45]);=0A= + }=0A= + } else {=0A= + if (modifiers_state[0x45]) {=0A= + modifiers_state[0x45] =3D 0;=0A= + xenfb_send_key(xenfb, 1, keycode_table[0x45]);=0A= + xenfb_send_key(xenfb, 0, keycode_table[0x45]);=0A= + }=0A= + }=0A= + }=0A= +=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(xenfb, down, scancode);=0A= + return;=0A= + }=0A= + else if (!shift && shift_keys) {=0A= + press_key_shift_up(xenfb, down, scancode);=0A= + return;=0A= + }=0A= +=0A= + if (xenfb_send_key(xenfb, down, keycode_table[scancode]) < 0)=0A= fprintf(stderr, "Key %d %s lost (%s)\n",=0A= scancode, down ? "down" : "up",=0A= strerror(errno));=0A= @@ -314,6 +410,10 @@ int main(int argc, char **argv)=0A= atkbd_set2_keycode[atkbd_unxlate_table[i] | 0x80];=0A= }=0A= =0A= + for (i =3D 0; i < 256; i++ ) {=0A= + modifiers_state[i] =3D 0;=0A= + }=0A= +=0A= fake_argv[2] =3D portstr;=0A= =0A= if (title !=3D NULL)=0A= ------=_NextPart_000_16AC_01C7CAFF.59495D80 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_16AC_01C7CAFF.59495D80--