aboutsummaryrefslogtreecommitdiffstats
path: root/util/av7110_loadkeys/av7110_loadkeys.c
diff options
context:
space:
mode:
authoretobi <git@e-tobi.net>2013-09-03 09:48:41 +0200
committeretobi <git@e-tobi.net>2013-09-03 09:48:41 +0200
commitab959d7b4194715870128e616b8e29d4a101e488 (patch)
tree61a746231d30817be73416a7d67763fd677a1042 /util/av7110_loadkeys/av7110_loadkeys.c
parent6b350466c4902c5b137e0efaf1d189128a7f18f5 (diff)
downloadlinux-dvb-apps-ab959d7b4194715870128e616b8e29d4a101e488.tar.gz
Imported Upstream version 1.1.1+rev1207upstream/1.1.1+rev1207
Diffstat (limited to 'util/av7110_loadkeys/av7110_loadkeys.c')
-rw-r--r--util/av7110_loadkeys/av7110_loadkeys.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/util/av7110_loadkeys/av7110_loadkeys.c b/util/av7110_loadkeys/av7110_loadkeys.c
index e9eeea0..793862f 100644
--- a/util/av7110_loadkeys/av7110_loadkeys.c
+++ b/util/av7110_loadkeys/av7110_loadkeys.c
@@ -33,9 +33,10 @@ void print_error (const char *action, const char *file)
static
int parse_keyname (char *pos, char **nend, int limit)
{
- int cmp, index;
+ int cmp, _index;
int l = 1;
- int r = sizeof (key_name) / sizeof (key_name[0]);
+ const struct input_key_name *kn;
+ int r;
if (limit < 5)
return -1;
@@ -46,7 +47,18 @@ int parse_keyname (char *pos, char **nend, int limit)
limit--;
}
- if (pos [0] != 'K' || pos[1] != 'E' || pos[2] != 'Y' || pos[3] != '_')
+ if (pos[3] != '_')
+ return -2;
+
+ if (pos[0] == 'K' && pos[1] == 'E' && pos[2] == 'Y') {
+ kn = key_name;
+ r = sizeof (key_name) / sizeof (key_name[0]);
+ }
+ else if (pos[0] == 'B' && pos[1] == 'T' && pos[2] == 'N') {
+ kn = btn_name;
+ r = sizeof (btn_name) / sizeof (btn_name[0]);
+ }
+ else
return -2;
(*nend) += 4;
@@ -56,21 +68,21 @@ int parse_keyname (char *pos, char **nend, int limit)
while (r >= l) {
int len0, len1 = 0;
- index = (l + r) / 2;
-
- len0 = strlen(key_name[index-1].name);
+ _index = (l + r) / 2;
+
+ len0 = strlen(kn[_index-1].name);
while (len1 < limit && isgraph(pos[len1]))
len1++;
- cmp = strncmp (key_name[index-1].name, pos,
- strlen(key_name[index-1].name));
-
+ cmp = strncmp (kn[_index-1].name, pos,
+ strlen(kn[_index-1].name));
+
if (len0 < len1 && cmp == 0)
cmp = -1;
if (cmp == 0) {
- *nend = pos + strlen (key_name[index-1].name);
+ *nend = pos + strlen (kn[_index-1].name);
if (**nend != '\n' &&
**nend != '\t' &&
@@ -78,13 +90,13 @@ int parse_keyname (char *pos, char **nend, int limit)
*nend != pos)
return -3;
- return key_name[index-1].key;
+ return kn[_index-1].key;
}
if (cmp < 0)
- l = index + 1;
+ l = _index + 1;
else
- r = index - 1;
+ r = _index - 1;
if (r < l) {
static const char msg [] = "\nunknown key '";
@@ -151,18 +163,18 @@ int main (int argc, char **argv)
while (pos < buf + len) {
int key, keycode;
-
+
while (!isxdigit(*pos) && pos < buf + len)
pos++;
if (pos == buf + len)
break;
-
+
key = strtol (pos, &pos, 0);
keycode = parse_keyname (pos, &pos, buf + len - pos);
if (key < 0 || key > 0xff) {
- const char msg [] =
+ const char msg [] =
"\nERROR: key must be in range 0 ... 0xff!\n\n";
write (0, msg, strlen(msg));
@@ -174,7 +186,7 @@ int main (int argc, char **argv)
setup.keytab[key] = keycode;
}
-
+
munmap (buf, len);
close (fd);
@@ -182,5 +194,3 @@ int main (int argc, char **argv)
return 0;
}
-
-