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>
18 #include "modifiers.h"
22 valid_type(int fd, int t)
28 ke.kb_value = K(t, 0);
30 return (ioctl(fd, KDSKBENT, (unsigned long) &ke) == 0);
34 maximum_val(int fd, int t)
36 struct kbentry ke, ke0;
44 ioctl(fd, KDGKBENT, (unsigned long) &ke0);
46 for (i = 0; i < 256; i++) {
47 ke.kb_value = K(t, i);
48 if (ioctl(fd, KDSKBENT, (unsigned long) &ke))
52 ioctl(fd, KDSKBENT, (unsigned long) &ke0);
58 lk_get_kmapinfo(struct lk_ctx *ctx, struct kmapinfo *res)
65 res->flags = ctx->flags;
66 res->keywords = ctx->keywords;
67 res->keymaps = ctx->keymap->count;
68 res->functions = ctx->func_table->count;
69 res->composes = ctx->accent_table->count;
71 res->keymaps_alloced = 0;
73 for (i = 0; i < MAX_NR_KEYMAPS; i++) {
74 if (lk_get_key(ctx, i, 0) == K_ALLOCATED) {
75 res->keymaps_alloced++;
85 lk_dump_summary(struct lk_ctx *ctx, FILE *fd, int console)
90 if (lk_get_kmapinfo(ctx, &info) < 0)
93 fprintf(fd, _("keycode range supported by kernel: 1 - %d\n"),
95 fprintf(fd, _("max number of actions bindable to a key: %d\n"),
97 fprintf(fd, _("number of keymaps in actual use: %u\n"),
98 (unsigned int) info.keymaps);
100 fprintf(fd, _("of which %u dynamically allocated\n"),
101 (unsigned int) info.keymaps_alloced);
103 fprintf(fd, _("ranges of action codes supported by kernel:\n"));
105 for (i = 0; i < NR_TYPES && valid_type(console, i); i++)
106 fprintf(fd, " 0x%04x - 0x%04x\n",
107 K(i, 0), K(i, maximum_val(console, i)));
109 fprintf(fd, _("number of function keys supported by kernel: %d\n"),
111 fprintf(fd, _("max nr of compose definitions: %d\n"),
113 fprintf(fd, _("nr of compose definitions in actual use: %u\n"),
114 (unsigned int) info.composes);
118 lk_dump_symbols(FILE *fd)
125 for (t = 0; t < syms_size; t++) {
127 for (v = 0; v < syms[t].size; v++) {
128 if ((p = syms[t].table[v])[0])
129 fprintf(fd, "0x%04x\t%s\n", K(t, v), p);
131 } else if (t == KT_META) {
132 for (v = 0; v < syms[0].size && v < 128; v++) {
133 if ((p = syms[0].table[v])[0])
134 fprintf(fd, "0x%04x\tMeta_%s\n", K(t, v), p);
139 fprintf(fd, _("\nThe following synonyms are recognized:\n\n"));
141 for (t = 0; t < syn_size; t++) {
142 fprintf(fd, _("%-15s for %s\n"),
143 synonyms[t].synonym, synonyms[t].official_name);
146 fprintf(fd, _("\nRecognized modifier names and their column numbers:\n"));
148 mod = (modifier_t *) modifiers;
150 fprintf(fd, "%s\t\t%3d\n", mod->name, 1 << mod->bit);