system/corennnnn
Revisión | 8d3c73afe364179722f6f51a21f0fc8fcd2e10c3 (tree) |
---|---|
Tiempo | 2013-07-25 16:20:08 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
init: builtins: Add 'setkeycode' command to init.rc parser
The command is used to set an entry into the kernel's scancode-to-keycode map.
Change-Id: If772b3590c08d3696ff9d015f1faf0e75405e262
@@ -150,7 +150,7 @@ static int insmod(const char *filename, char *options) | ||
150 | 150 | return ret; |
151 | 151 | } |
152 | 152 | |
153 | -static int setkey(struct kbentry *kbe) | |
153 | +static int kbioctl(int cmd, void *data) | |
154 | 154 | { |
155 | 155 | int fd, ret; |
156 | 156 |
@@ -158,7 +158,7 @@ static int setkey(struct kbentry *kbe) | ||
158 | 158 | if (fd < 0) |
159 | 159 | return -1; |
160 | 160 | |
161 | - ret = ioctl(fd, KDSKBENT, kbe); | |
161 | + ret = ioctl(fd, cmd, data); | |
162 | 162 | |
163 | 163 | close(fd); |
164 | 164 | return ret; |
@@ -571,7 +571,23 @@ int do_setkey(int nargs, char **args) | ||
571 | 571 | kbe.kb_table = strtoul(args[1], 0, 0); |
572 | 572 | kbe.kb_index = strtoul(args[2], 0, 0); |
573 | 573 | kbe.kb_value = strtoul(args[3], 0, 0); |
574 | - return setkey(&kbe); | |
574 | + return kbioctl(KDSKBENT, &kbe); | |
575 | +} | |
576 | + | |
577 | +int do_setkeycode(int nargs, char **args) | |
578 | +{ | |
579 | + struct kbkeycode kbk; | |
580 | + unsigned int sc, kc; | |
581 | + sc = strtoul(args[1], 0, 0); | |
582 | + if (sc >= 0xe000) { | |
583 | + sc -= 0xe000; | |
584 | + sc += 128; | |
585 | + } | |
586 | + kc = strtoul(args[2], 0, 0); | |
587 | + kbk.scancode = sc; | |
588 | + kbk.keycode = kc; | |
589 | + /* sc, kc may be out of range, but we leave the testing to the kernel */ | |
590 | + return kbioctl(KDSETKEYCODE, &kbk); | |
575 | 591 | } |
576 | 592 | |
577 | 593 | int do_setprop(int nargs, char **args) |
@@ -143,6 +143,7 @@ int lookup_keyword(const char *s) | ||
143 | 143 | if (!strcmp(s, "etenforce")) return K_setenforce; |
144 | 144 | if (!strcmp(s, "etenv")) return K_setenv; |
145 | 145 | if (!strcmp(s, "etkey")) return K_setkey; |
146 | + if (!strcmp(s, "etkeycode")) return K_setkeycode; | |
146 | 147 | if (!strcmp(s, "etprop")) return K_setprop; |
147 | 148 | if (!strcmp(s, "etrlimit")) return K_setrlimit; |
148 | 149 | if (!strcmp(s, "etsebool")) return K_setsebool; |
@@ -21,6 +21,7 @@ int do_rmdir(int nargs, char **args); | ||
21 | 21 | int do_setcon(int nargs, char **args); |
22 | 22 | int do_setenforce(int nargs, char **args); |
23 | 23 | int do_setkey(int nargs, char **args); |
24 | +int do_setkeycode(int nargs, char **args); | |
24 | 25 | int do_setprop(int nargs, char **args); |
25 | 26 | int do_setrlimit(int nargs, char **args); |
26 | 27 | int do_setsebool(int nargs, char **args); |
@@ -76,6 +77,7 @@ enum { | ||
76 | 77 | KEYWORD(setenforce, COMMAND, 1, do_setenforce) |
77 | 78 | KEYWORD(setenv, OPTION, 2, 0) |
78 | 79 | KEYWORD(setkey, COMMAND, 0, do_setkey) |
80 | + KEYWORD(setkeycode, COMMAND, 2, do_setkeycode) | |
79 | 81 | KEYWORD(setprop, COMMAND, 2, do_setprop) |
80 | 82 | KEYWORD(setrlimit, COMMAND, 3, do_setrlimit) |
81 | 83 | KEYWORD(setsebool, COMMAND, 2, do_setsebool) |
@@ -207,6 +207,9 @@ setenforce 0|1 | ||
207 | 207 | setkey |
208 | 208 | TBD |
209 | 209 | |
210 | +setkeycode <scancode> <keycode> | |
211 | + Set an entry into the kernel's scancode-to-keycode map. | |
212 | + | |
210 | 213 | setprop <name> <value> |
211 | 214 | Set system property <name> to <value>. |
212 | 215 |