'Realigned' the layout table a bit. Applied the non-latin-1 stuff and
the dead key mapping stuff to the actual mapping code too. Prettied up the fixme message. Added a check where if the keys of two layouts match exactly, the one with the best-matching keycode order is chosen, so that the QWERTY and Dvorak layouts can be distinguished.
This commit is contained in:
parent
c53def75cf
commit
787cf10922
|
@ -520,10 +520,11 @@ void X11DRV_KEYBOARD_HandleEvent( WND *pWnd, XKeyEvent *event )
|
||||||
void
|
void
|
||||||
X11DRV_KEYBOARD_DetectLayout (void)
|
X11DRV_KEYBOARD_DetectLayout (void)
|
||||||
{
|
{
|
||||||
unsigned current, match, mismatch;
|
unsigned current, match, mismatch, seq;
|
||||||
int score, keyc, i, key, ok, syms;
|
int score, keyc, i, key, pkey, ok, syms;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
const char (*lkey)[MAIN_LEN][4];
|
const char (*lkey)[MAIN_LEN][4];
|
||||||
|
unsigned max_seq = 0;
|
||||||
int max_score = 0, ismatch = 0;
|
int max_score = 0, ismatch = 0;
|
||||||
char ckey[4] =
|
char ckey[4] =
|
||||||
{0, 0, 0, 0};
|
{0, 0, 0, 0};
|
||||||
|
@ -539,7 +540,9 @@ X11DRV_KEYBOARD_DetectLayout (void)
|
||||||
match = 0;
|
match = 0;
|
||||||
mismatch = 0;
|
mismatch = 0;
|
||||||
score = 0;
|
score = 0;
|
||||||
|
seq = 0;
|
||||||
lkey = main_key_tab[current].key;
|
lkey = main_key_tab[current].key;
|
||||||
|
pkey = -1;
|
||||||
for (keyc = min_keycode; keyc <= max_keycode; keyc++) {
|
for (keyc = min_keycode; keyc <= max_keycode; keyc++) {
|
||||||
/* get data for keycode from X server */
|
/* get data for keycode from X server */
|
||||||
for (i = 0; i < syms; i++) {
|
for (i = 0; i < syms; i++) {
|
||||||
|
@ -570,9 +573,12 @@ X11DRV_KEYBOARD_DetectLayout (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* count the matches and mismatches */
|
/* count the matches and mismatches */
|
||||||
if (ok > 0)
|
if (ok > 0) {
|
||||||
match++;
|
match++;
|
||||||
else {
|
/* and how much the keycode order matches */
|
||||||
|
if (key > pkey) seq++;
|
||||||
|
pkey = key;
|
||||||
|
} else {
|
||||||
TRACE (key, "mismatch for keycode %d, character %c\n", keyc,
|
TRACE (key, "mismatch for keycode %d, character %c\n", keyc,
|
||||||
ckey[0]);
|
ckey[0]);
|
||||||
mismatch++;
|
mismatch++;
|
||||||
|
@ -582,19 +588,21 @@ X11DRV_KEYBOARD_DetectLayout (void)
|
||||||
}
|
}
|
||||||
TRACE (keyboard, "matches=%d, mismatches=%d, score=%d\n",
|
TRACE (keyboard, "matches=%d, mismatches=%d, score=%d\n",
|
||||||
match, mismatch, score);
|
match, mismatch, score);
|
||||||
if (score > max_score) {
|
if ((score > max_score) ||
|
||||||
|
((score == max_score) && (seq > max_seq))) {
|
||||||
/* best match so far */
|
/* best match so far */
|
||||||
kbd_layout = current;
|
kbd_layout = current;
|
||||||
max_score = score;
|
max_score = score;
|
||||||
|
max_seq = seq;
|
||||||
ismatch = !mismatch;
|
ismatch = !mismatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* we're done, report results if necessary */
|
/* we're done, report results if necessary */
|
||||||
if (!ismatch) {
|
if (!ismatch) {
|
||||||
FIXME (keyboard,
|
FIXME (keyboard,
|
||||||
"Your keyboard layout was not found! Using closest match (%04x).\n"
|
"Your keyboard layout was not found!\n"
|
||||||
"Please define your layout in windows/x11drv/keyboard.c "
|
"Instead using closest match (%04x) for scancode mapping.\n"
|
||||||
"and submit them\n"
|
"Please define your layout in windows/x11drv/keyboard.c and submit them\n"
|
||||||
"to us for inclusion into future Wine releases.\n"
|
"to us for inclusion into future Wine releases.\n"
|
||||||
"See documentation/keyboard for more information.\n",
|
"See documentation/keyboard for more information.\n",
|
||||||
main_key_tab[kbd_layout].lang);
|
main_key_tab[kbd_layout].lang);
|
||||||
|
@ -705,8 +713,11 @@ void X11DRV_KEYBOARD_Init(void)
|
||||||
int maxlen=0,maxval=-1,ok;
|
int maxlen=0,maxval=-1,ok;
|
||||||
for (i=0; i<syms; i++) {
|
for (i=0; i<syms; i++) {
|
||||||
keysym = TSXKeycodeToKeysym(display, keyc, i);
|
keysym = TSXKeycodeToKeysym(display, keyc, i);
|
||||||
if ((keysym<0x100)&&(keysym!=' ')) ckey[i] = keysym;
|
if ((keysym<0x800) && (keysym!=' ')) {
|
||||||
else ckey[i] = 0;
|
ckey[i] = keysym & 0xFF;
|
||||||
|
} else {
|
||||||
|
ckey[i] = KEYBOARD_MapDeadKeysym(keysym);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* find key with longest match streak */
|
/* find key with longest match streak */
|
||||||
for (keyn=0; keyn<MAIN_LEN; keyn++) {
|
for (keyn=0; keyn<MAIN_LEN; keyn++) {
|
||||||
|
|
Loading…
Reference in New Issue