summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2012-05-30 16:31:49 +0100
committerKristian Høgsberg <krh@bitplanet.net>2012-05-31 15:42:17 -0400
commit7bbd5b333567430ff06e9ceed20576291406011f (patch)
tree8a6a579838e25e7e0e7dfbfbd1767cd1b878a152
parent33965c242d81c9980d7b20b8adaa8c88a05f6109 (diff)
evdev: Add LED update hook
Simply pushes the updated LEDs through to all keyboard attached to the seat. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--src/evdev.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/evdev.c b/src/evdev.c
index a34aa43..e73f343 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -33,6 +33,35 @@
#include "evdev-private.h"
#include "launcher-util.h"
+static void
+evdev_led_update(struct weston_seat *seat_base, enum weston_led leds)
+{
+ static const struct {
+ enum weston_led weston;
+ int evdev;
+ } map[] = {
+ { LED_NUM_LOCK, LED_NUML },
+ { LED_CAPS_LOCK, LED_CAPSL },
+ { LED_SCROLL_LOCK, LED_SCROLLL },
+ };
+ struct evdev_seat *seat = (struct evdev_seat *) seat_base;
+ struct evdev_input_device *device;
+ struct input_event ev[ARRAY_LENGTH(map)];
+ unsigned int i;
+
+ memset(ev, 0, sizeof(ev));
+ for (i = 0; i < ARRAY_LENGTH(map); i++) {
+ ev[i].type = EV_LED;
+ ev[i].code = map[i].evdev;
+ ev[i].value = !!(leds & map[i].weston);
+ }
+
+ wl_list_for_each(device, &seat->devices_list, link) {
+ if (device->caps & EVDEV_KEYBOARD)
+ write(device->fd, ev, sizeof *ev);
+ }
+}
+
static inline void
evdev_process_key(struct evdev_input_device *device,
struct input_event *e, int time)
@@ -691,6 +720,7 @@ evdev_input_create(struct weston_compositor *c, struct udev *udev,
memset(seat, 0, sizeof *seat);
weston_seat_init(&seat->base, c);
+ seat->base.led_update = evdev_led_update;
wl_list_init(&seat->devices_list);
seat->seat_id = strdup(seat_id);