3 * This file is part of kbd project.
4 * Copyright (C) 2012-2013 Alexey Gladkov <gladkov.alexey@gmail.com>
6 * This file is covered by the GNU General Public License,
7 * which should be included with kbd as the file COPYING.
12 #include <sys/ioctl.h>
18 lk_kernel_keys(struct keymap *kmap, int fd)
23 for (t = 0; t < MAX_NR_KEYMAPS; t++) {
24 for (i = 0; i < NR_KEYS; i++) {
29 if (ioctl(fd, KDGKBENT, (unsigned long) &ke)) {
30 ERR(kmap, _("KDGKBENT: %s: error at index %d in table %d"),
31 strerror(errno), i, t);
35 if (lk_add_key(kmap, i, t, ke.kb_value) < 0)
40 if (lk_add_constants(kmap) < 0)
47 lk_kernel_funcs(struct keymap *kmap, int fd)
52 for (i = 0; i < MAX_NR_FUNC; i++) {
55 if (ioctl(fd, KDGKBSENT, (unsigned long) &kbs)) {
56 ERR(kmap, _("KDGKBSENT: %s: Unable to get function key string"),
61 if (!strlen((char *) kbs.kb_string))
64 if (lk_add_func(kmap, kbs) < 0)
72 lk_kernel_diacrs(struct keymap *kmap, int fd)
75 int request = KDGKBDIACRUC;
77 struct kbdiacruc *ar = kd.kbdiacruc;
79 int request = KDGKBDIACR;
81 struct kbdiacr *ar = kd.kbdiacr;
85 if (ioctl(fd, request, (unsigned long) &kd)) {
86 ERR(kmap, _("KDGKBDIACR(UC): %s: Unable to get accent table"),
91 for (i = 0; i < kd.kb_cnt; i++) {
92 if (lk_add_diacr(kmap, (ar+i)->diacr, (ar+i)->base, (ar+i)->result) < 0)
100 lk_kernel_keymap(struct keymap *kmap, int fd)
102 if (lk_kernel_keys(kmap, fd) < 0 ||
103 lk_kernel_funcs(kmap, fd) < 0 ||
104 lk_kernel_diacrs(kmap, fd) < 0)