Anonymous avatar Anonymous committed 8225582

keymap: Tolerate invalid entries in keymaps

Some keymaps apply to a large range of computer models, not all of which have
all of the scan codes in the maps. If a single scan code is invalid, do not
abort but continue with the next entry in the map. Instead just show the error
message for that particular scan code, to help with debugging.

Comments (0)

Files changed (1)

src/keymap/keymap.c

                 if (e && errno == EINVAL) {
                         return -2;
                 } else {
-                        fprintf(stderr, "EVIOCGKEYCODE: %m\n");
+                        fprintf(stderr, "EVIOCGKEYCODE for scan code 0x%x: %m\n", scancode);
                         return -1;
                 }
         }
 
                 if ((old_keycode = evdev_get_keycode(fd, scancode, 0)) < 0) {
                         r = -1;
-                        goto fail;
+                        continue;
                 }
 
                 if (evdev_set_keycode(fd, scancode, new_keycode) < 0) {
                         r = -1;
-                        goto fail;
+                        continue;
                 }
 
                 if (new_keycode != old_keycode)
                         fprintf(stderr, "Remapped scancode 0x%02x to 0x%02x (prior: 0x%02x)\n",
                                 scancode, new_keycode, old_keycode);
         }
-fail:
+
         fclose(f);
         return r;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.