Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f15d1806
Commit
f15d1806
authored
Mar 28, 1999
by
Pavel Roskin
Committed by
Alexandre Julliard
Mar 28, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes in X11DRV_KEYBOARD_DetectLayout in order to implement Russian
keyboard support.
parent
f80b2ab6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
49 deletions
+75
-49
keyboard.c
windows/x11drv/keyboard.c
+75
-49
No files found.
windows/x11drv/keyboard.c
View file @
f15d1806
...
@@ -505,62 +505,88 @@ void X11DRV_KEYBOARD_HandleEvent( WND *pWnd, XKeyEvent *event )
...
@@ -505,62 +505,88 @@ void X11DRV_KEYBOARD_HandleEvent( WND *pWnd, XKeyEvent *event )
* This routine walks through the defined keyboard layouts and selects
* This routine walks through the defined keyboard layouts and selects
* whichever matches most closely.
* whichever matches most closely.
*/
*/
void
X11DRV_KEYBOARD_DetectLayout
(
void
)
void
X11DRV_KEYBOARD_DetectLayout
(
void
)
{
{
unsigned
current
,
match
,
mismatch
;
unsigned
current
,
match
,
mismatch
;
int
max_score
=
0
,
ismatch
=
0
;
int
score
,
keyc
,
i
,
key
,
ok
,
syms
;
int
score
,
keyc
,
i
,
key
,
ok
,
syms
=
(
keysyms_per_keycode
>
4
)
?
4
:
keysyms_per_keycode
;
KeySym
keysym
;
KeySym
keysym
;
const
char
(
*
lkey
)[
MAIN_LEN
][
4
];
char
ckey
[
4
]
=
{
0
,
0
,
0
,
0
};
int
max_score
=
0
,
ismatch
=
0
;
const
char
(
*
lkey
)[
MAIN_LEN
][
4
];
char
ckey
[
4
]
=
{
0
,
0
,
0
,
0
};
for
(
current
=
0
;
main_key_tab
[
current
].
lang
;
current
++
)
{
TRACE
(
keyboard
,
"Attempting to match against layout %04x
\n
"
,
main_key_tab
[
current
].
lang
);
syms
=
keysyms_per_keycode
;
match
=
0
;
mismatch
=
0
;
if
(
syms
>
4
)
{
lkey
=
main_key_tab
[
current
].
key
;
WARN
(
keyboard
,
"%d keysyms per keycode not supported, set to 4"
,
syms
);
for
(
keyc
=
min_keycode
;
keyc
<=
max_keycode
;
keyc
++
)
{
syms
=
4
;
/* get data for keycode from X server */
}
for
(
i
=
0
;
i
<
syms
;
i
++
)
{
for
(
current
=
0
;
main_key_tab
[
current
].
lang
;
current
++
)
{
keysym
=
TSXKeycodeToKeysym
(
display
,
keyc
,
i
);
TRACE
(
keyboard
,
"Attempting to match against layout %04x
\n
"
,
if
((
keysym
<
0x100
)
&&
(
keysym
!=
' '
))
ckey
[
i
]
=
keysym
;
main_key_tab
[
current
].
lang
);
else
ckey
[
i
]
=
0
;
match
=
0
;
}
mismatch
=
0
;
if
(
ckey
[
0
])
{
score
=
0
;
/* search for a match in layout table */
lkey
=
main_key_tab
[
current
].
key
;
/* right now, we just find an absolute match for defined positions */
for
(
keyc
=
min_keycode
;
keyc
<=
max_keycode
;
keyc
++
)
{
/* (undefined positions are ignored, so if it's defined as "3#"
/* get data for keycode from X server */
in the table, it's okay that the X server has "3#", for example) */
for
(
i
=
0
;
i
<
syms
;
i
++
)
{
for
(
key
=
0
;
key
<
MAIN_LEN
;
key
++
)
{
keysym
=
TSXKeycodeToKeysym
(
display
,
keyc
,
i
);
for
(
ok
=
(
*
lkey
)[
key
][
i
=
0
];
ok
&&
(
i
<
4
);
i
++
)
/* Allow both one-byte and two-byte national keysyms */
if
((
*
lkey
)[
key
][
i
]
&&
(
*
lkey
)[
key
][
i
]
!=
ckey
[
i
])
ok
=
0
;
if
((
keysym
<
0x800
)
&&
(
keysym
!=
' '
))
if
(
ok
)
break
;
ckey
[
i
]
=
keysym
&
0xFF
;
else
ckey
[
i
]
=
0
;
}
if
(
ckey
[
0
])
{
/* search for a match in layout table */
/* right now, we just find an absolute match for defined positions */
/* (undefined positions are ignored, so if it's defined as "3#" in */
/* the table, it's okay that the X server has "3#", for example) */
/* however, the score will be higher for longer matches */
for
(
key
=
0
;
key
<
MAIN_LEN
;
key
++
)
{
for
(
ok
=
0
,
i
=
0
;
(
ok
>=
0
)
&&
(
i
<
syms
);
i
++
)
{
if
((
*
lkey
)[
key
][
i
]
&&
((
*
lkey
)[
key
][
i
]
==
ckey
[
i
]))
ok
++
;
if
((
*
lkey
)[
key
][
i
]
&&
((
*
lkey
)[
key
][
i
]
!=
ckey
[
i
]))
ok
=
-
1
;
}
}
/* count the matches and mismatches */
if
(
ok
>
0
)
{
if
(
key
<
MAIN_LEN
)
match
++
;
else
{
score
+=
ok
;
TRACE
(
key
,
"mismatch for keycode %d, character %c
\n
"
,
keyc
,
ckey
[
0
]);
break
;
mismatch
++
;
}
}
}
}
}
/* count the matches and mismatches */
/* estimate and check score */
if
(
ok
>
0
)
score
=
match
-
mismatch
;
match
++
;
TRACE
(
keyboard
,
"matches=%d, mismatches=%d, score=%d
\n
"
,
match
,
mismatch
,
score
);
else
{
if
(
score
>
max_score
)
{
TRACE
(
key
,
"mismatch for keycode %d, character %c
\n
"
,
keyc
,
/* best match so far */
ckey
[
0
]);
kbd_layout
=
current
;
mismatch
++
;
max_score
=
score
;
score
-=
syms
;
ismatch
=
!
mismatch
;
}
}
}
}
}
/* we're done, report results if necessary */
TRACE
(
keyboard
,
"matches=%d, mismatches=%d, score=%d
\n
"
,
if
(
!
ismatch
)
{
match
,
mismatch
,
score
);
FIXME
(
keyboard
,
"Your keyboard layout was not found! Using closest match (%04x).
\n
"
,
if
(
score
>
max_score
)
{
main_key_tab
[
kbd_layout
].
lang
);
/* best match so far */
FIXME
(
keyboard
,
"Please define your layout in windows/x11drv/keyboard.c, and submit them
\n
"
)
;
kbd_layout
=
current
;
FIXME
(
keyboard
,
"to us for inclusion into future Wine releases.
\n
"
)
;
max_score
=
score
;
FIXME
(
keyboard
,
"See documentation/keyboard for more information.
\n
"
)
;
ismatch
=
!
mismatch
;
}
}
TRACE
(
keyboard
,
"detected layout is %04x
\n
"
,
main_key_tab
[
kbd_layout
].
lang
);
}
/* we're done, report results if necessary */
if
(
!
ismatch
)
{
FIXME
(
keyboard
,
"Your keyboard layout was not found! Using closest match (%04x).
\n
"
"Please define your layout in windows/x11drv/keyboard.c "
"and submit them
\n
"
"to us for inclusion into future Wine releases.
\n
"
"See documentation/keyboard for more information.
\n
"
,
main_key_tab
[
kbd_layout
].
lang
);
}
TRACE
(
keyboard
,
"detected layout is %04x
\n
"
,
main_key_tab
[
kbd_layout
].
lang
);
}
}
/**********************************************************************
/**********************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment