log_debug("keyboard: updating force-release list with '%s'", codes);
ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
if (ret < 0)
- log_error("Error writing force-release attribute: %s", strerror(-ret));
+ log_error_errno(ret, "Error writing force-release attribute: %m");
return ret;
}
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
const char *key;
- unsigned int scancode;
+ unsigned int scancode, keycode_num;
char *endptr;
const char *keycode;
const struct key *k;
/* translate identifier to key code */
k = keyboard_lookup_key(keycode, strlen(keycode));
- if (!k) {
- log_error("Error, unknown key identifier '%s'", keycode);
- continue;
+ if (k) {
+ keycode_num = k->id;
+ } else {
+ /* check if it's a numeric code already */
+ keycode_num = strtoul(keycode, &endptr, 0);
+ if (endptr[0] !='\0') {
+ log_error("Error, unknown key identifier '%s'", keycode);
+ continue;
+ }
}
map[map_count].scan = scancode;
- map[map_count].key = k->id;
+ map[map_count].key = keycode_num;
if (map_count < ELEMENTSOF(map)-1)
map_count++;
}
fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
- log_error("Error, opening device '%s': %m", node);
+ log_error_errno(errno, "Error, opening device '%s': %m", node);
return EXIT_FAILURE;
}
log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)",
map[i].scan, map[i].scan, map[i].key, map[i].key);
if (ioctl(fd, EVIOCSKEYCODE, &map[i]) < 0)
- log_error("Error calling EVIOCSKEYCODE (scan code 0x%x, key code %d): %m", map[i].scan, map[i].key);
+ log_error_errno(errno, "Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", node, map[i].scan, map[i].key);
}
/* install list of force-release codes */