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.
11 #include <sys/ioctl.h>
19 lk_kernel_keys(struct lk_ctx *ctx, int fd)
24 for (t = 0; t < MAX_NR_KEYMAPS; t++) {
25 for (i = 0; i < NR_KEYS; i++) {
30 if (ioctl(fd, KDGKBENT, (unsigned long) &ke)) {
31 ERR(ctx, _("KDGKBENT: %s: error at index %d in table %d"),
32 strerror(errno), i, t);
36 if (lk_add_key(ctx, t, i, ke.kb_value) < 0)
41 if (lk_add_constants(ctx) < 0)
48 lk_kernel_funcs(struct lk_ctx *ctx, int fd)
53 for (i = 0; i < MAX_NR_FUNC; i++) {
56 if (ioctl(fd, KDGKBSENT, (unsigned long) &kbs)) {
57 ERR(ctx, _("KDGKBSENT: %s: Unable to get function key string"),
62 if (!strlen((char *) kbs.kb_string))
65 if (lk_add_func(ctx, kbs) < 0)
73 lk_kernel_diacrs(struct lk_ctx *ctx, int fd)
76 int request = KDGKBDIACRUC;
78 struct kbdiacruc *ar = kd.kbdiacruc;
80 int request = KDGKBDIACR;
82 struct kbdiacr *ar = kd.kbdiacr;
85 struct lk_kbdiacr dcr;
87 if (ioctl(fd, request, (unsigned long) &kd)) {
88 ERR(ctx, _("KDGKBDIACR(UC): %s: Unable to get accent table"),
93 for (i = 0; i < kd.kb_cnt; i++) {
94 dcr.diacr = (ar+i)->diacr;
95 dcr.base = (ar+i)->base;
96 dcr.result = (ar+i)->result;
98 if (lk_add_diacr(ctx, i, &dcr) < 0)
106 lk_kernel_keymap(struct lk_ctx *ctx, int fd)
108 if (lk_kernel_keys(ctx, fd) < 0 ||
109 lk_kernel_funcs(ctx, fd) < 0 ||
110 lk_kernel_diacrs(ctx, fd) < 0)