Invite |
21-02-2003 10:01 78483 |
Вот, в SuSE support database нашел:
Это для консоли:
Цитата:
Situation:
You want to employ a keyboard with special 'Internet' or other additional keys in Linux. Basically, it is a normally connected ordinary PC keyboard with additional keys, i.e. with more than 102 or 105 keys. Nothing seems to happen when you press one of these additional keys. However, you would like to utilize these keys.
Background:
Basically, these keys work like all other keys on the keyboard. However, there is no suitable table that 'translates' these special keys to the desired function. Nevertheless, the Linux kernel uses two such tables. The first one translates the scancode generated by the keyboard to a so-called keycode, which in turn is transformed to the actual keyboard layout by means of an additional, country-specific keymap which can be loaded by the user.
As the special keys generate unknown scancodes, unfortunately you have to change both tables. The step-by-step procedure is described below.
Procedure:
Currently, the procedure described below can only be used for the text console. Due to the special handling of the keyboard by the X server, these settings can't be adopted under X.
Proceed as follows in order to utilize the additional keys in the console.
First of all, find out which special key generates which scancode. You can do this with the help of the command showkey -s. Successively press all special keys (the generated code of which usually begins with 0xe0) and make a note of the code. This is what the result should look like:
erde:~# showkey -s
kb mode was XLATE
press any key (program terminates 10s after last keypress)...
0x9c
0xe0 0x25
0xe0 0xa5
0xe0 0x26
0xe0 0xa6
0xe0 0x32
0xe0 0xb2
In order to terminate the program, simply wait for 10 seconds without pressing any key. In the above-mentioned example, 3 special keys are pressed, and each key generates 2 bytes of code when the key is pressed and another 2 bytes when the key is released. You just need the value that is displayed when the key is pressed. By the way, the first value displayed by the program is the code generated when the Return key is released ...
Accordingly, the following codes can be extracted from the above example:
0xe0 0x25 for the 1. key
0xe0 0x26 for the 2. key
0xe0 0x32 for the 3. key
By means of e.g. a shell script, you can allocate these to so-called keycodes. The keycodes 112-125 are not employed by any other keys and may be allocated freely to special keys. This is done by means of the following commands.
setkeycodes e025 112
setkeycodes e026 113
setkeycodes e032 114
From now on, the kernel will generate the respective keycodes when the special keys are pressed. The respective functions must now be allocated to these keycodes through the second table.
You can do this by means of the keymap that is automatically loaded by one of the start-up scripts in order to set the English (US) keyboard layout when the system is booted. The keymap for the English (US) keyboard can be found under the file name /usr/lib/kbd/keymaps/i386/qwerty/us.map.gz.
To modify the file, unpack it with the command gunzip. Check the manpages for the command loadkeys and the file keymaps for allocating special functions to these keys. In my example, I assign the keys F13 - F15 to these keys and allocate a frequently-used command to a special key. For this purpose, append the following lines to the keymap us.map:
keycode 112 = F13
keycode 113 = F14
keycode 114 = F15
string F13 = "ls\n"
After loading the new keymap with the command
loadkeys us.map
You can invoke the command ls by pressing the first defined special key. In this way, you can freely allocate key functions (listed in the manpage on 'keymaps') or entire character chains to all other keys, which will subsequently be at your disposal on the console.
|
А это для X'ов:
Цитата:
Situation
You want to use the extra keys on your new multimedia keyboard, but you do not know how. These keys do not have any effect out-of-the-box.
Procedure
No actions have been assigned to the keycodes produced by the keys yet. You have to take over this process by way of the program xmodmap. To do this, first save the keyboard layout currently active by using the command:
xmodmap -pke > ~/Xmodmap.save
Now you can use a small tool to find out the keycodes produced by your extra keys. To do this, start the program xev in a terminal program such as xterm or konsole. When you press a key, you will see how xev displays that key's keycode on the terminal. For example, the output for the key A is:
KeyPress event, serial 23, synthetic NO, window 0x2800001,
root 0x62, subw 0x0, time 3131034, (-212,59), root:(276,76),
state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 characters: "a"
As you see, the keycode for the key A is 38. Now you could, for example, edit the file Xmodmap previously saved and assign B to the keycode 38. By doing this, the result of pressing the key A would be B.
The same procedure applies for the extra keys: you can find out their keycode and assign still unused function keys (such as F13) to them. Once this is done, you can move the file Xmodmap to ~/.Xmodmap, where it will be read in everytime the graphical interface starts. Use the following command to test and reread this file:
xmodmap ~/Xmodmap.save
The reaction of your window manager/desktop environment to the new function keys may vary. For example, KDE 3.x enables you to set many different actions in its Control Center -> Look & Feel -> Key Bindings. You can also assign single applications to the new function keys in the KDE Menu Editor, which can be accessed with the right mouse button on the menu button.
An alternative would be using a program only responsible for such functions like, for example, bbkeys. The use of bbkeys, included in the package bbtools in recent versions of SuSE Linux, is actually intended for the window manager blackbox. However, it also works with other window managers/desktop environments. For more information on the configuration of bbkeys, please refer to the web site.
|
|