Fix a bug in VkKeyScan.

This commit is contained in:
Dmitry Timoshkov 2003-11-11 21:57:52 +00:00 committed by Alexandre Julliard
parent b40a287e03
commit 4f21b3cd64
1 changed files with 57 additions and 38 deletions

View File

@ -1504,34 +1504,53 @@ WORD X11DRV_VkKeyScan(CHAR cChar)
Display *display = thread_display(); Display *display = thread_display();
KeyCode keycode; KeyCode keycode;
KeySym keysym; KeySym keysym;
int i,index; int i, index;
int highbyte=0; SHORT ret;
/* char->keysym (same for ANSI chars) */ /* char->keysym (same for ANSI chars) */
keysym=(unsigned char) cChar;/* (!) cChar is signed */ keysym = (unsigned char)cChar; /* (!) cChar is signed */
if (keysym<=27) keysym+=0xFF00;/*special chars : return, backspace...*/ if (keysym <= 27) keysym += 0xFF00; /* special chars : return, backspace... */
keycode = TSXKeysymToKeycode(display, keysym); /* keysym -> keycode */ keycode = TSXKeysymToKeycode(display, keysym); /* keysym -> keycode */
if (!keycode) if (!keycode)
{ /* It didn't work ... let's try with deadchar code. */ { /* It didn't work ... let's try with deadchar code. */
TRACE("retrying with | 0xFE00\n");
keycode = TSXKeysymToKeycode(display, keysym | 0xFE00); keycode = TSXKeysymToKeycode(display, keysym | 0xFE00);
} }
TRACE("'%c'(%#lx, %lu): got keycode %#.2x\n", TRACE("'%c'(%#lx, %lu): got keycode %#.2x (%d)\n",
cChar,keysym,keysym,keycode); cChar, keysym, keysym, keycode, keycode);
if (keycode) /* keycode -> (keyc2vkey) vkey */
ret = keyc2vkey[keycode];
if (!keycode || !ret)
{ {
for (index=-1, i=0; (i<8) && (index<0); i++) /* find shift state */ TRACE("keycode for '%c' not found, returning -1\n", cChar);
if (TSXKeycodeToKeysym(display,keycode,i)==keysym) index=i; return -1;
switch (index) { }
case -1 :
WARN("Keysym %lx not found while parsing the keycode table\n",keysym); break; index = -1;
case 0 : break; for (i = 0; i < 4; i++) /* find shift state */
case 1 : highbyte = 0x0100; break; {
case 2 : highbyte = 0x0600; break; if (TSXKeycodeToKeysym(display, keycode, i) == keysym)
case 3 : highbyte = 0x0700; break; {
default : ERR("index %d found by XKeycodeToKeysym. please report! \n",index); index = i;
break;
}
}
switch (index)
{
default:
case -1:
WARN("Keysym %lx not found while parsing the keycode table\n", keysym);
return -1;
case 0: break;
case 1: ret += 0x0100; break;
case 2: ret += 0x0600; break;
case 3: ret += 0x0700; break;
} }
/* /*
index : 0 adds 0x0000 index : 0 adds 0x0000
@ -1540,9 +1559,9 @@ WORD X11DRV_VkKeyScan(CHAR cChar)
index : 2 adds 0x0600 (ctrl+alt) index : 2 adds 0x0600 (ctrl+alt)
index : 3 adds 0x0700 (ctrl+alt+shift) index : 3 adds 0x0700 (ctrl+alt+shift)
*/ */
}
TRACE(" ... returning %#.2x\n", keyc2vkey[keycode]+highbyte); TRACE(" ... returning %#.2x\n", ret);
return keyc2vkey[keycode]+highbyte; /* keycode -> (keyc2vkey) vkey */ return ret;
} }
/*********************************************************************** /***********************************************************************