1 /* loadkeys - load national keyboard map Author: Marcus Hampel
5 #include <minix/keymap.h>
13 #define KBD_DEVICE "/dev/kbd"
15 #define KBD_DEVICE "/dev/console"
18 u16_t keymap
[NR_SCAN_CODES
* MAP_COLS
];
19 u8_t comprmap
[4 + NR_SCAN_CODES
* MAP_COLS
* 9/8 * 2 + 1];
24 write(2, s
, strlen(s
));
44 tell("Usage: loadkeys mapfile\n");
49 int main(int argc
, char *argv
[])
58 if ((fd
= open(argv
[1], O_RDONLY
)) < 0) fatal(argv
[1]);
60 if (read(fd
, comprmap
, sizeof(comprmap
)) < 0) fatal(argv
[1]);
62 if (memcmp(comprmap
, KEY_MAGIC
, 4) != 0) {
65 tell(": not a keymap file\n");
70 /* Decompress the keymap data. */
73 for (km
= keymap
; km
< keymap
+ NR_SCAN_CODES
* MAP_COLS
; km
++) {
75 /* Need a new flag byte. */
79 *km
= *cm
++; /* Low byte. */
81 *km
|= (*cm
++ << 8); /* One of the few special keys. */
86 if ((fd
= open(KBD_DEVICE
, O_WRONLY
)) < 0) fatal(KBD_DEVICE
);
88 if (ioctl(fd
, KIOCSMAP
, keymap
) < 0) fatal(KBD_DEVICE
);