winex11: Use a table of available OEM virtual key codes.

Restore availability of vkeys prior to VK_OEM_8.  That's safe now that OEM
vkeys are assigned in a separate loop after standard OEM vkey assignments
have been made.
This commit is contained in:
Ken Thomases 2009-10-26 22:29:26 -05:00 committed by Alexandre Julliard
parent f6a6712a31
commit 58156740f9
1 changed files with 30 additions and 16 deletions

View File

@ -1683,11 +1683,21 @@ void X11DRV_InitKeyboard( Display *display )
KeySym keysym;
KeyCode *kcp;
XKeyEvent e2;
WORD scan, vkey, OEMvkey;
WORD scan, vkey;
int keyc, i, keyn, syms;
char ckey[4]={0,0,0,0};
const char (*lkey)[MAIN_LEN][4];
char vkey_used[256] = { 0 };
static const struct {
WORD first, last;
} vkey_ranges[] = {
{ VK_OEM_1, VK_OEM_3 },
{ VK_OEM_4, VK_ICO_00 },
{ 0xe6, 0xe6 },
{ 0xe9, 0xf5 },
{ 0, 0 }
};
int vkey_range;
set_kbd_layout_preload_key();
@ -1861,8 +1871,9 @@ void X11DRV_InitKeyboard( Display *display )
} /* for */
/* Others keys: let's assign OEM virtual key codes in the allowed range,
* that is ([0xba,0xc0], [0xdb,0xe4], 0xe6 (given up) et [0xe9,0xf5]) */
OEMvkey = VK_OEM_8; /* next is available. */
* that is ([0xba,0xc0], [0xdb,0xe4], 0xe6, and [0xe9,0xf5]) */
vkey_range = 0;
vkey = vkey_ranges[vkey_range].first;
for (keyc = min_keycode; keyc <= max_keycode; keyc++)
{
if (keyc2vkey[keyc] & 0xff)
@ -1873,22 +1884,27 @@ void X11DRV_InitKeyboard( Display *display )
if (!keysym)
continue;
do
while (vkey && vkey_used[vkey])
{
switch (++OEMvkey)
if (vkey == vkey_ranges[vkey_range].last)
{
case 0xc1 : OEMvkey=0xdb; break;
case 0xe5 : OEMvkey=0xe9; break;
case 0xf6 : OEMvkey=0xf5; WARN("No more OEM vkey available!\n");
vkey_range++;
vkey = vkey_ranges[vkey_range].first;
}
} while (OEMvkey < 0xf5 && vkey_used[OEMvkey]);
else
vkey++;
}
vkey = VKEY_IF_NOT_USED(OEMvkey);
if (!vkey)
{
WARN("No more vkeys available!\n");
break;
}
if (TRACE_ON(keyboard))
{
TRACE("OEM specific virtual key %X assigned to keycode %X:\n",
OEMvkey, e2.keycode);
vkey, e2.keycode);
TRACE("(");
for (i = 0; i < keysyms_per_keycode; i += 1)
{
@ -1903,11 +1919,9 @@ void X11DRV_InitKeyboard( Display *display )
TRACE(")\n");
}
if (vkey)
{
TRACE("keycode %04x => vkey %04x\n", e2.keycode, vkey);
keyc2vkey[e2.keycode] = vkey;
}
TRACE("keycode %04x => vkey %04x\n", e2.keycode, vkey);
keyc2vkey[e2.keycode] = vkey;
vkey_used[vkey] = 1;
} /* for */
#undef VKEY_IF_NOT_USED