aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Manna <kyle.manna@fuel7.com>2012-08-08 19:22:29 -0500
committerGerd Hoffmann <kraxel@redhat.com>2014-04-10 12:38:05 +0200
commit5ada44665cc8d54a0d29570bcf5d383e3feaa4d2 (patch)
tree2b6e0d1f09b737540a009b239992c7795d07c34c
parent8986aca6ff02ad7e32f4e6410858ff192beb2df0 (diff)
downloadinput-5ada44665cc8d54a0d29570bcf5d383e3feaa4d2.tar.gz
input-kbd: Remove check that breaks sparse keymaps
With sparse keymaps the scancode is commonly greater then the map size. Remove this check, and use the maps count of keys to keep track of things. Signed-off-by: Kyle Manna <kyle.manna@fuel7.com>
-rw-r--r--input-kbd.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/input-kbd.c b/input-kbd.c
index 09d6022..3f0be52 100644
--- a/input-kbd.c
+++ b/input-kbd.c
@@ -127,8 +127,9 @@ static int kbd_map_parse(FILE *fp, struct kbd_map *map)
struct kbd_entry entry;
char line[80],scancode[80],keycode[80];
int i;
+ int idx = 0;
- while (NULL != fgets(line,sizeof(line),fp)) {
+ while ((NULL != fgets(line,sizeof(line),fp)) && (idx < map->keys)) {
if (2 != sscanf(line," %80s = %80s", scancode, keycode)) {
fprintf(stderr,"parse error: %s",line);
return -1;
@@ -140,10 +141,10 @@ static int kbd_map_parse(FILE *fp, struct kbd_map *map)
} else {
entry.scancode = strtol(scancode, NULL, 10);
}
- if (entry.scancode < 0 ||
- entry.scancode >= map->size) {
- fprintf(stderr,"scancode %d out of range (0-%d)\n",
- entry.scancode,map->size);
+
+ if (entry.scancode < 0) {
+ fprintf(stderr,"scancode %d invalid\n",
+ entry.scancode);
return -1;
}
@@ -161,7 +162,7 @@ static int kbd_map_parse(FILE *fp, struct kbd_map *map)
fprintf(stderr,"set: ");
kbd_key_print(stderr,entry.scancode,entry.keycode);
- map->map[entry.scancode] = entry;
+ map->map[idx++] = entry;
}
return 0;
}