blob: 91c03055b5317a45c0fb97b5b90998b09d5b9ad5 [file] [log] [blame]
Ove Kaaven272be7b1999-03-15 15:24:56 +00001Wine now needs to know about your keyboard layout. This requirement comes from
2a need from many apps to have the correct scancodes available, since they read
3these directly, instead of just taking the characters returned by the X server.
4This means that Wine now needs to have a mapping from X keys to the scancodes
5these applications expect.
6
7On startup, Wine will try to recognize the active X layout by seeing if it
8matches any of the defined tables. If it does, everything is allright. If not,
9you need to define it.
10
11To do this, open the file windows/x11drv/keyboard.c and take a look at the
12existing tables. Make a backup copy of it, especially if you don't use CVS.
13
14What you really would need to do, is to find out which scancode each key needs
15to generate, find it in the main_key_scan table, which looks like this
16
17static const int main_key_scan[MAIN_LEN] =
18{
19/* this is my (102-key) keyboard layout, sorry if it doesn't quite match yours */
20 0x29,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,
21 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,
22 0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2B,
23 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
24 0x56 /* the 102nd key (actually to the right of l-shift) */
25};
26
27and then assign each scancode the characters imprinted on the keycaps. This
28was done (sort of) for the US 101-key keyboard, which you can find near the
29top in keyboard.c. It also shows that if there is no 102nd key, you can skip
30that.
31
32However, for most international 102-key keyboards, we have done it easy for you.
33The scancode layout for these already pretty much matches the physical layout
34in the main_key_scan, so all you need to do is to go through all the keys that
35generate characters on your main keyboard (except spacebar), and stuff those
36into an appropriate table. The only exception is that the 102nd key, which is
37usually to the left of the first key of the last line (usually Z), must be
38placed on a separate line after the last line.
39
40For example, my Norwegian keyboard looks like this
41
42§ ! " # ¤ % & / ( ) = ? ` Back-
43| 1 2@ 3£ 4$ 5 6 7{ 8[ 9] 0} + \´ space
44
45Tab Q W E R T Y U I O P Å ^
46 ¨~
47 Enter
48Caps A S D F G H J K L Ø Æ *
49Lock '
50
51Sh- > Z X C V B N M ; : _ Shift
52ift < , . -
53
54Ctrl Alt Spacebar AltGr Ctrl
55
56
57Note the 102nd key, which is the "<>" key, to the left of Z. The character
58to the right of the main character is the character generated by AltGr.
59
60This keyboard is defined as follows:
61
62static const char main_key_NO[MAIN_LEN][4] =
63{
64 "","1!","2\"@","3#£","4¤$","5%","6&","7/{","8([","9)]","0=}","+?","\\´",
65 "qQ","wW","eE","rR","tT","yY","uU","iI","oO","pP","åÅ","¨^~",
66 "aA","sS","dD","fF","gG","hH","jJ","kK","lL","øØ","æÆ","'*",
67 "zZ","xX","cC","vV","bB","nN","mM",",;",".:","-_",
68 "<>"
69};
70
71Except that " and \ needs to be quoted with a backslash, and that the 102nd
72key is on a separate line, it's pretty straightforward.
73
74After you have written such a table, you need to add it to the main_key_tab[]
75layout index table. This will look like this:
76
77static struct {
78 WORD lang, ansi_codepage, oem_codepage;
79 const char (*key)[MAIN_LEN][4];
80} main_key_tab[]={
81...
82...
83 {MAKELANGID(LANG_NORWEGIAN,SUBLANG_DEFAULT), 1252, 865, &main_key_NO},
84...
85
86After you have added your table, recompile Wine and test that it works.
Ove Kaaven83827c11999-04-15 16:44:34 +000087If it fails to detect your table, try running
88
89wine -debugmsg +key,+keyboard >& key.log
90
91and look in the resulting key.log file to find the error messages it
92gives for your layout.
Ove Kaaven272be7b1999-03-15 15:24:56 +000093
94Note that the LANG_* and SUBLANG_* definitions are in include/winnls.h,
95which you might need to know to find out which numbers your language
Ove Kaaven83827c11999-04-15 16:44:34 +000096is assigned, and find it in the debugmsg output. The numbers will
97be SUBLANG * 0x400 + LANG, so, for example the combination
98LANG_NORWEGIAN (0x14) and SUBLANG_DEFAULT (0x1) will be (in hex)
9914 + 1*400 = 414, so since I'm Norwegian, I could look for 0414 in
100the debugmsg output to find out why my keyboard won't detect.
Ove Kaaven272be7b1999-03-15 15:24:56 +0000101
102Once it works, submit it to the Wine project. If you use CVS, you
103will just have to do
104
Ove Kaaven83827c11999-04-15 16:44:34 +0000105cvs -z3 diff -u windows/x11drv/keyboard.c > layout.diff
Ove Kaaven272be7b1999-03-15 15:24:56 +0000106
107from your main Wine directory, then submit layout.diff to
108wine-patches@winehq.com along with a brief note of what it is.
109
110If you don't use CVS, you need to do
111
112diff -u the_backup_file_you_made windows/x11drv/keyboard.c > layout.diff
113
114and submit it as explained above.
115
116If you did it right, it will be included in the next Wine release, and all
117the troublesome applications (especially remote-control applications) and
118games that use scancodes will be happily using your keyboard layout, and you
119won't get those annoying fixme messages either.
120
121Good luck.
122
123-Ove Kåven <ovek@arcticnet.no>