• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisión8d3c73afe364179722f6f51a21f0fc8fcd2e10c3 (tree)
Tiempo2013-07-25 16:20:08
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

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

Cambiar Resumen

Diferencia incremental

--- a/init/builtins.c
+++ b/init/builtins.c
@@ -150,7 +150,7 @@ static int insmod(const char *filename, char *options)
150150 return ret;
151151 }
152152
153-static int setkey(struct kbentry *kbe)
153+static int kbioctl(int cmd, void *data)
154154 {
155155 int fd, ret;
156156
@@ -158,7 +158,7 @@ static int setkey(struct kbentry *kbe)
158158 if (fd < 0)
159159 return -1;
160160
161- ret = ioctl(fd, KDSKBENT, kbe);
161+ ret = ioctl(fd, cmd, data);
162162
163163 close(fd);
164164 return ret;
@@ -571,7 +571,23 @@ int do_setkey(int nargs, char **args)
571571 kbe.kb_table = strtoul(args[1], 0, 0);
572572 kbe.kb_index = strtoul(args[2], 0, 0);
573573 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);
575591 }
576592
577593 int do_setprop(int nargs, char **args)
--- a/init/init_parser.c
+++ b/init/init_parser.c
@@ -143,6 +143,7 @@ int lookup_keyword(const char *s)
143143 if (!strcmp(s, "etenforce")) return K_setenforce;
144144 if (!strcmp(s, "etenv")) return K_setenv;
145145 if (!strcmp(s, "etkey")) return K_setkey;
146+ if (!strcmp(s, "etkeycode")) return K_setkeycode;
146147 if (!strcmp(s, "etprop")) return K_setprop;
147148 if (!strcmp(s, "etrlimit")) return K_setrlimit;
148149 if (!strcmp(s, "etsebool")) return K_setsebool;
--- a/init/keywords.h
+++ b/init/keywords.h
@@ -21,6 +21,7 @@ int do_rmdir(int nargs, char **args);
2121 int do_setcon(int nargs, char **args);
2222 int do_setenforce(int nargs, char **args);
2323 int do_setkey(int nargs, char **args);
24+int do_setkeycode(int nargs, char **args);
2425 int do_setprop(int nargs, char **args);
2526 int do_setrlimit(int nargs, char **args);
2627 int do_setsebool(int nargs, char **args);
@@ -76,6 +77,7 @@ enum {
7677 KEYWORD(setenforce, COMMAND, 1, do_setenforce)
7778 KEYWORD(setenv, OPTION, 2, 0)
7879 KEYWORD(setkey, COMMAND, 0, do_setkey)
80+ KEYWORD(setkeycode, COMMAND, 2, do_setkeycode)
7981 KEYWORD(setprop, COMMAND, 2, do_setprop)
8082 KEYWORD(setrlimit, COMMAND, 3, do_setrlimit)
8183 KEYWORD(setsebool, COMMAND, 2, do_setsebool)
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -207,6 +207,9 @@ setenforce 0|1
207207 setkey
208208 TBD
209209
210+setkeycode <scancode> <keycode>
211+ Set an entry into the kernel's scancode-to-keycode map.
212+
210213 setprop <name> <value>
211214 Set system property <name> to <value>.
212215