summaryrefslogtreecommitdiff
path: root/rcm-server-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcm-server-main.c')
-rw-r--r--rcm-server-main.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/rcm-server-main.c b/rcm-server-main.c
index 8dc5a6b..990a964 100644
--- a/rcm-server-main.c
+++ b/rcm-server-main.c
@@ -726,11 +726,10 @@ evdev_read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
{
struct device *device = userdata;
struct input_event ev;
- static const char *keycode_str = NULL;
- static uint32_t keycode = KEY_RESERVED;
+ static struct linux_input_keycode *keycode = NULL;
+ static bool pressed = false;
static uint32_t scancode;
static bool scancode_recv = false;
- static bool pressed = false;
unsigned i;
if (fd != device->evdev_fd)
@@ -751,7 +750,7 @@ evdev_read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
while (read(fd, &ev, sizeof(ev)) == sizeof(ev)) {
switch (ev.type) {
case EV_KEY:
- if (keycode != KEY_RESERVED)
+ if (keycode)
printf("Reading from evdev - multiple keycodes?\n");
for (i = 0; linux_input_keycodes[i].name; i++) {
@@ -764,9 +763,9 @@ evdev_read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
break;
}
- keycode_str = linux_input_keycodes[i].name;
- keycode = ev.code;
- pressed = ev.value ? true : false;
+ keycode = &linux_input_keycodes[i];
+ if (ev.value)
+ pressed = true;
break;
case EV_MSC:
@@ -779,35 +778,46 @@ evdev_read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
break;
case EV_SYN:
- if (keycode != KEY_RESERVED || scancode_recv) {
- printf("evdev event -");
- if (keycode != KEY_RESERVED)
- printf(" keycode %s (%u) %s",
- keycode_str, keycode,
- pressed ? "pressed" : "released");
+ if (keycode || scancode_recv) {
+ const char *protocol;
+
+ /* FIXME: protocol reporting needs kernel support */
if (scancode_recv)
+ protocol = evdev_guess_protocol(device, scancode, lik ? lik->value : KEY_RESERVED);
+
+ printf("evdev -");
+
+ if (scancode_recv) {
+ printf(" protocol %s (guessed)", protocol);
printf(" scancode 0x%08x", scancode);
+ }
+
+ if (keycode) {
+ printf(" keycode %s (%u)", keycode->name, keycode->value);
+ printf(" %s", pressed ? "pressed" : "released");
+ }
+
printf("\n");
- /* FIXME: protocol needs kernel support */
- if (pressed && scancode_recv)
+ if (scancode_recv)
sd_bus_emit_signal(device->mgr->bus,
device->path,
"org.gnome.RemoteControlManager.Device",
"KeyPressed",
- "sts", "nec", scancode, keycode_str);
- else if (!pressed && keycode != KEY_RESERVED)
+ "sts", protocol, scancode,
+ keycode ? keycode->name : "KEY_RESERVED");
+
+ else if (keycode && !pressed)
sd_bus_emit_signal(device->mgr->bus,
device->path,
"org.gnome.RemoteControlManager.Device",
"KeyReleased",
- "s", keycode_str);
+ "s", keycode->name);
}
- keycode = KEY_RESERVED;
- keycode_str = NULL;
scancode_recv = false;
pressed = false;
+ keycode = NULL;
break;
default: