Ove Kaaven | 272be7b | 1999-03-15 15:24:56 +0000 | [diff] [blame] | 1 | Wine now needs to know about your keyboard layout. This requirement comes from |
| 2 | a need from many apps to have the correct scancodes available, since they read |
| 3 | these directly, instead of just taking the characters returned by the X server. |
| 4 | This means that Wine now needs to have a mapping from X keys to the scancodes |
| 5 | these applications expect. |
| 6 | |
| 7 | On startup, Wine will try to recognize the active X layout by seeing if it |
| 8 | matches any of the defined tables. If it does, everything is allright. If not, |
| 9 | you need to define it. |
| 10 | |
| 11 | To do this, open the file windows/x11drv/keyboard.c and take a look at the |
| 12 | existing tables. Make a backup copy of it, especially if you don't use CVS. |
| 13 | |
| 14 | What you really would need to do, is to find out which scancode each key needs |
| 15 | to generate, find it in the main_key_scan table, which looks like this |
| 16 | |
| 17 | static 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 | |
| 27 | and then assign each scancode the characters imprinted on the keycaps. This |
| 28 | was done (sort of) for the US 101-key keyboard, which you can find near the |
| 29 | top in keyboard.c. It also shows that if there is no 102nd key, you can skip |
| 30 | that. |
| 31 | |
| 32 | However, for most international 102-key keyboards, we have done it easy for you. |
| 33 | The scancode layout for these already pretty much matches the physical layout |
| 34 | in the main_key_scan, so all you need to do is to go through all the keys that |
| 35 | generate characters on your main keyboard (except spacebar), and stuff those |
| 36 | into an appropriate table. The only exception is that the 102nd key, which is |
| 37 | usually to the left of the first key of the last line (usually Z), must be |
| 38 | placed on a separate line after the last line. |
| 39 | |
| 40 | For example, my Norwegian keyboard looks like this |
| 41 | |
| 42 | § ! " # ¤ % & / ( ) = ? ` Back- |
| 43 | | 1 2@ 3£ 4$ 5 6 7{ 8[ 9] 0} + \´ space |
| 44 | |
| 45 | Tab Q W E R T Y U I O P Å ^ |
| 46 | ¨~ |
| 47 | Enter |
| 48 | Caps A S D F G H J K L Ø Æ * |
| 49 | Lock ' |
| 50 | |
| 51 | Sh- > Z X C V B N M ; : _ Shift |
| 52 | ift < , . - |
| 53 | |
| 54 | Ctrl Alt Spacebar AltGr Ctrl |
| 55 | |
| 56 | |
| 57 | Note the 102nd key, which is the "<>" key, to the left of Z. The character |
| 58 | to the right of the main character is the character generated by AltGr. |
| 59 | |
| 60 | This keyboard is defined as follows: |
| 61 | |
| 62 | static 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 | |
| 71 | Except that " and \ needs to be quoted with a backslash, and that the 102nd |
| 72 | key is on a separate line, it's pretty straightforward. |
| 73 | |
| 74 | After you have written such a table, you need to add it to the main_key_tab[] |
| 75 | layout index table. This will look like this: |
| 76 | |
| 77 | static 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 | |
| 86 | After you have added your table, recompile Wine and test that it works. |
Ove Kaaven | 83827c1 | 1999-04-15 16:44:34 +0000 | [diff] [blame] | 87 | If it fails to detect your table, try running |
| 88 | |
| 89 | wine -debugmsg +key,+keyboard >& key.log |
| 90 | |
| 91 | and look in the resulting key.log file to find the error messages it |
| 92 | gives for your layout. |
Ove Kaaven | 272be7b | 1999-03-15 15:24:56 +0000 | [diff] [blame] | 93 | |
| 94 | Note that the LANG_* and SUBLANG_* definitions are in include/winnls.h, |
| 95 | which you might need to know to find out which numbers your language |
Ove Kaaven | 83827c1 | 1999-04-15 16:44:34 +0000 | [diff] [blame] | 96 | is assigned, and find it in the debugmsg output. The numbers will |
| 97 | be SUBLANG * 0x400 + LANG, so, for example the combination |
| 98 | LANG_NORWEGIAN (0x14) and SUBLANG_DEFAULT (0x1) will be (in hex) |
| 99 | 14 + 1*400 = 414, so since I'm Norwegian, I could look for 0414 in |
| 100 | the debugmsg output to find out why my keyboard won't detect. |
Ove Kaaven | 272be7b | 1999-03-15 15:24:56 +0000 | [diff] [blame] | 101 | |
| 102 | Once it works, submit it to the Wine project. If you use CVS, you |
| 103 | will just have to do |
| 104 | |
Ove Kaaven | 83827c1 | 1999-04-15 16:44:34 +0000 | [diff] [blame] | 105 | cvs -z3 diff -u windows/x11drv/keyboard.c > layout.diff |
Ove Kaaven | 272be7b | 1999-03-15 15:24:56 +0000 | [diff] [blame] | 106 | |
| 107 | from your main Wine directory, then submit layout.diff to |
| 108 | wine-patches@winehq.com along with a brief note of what it is. |
| 109 | |
| 110 | If you don't use CVS, you need to do |
| 111 | |
| 112 | diff -u the_backup_file_you_made windows/x11drv/keyboard.c > layout.diff |
| 113 | |
| 114 | and submit it as explained above. |
| 115 | |
| 116 | If you did it right, it will be included in the next Wine release, and all |
| 117 | the troublesome applications (especially remote-control applications) and |
| 118 | games that use scancodes will be happily using your keyboard layout, and you |
| 119 | won't get those annoying fixme messages either. |
| 120 | |
| 121 | Good luck. |
| 122 | |
| 123 | -Ove Kåven <ovek@arcticnet.no> |