1 // SPDX-License-Identifier: GPL-2.0+
3 * originally written by: Kirk Reiser.
5 ** Copyright (C) 2002 Kirk Reiser.
6 * Copyright (C) 2003 David Borowski.
16 static char buffer
[256];
18 static int get_define(void)
22 while (fgets(buffer
, sizeof(buffer
)-1, infile
)) {
24 if (strncmp(buffer
, "#define", 7))
27 while (*c
== ' ' || *c
== '\t')
30 while (*c
&& *c
!= ' ' && *c
!= '\t' && *c
!= '\n')
32 if (!*c
|| *c
== '\n')
35 while (*c
== ' ' || *c
== '\t' || *c
== '(')
38 while (*c
&& *c
!= '\n' && *c
!= ')')
49 main(int argc
, char *argv
[])
53 const char *dir_name
, *spk_dir_name
;
56 dir_name
= getenv("TOPDIR");
59 spk_dir_name
= getenv("SPKDIR");
61 spk_dir_name
= "drivers/accessibility/speakup";
62 bzero(key_table
, sizeof(key_table
));
63 add_key("shift", 1, is_shift
);
64 add_key("altgr", 2, is_shift
);
65 add_key("ctrl", 4, is_shift
);
66 add_key("alt", 8, is_shift
);
67 add_key("spk", 16, is_shift
);
68 add_key("double", 32, is_shift
);
70 open_input(dir_name
, "include/linux/input.h");
71 while (get_define()) {
72 if (strncmp(def_name
, "KEY_", 4))
74 value
= atoi(def_val
);
75 if (value
> 0 && value
< MAXKEYVAL
)
76 add_key(def_name
, value
, is_input
);
79 open_input(dir_name
, "include/uapi/linux/input-event-codes.h");
80 while (get_define()) {
81 if (strncmp(def_name
, "KEY_", 4))
83 value
= atoi(def_val
);
84 if (value
> 0 && value
< MAXKEYVAL
)
85 add_key(def_name
, value
, is_input
);
88 open_input(spk_dir_name
, "spk_priv_keyinfo.h");
89 while (get_define()) {
90 if (strlen(def_val
) > 5) {
91 //if (def_val[0] == '(')
93 cp
= strchr(def_val
, '+');
99 this = find_key(def_val
);
102 if (!this || *cp
< '0' || *cp
> '9')
104 value
= this->value
+atoi(cp
);
105 } else if (!strncmp(def_val
, "0x", 2))
106 sscanf(def_val
+2, "%x", &value
);
107 else if (*def_val
>= '0' && *def_val
<= '9')
108 value
= atoi(def_val
);
111 add_key(def_name
, value
, is_spk
);
114 printf("struct st_key_init init_key_data[] = {\n");
115 for (i
= 0; i
< HASHSIZE
; i
++) {
116 this = &key_table
[i
];
120 printf("\t{ \"%s\", %d, %d, },\n", this->name
, this->value
, this->shift
);
124 printf("\t{ \".\", 0, 0 }\n};\n");