chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
man: make bootup graph consistent
[elogind.git]
/
src
/
udev
/
udev-builtin-keyboard.c
diff --git
a/src/udev/udev-builtin-keyboard.c
b/src/udev/udev-builtin-keyboard.c
index 614e44ec7641b857b8031e29381efb941b0faefc..d8ee4cbb61adc97194a6740900fd9c846701b47d 100644
(file)
--- a/
src/udev/udev-builtin-keyboard.c
+++ b/
src/udev/udev-builtin-keyboard.c
@@
-28,17
+28,17
@@
#include "udev.h"
#include "udev.h"
-static const struct key *keyboard_lookup_key(const char *str, unsigned
int
len);
+static const struct key *keyboard_lookup_key(const char *str, unsigned len);
#include "keyboard-keys-from-name.h"
#include "keyboard-keys-to-name.h"
#include "keyboard-keys-from-name.h"
#include "keyboard-keys-to-name.h"
-static int install_force_release(struct udev_device *dev, const unsigned
int *release, unsigned int
release_count) {
+static int install_force_release(struct udev_device *dev, const unsigned
*release, unsigned
release_count) {
struct udev_device *atkbd;
const char *cur;
char codes[4096];
char *s;
size_t l;
struct udev_device *atkbd;
const char *cur;
char codes[4096];
char *s;
size_t l;
- unsigned i
nt i
;
+ unsigned i;
int ret;
atkbd = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
int ret;
atkbd = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);
@@
-57,28
+57,28
@@
static int install_force_release(struct udev_device *dev, const unsigned int *re
/* append new codes */
for (i = 0; i < release_count; i++)
/* append new codes */
for (i = 0; i < release_count; i++)
- l = strpcpyf(&s, l, ",%
d
", release[i]);
+ l = strpcpyf(&s, l, ",%
u
", release[i]);
log_debug("keyboard: updating force-release list with '%s'", codes);
ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
if (ret < 0)
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;
}
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], bool test) {
struct udev_list_entry *entry;
struct {
return ret;
}
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], bool test) {
struct udev_list_entry *entry;
struct {
- unsigned
int
scan;
- unsigned
int
key;
+ unsigned scan;
+ unsigned key;
} map[1024];
} map[1024];
- unsigned
int
map_count = 0;
- unsigned
int
release[1024];
- unsigned
int
release_count = 0;
+ unsigned map_count = 0;
+ unsigned release[1024];
+ unsigned release_count = 0;
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
const char *key;
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
const char *key;
- unsigned
int scancode
;
+ unsigned
scancode, keycode_num
;
char *endptr;
const char *keycode;
const struct key *k;
char *endptr;
const char *keycode;
const struct key *k;
@@
-110,13
+110,19
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
/* translate identifier to key code */
k = keyboard_lookup_key(keycode, strlen(keycode));
/* 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].scan = scancode;
- map[map_count].key = k
->id
;
+ map[map_count].key = k
eycode_num
;
if (map_count < ELEMENTSOF(map)-1)
map_count++;
}
if (map_count < ELEMENTSOF(map)-1)
map_count++;
}
@@
-124,7
+130,7
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
if (map_count > 0 || release_count > 0) {
const char *node;
int fd;
if (map_count > 0 || release_count > 0) {
const char *node;
int fd;
- unsigned i
nt i
;
+ unsigned i;
node = udev_device_get_devnode(dev);
if (!node) {
node = udev_device_get_devnode(dev);
if (!node) {
@@
-134,7
+140,7
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
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;
}
return EXIT_FAILURE;
}
@@
-143,7
+149,7
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
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_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 */
}
/* install list of force-release codes */
@@
-159,5
+165,5
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
const struct udev_builtin udev_builtin_keyboard = {
.name = "keyboard",
.cmd = builtin_keyboard,
const struct udev_builtin udev_builtin_keyboard = {
.name = "keyboard",
.cmd = builtin_keyboard,
- .help = "
k
eyboard scan code to key mapping",
+ .help = "
K
eyboard scan code to key mapping",
};
};