| 1 |
xkeymap - X Window System keyboard mapping utility for Allegro |
| 2 |
|
| 3 |
by Michael Bukin, modified by Elias Pschernig |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
0. Quickstart |
| 8 |
|
| 9 |
- Make sure you have an appropriate "keyboard=" entry in your |
| 10 |
allegro.cfg. |
| 11 |
|
| 12 |
- Run xkeymap, and click on the "Setup key mappings" button. |
| 13 |
|
| 14 |
- Select Allegro scancodes from the list, and hit corresponding keys |
| 15 |
on your keyboard. |
| 16 |
|
| 17 |
- "Save and exit", and paste the generated file xkeymap.cfg into your |
| 18 |
allegro.cfg. |
| 19 |
|
| 20 |
- If Allegro's keyboard mapping is still broken, reading on probably |
| 21 |
won't help - in this case you can write to the mailing lists or the |
| 22 |
web forum on allegro.cc. |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
1. Why it is needed |
| 27 |
|
| 28 |
To achieve maximum portability, Allegro does its own key-mapping, |
| 29 |
directly reading in raw scancodes from the keyboard. While on some |
| 30 |
platforms, like DOS, Windows or QNX, it is possible to directly read |
| 31 |
in these scancodes, on other platforms, like X, this is not possible. |
| 32 |
In X, Allegro can only read in virtual keycodes produced by X, which |
| 33 |
already depend on the keyboard layout specifications. Because of that, |
| 34 |
you have to provide a keyboard configuration which maps the X virtual |
| 35 |
keycodes back to the raw scancodes. This utility makes it easy to |
| 36 |
create the right configuration, by giving you a selection of Allegro |
| 37 |
keycodes and asking you to press the corresponding key on your |
| 38 |
keyboard, so the X virtual keycode can be detected. |
| 39 |
|
| 40 |
Note that X may completely block some keys which, therefore, can't be |
| 41 |
detected at all by user programs. (For me, this is the case for the |
| 42 |
left control key and the menu key.) |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
2. How to use it |
| 47 |
|
| 48 |
Make sure your standard allegro.cfg (either ./allegro.cfg, |
| 49 |
~/allegro.cfg, ~/.allegrorc, /etc/allegro.cfg, or /etc/allegrorc) |
| 50 |
contains the right "keyboard=" line for your keyboard layout, for |
| 51 |
example "keyboard=es" for a Spanish layout - before running the |
| 52 |
program. Alternatively, you can click on the button labelled "Default" |
| 53 |
to directly load a keyboard layout file. Some layouts ship with |
| 54 |
Allegro and can be found in the "resources/keyboard" folder. Or you |
| 55 |
can create your own with the keyconf utility. |
| 56 |
|
| 57 |
Now click on the "Setup key mappings" button. It shows you a list |
| 58 |
containing all Allegro keycodes. Select any keycode with the mouse or |
| 59 |
cursor keys, and hit return (or double-click, or click the button |
| 60 |
below it). Then press the key on your keyboard whose X code should be |
| 61 |
seen by Allegro as the selected key. Normally, you want to ignore the |
| 62 |
"KEY_" name of the key, and only look at the letters displayed below |
| 63 |
the "Produces:" button, which tell what characters are produced when |
| 64 |
hitting the key, or Shift+key or AltGr+key combinations. For example, |
| 65 |
if you have "keyboard=de" in your allegro.cfg, the key KEY_Y will show |
| 66 |
"z Z", and you should press the key labelled 'Z' on your keyboard, not |
| 67 |
'Y'. The "Done" button takes you back to the main menu, where you can |
| 68 |
test the current mapping with the "Test key mappings" button. |
| 69 |
|
| 70 |
Use "Save and exit" to write the X mappings into a file called |
| 71 |
"xkeymap.cfg", the contents of which you should paste into your |
| 72 |
allegro.cfg. |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
3. Example from my current system |
| 77 |
|
| 78 |
I'm using a Debian-Linux-i386 version with XFree86 4.2.1 and a PC |
| 79 |
keyboard, and the following standard keyboard layout is specified in |
| 80 |
/etc/X11/XF86Config (for a german keyboard layout): |
| 81 |
|
| 82 |
Section "InputDevice" |
| 83 |
Identifier "Keyboard0" |
| 84 |
Driver "keyboard" |
| 85 |
Option "XkbKeycodes" "xfree86" |
| 86 |
Option "XkbTypes" "default" |
| 87 |
Option "XkbCompat" "default" |
| 88 |
Option "XkbSymbols" "en_US(pc105)+de" |
| 89 |
Option "XkbGeometry" "pc(pc105)" |
| 90 |
EndSection |
| 91 |
|
| 92 |
My allegro.cfg is in /etc/allegro.cfg, and contains this: |
| 93 |
|
| 94 |
[system] |
| 95 |
keyboard = de |
| 96 |
language = de |
| 97 |
|
| 98 |
Using the xkeymap utility, and typing in all keys which were not |
| 99 |
working before, produced the following xkeymap.cfg for me. I just |
| 100 |
pasted it at the beginning of my /etc/allegro.cfg - and now have |
| 101 |
a 100% working keyboard in Allegro programs :) |
| 102 |
|
| 103 |
[xkeymap] |
| 104 |
keycode20 = 12 |
| 105 |
keycode21 = 13 |
| 106 |
keycode29 = 21 |
| 107 |
keycode34 = 26 |
| 108 |
keycode35 = 27 |
| 109 |
keycode47 = 39 |
| 110 |
keycode48 = 40 |
| 111 |
keycode49 = 41 |
| 112 |
keycode51 = 43 |
| 113 |
keycode52 = 44 |
| 114 |
keycode59 = 51 |
| 115 |
keycode60 = 52 |
| 116 |
keycode61 = 53 |
| 117 |
keycode64 = 56 |
| 118 |
keycode94 = 214 |
| 119 |
keycode113 = 184 |
| 120 |
keycode115 = 219 |
| 121 |
keycode116 = 220 |