evdev: Add device capabilities
[platform/upstream/libinput.git] / src / evdev.c
1 /*
2  * Copyright © 2010 Intel Corporation
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of the copyright holders not be used in
9  * advertising or publicity pertaining to distribution of the software
10  * without specific, written prior permission.  The copyright holders make
11  * no representations about the suitability of this software for any
12  * purpose.  It is provided "as is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <linux/input.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <mtdev.h>
30
31 #include "compositor.h"
32 #include "evdev.h"
33 #include "evdev-private.h"
34 #include "launcher-util.h"
35
36 static inline void
37 evdev_process_key(struct evdev_input_device *device,
38                         struct input_event *e, int time)
39 {
40         if (e->value == 2)
41                 return;
42
43         switch (e->code) {
44         case BTN_LEFT:
45         case BTN_RIGHT:
46         case BTN_MIDDLE:
47         case BTN_SIDE:
48         case BTN_EXTRA:
49         case BTN_FORWARD:
50         case BTN_BACK:
51         case BTN_TASK:
52                 notify_button(&device->master->base.seat,
53                               time, e->code, e->value);
54                 break;
55
56         default:
57                 notify_key(&device->master->base.seat,
58                            time, e->code, e->value);
59                 break;
60         }
61 }
62
63 static void
64 evdev_process_touch(struct evdev_input_device *device,
65                     struct input_event *e)
66 {
67         const int screen_width = device->output->current->width;
68         const int screen_height = device->output->current->height;
69
70         switch (e->code) {
71         case ABS_MT_SLOT:
72                 device->mt.slot = e->value;
73                 break;
74         case ABS_MT_TRACKING_ID:
75                 if (e->value >= 0)
76                         device->pending_events |= EVDEV_ABSOLUTE_MT_DOWN;
77                 else
78                         device->pending_events |= EVDEV_ABSOLUTE_MT_UP;
79                 break;
80         case ABS_MT_POSITION_X:
81                 device->mt.x[device->mt.slot] =
82                         (e->value - device->abs.min_x) * screen_width /
83                         (device->abs.max_x - device->abs.min_x) +
84                         device->output->x;
85                 device->pending_events |= EVDEV_ABSOLUTE_MT_MOTION;
86                 break;
87         case ABS_MT_POSITION_Y:
88                 device->mt.y[device->mt.slot] =
89                         (e->value - device->abs.min_y) * screen_height /
90                         (device->abs.max_y - device->abs.min_y) +
91                         device->output->y;
92                 device->pending_events |= EVDEV_ABSOLUTE_MT_MOTION;
93                 break;
94         }
95 }
96
97 static inline void
98 evdev_process_absolute_motion(struct evdev_input_device *device,
99                               struct input_event *e)
100 {
101         const int screen_width = device->output->current->width;
102         const int screen_height = device->output->current->height;
103
104         switch (e->code) {
105         case ABS_X:
106                 device->abs.x =
107                         (e->value - device->abs.min_x) * screen_width /
108                         (device->abs.max_x - device->abs.min_x) +
109                         device->output->x;
110                 device->pending_events |= EVDEV_ABSOLUTE_MOTION;
111                 break;
112         case ABS_Y:
113                 device->abs.y =
114                         (e->value - device->abs.min_y) * screen_height /
115                         (device->abs.max_y - device->abs.min_y) +
116                         device->output->y;
117                 device->pending_events |= EVDEV_ABSOLUTE_MOTION;
118                 break;
119         }
120 }
121
122 static inline void
123 evdev_process_relative(struct evdev_input_device *device,
124                        struct input_event *e, uint32_t time)
125 {
126         switch (e->code) {
127         case REL_X:
128                 device->rel.dx += wl_fixed_from_int(e->value);
129                 device->pending_events |= EVDEV_RELATIVE_MOTION;
130                 break;
131         case REL_Y:
132                 device->rel.dy += wl_fixed_from_int(e->value);
133                 device->pending_events |= EVDEV_RELATIVE_MOTION;
134                 break;
135         case REL_WHEEL:
136                 notify_axis(&device->master->base.seat,
137                               time,
138                               WL_POINTER_AXIS_VERTICAL_SCROLL, e->value);
139                 break;
140         case REL_HWHEEL:
141                 notify_axis(&device->master->base.seat,
142                               time,
143                               WL_POINTER_AXIS_HORIZONTAL_SCROLL, e->value);
144                 break;
145         }
146 }
147
148 static inline void
149 evdev_process_absolute(struct evdev_input_device *device,
150                        struct input_event *e)
151 {
152         if (device->is_mt) {
153                 evdev_process_touch(device, e);
154         } else {
155                 evdev_process_absolute_motion(device, e);
156         }
157 }
158
159 static int
160 is_motion_event(struct input_event *e)
161 {
162         switch (e->type) {
163         case EV_REL:
164                 switch (e->code) {
165                 case REL_X:
166                 case REL_Y:
167                         return 1;
168                 }
169         case EV_ABS:
170                 switch (e->code) {
171                 case ABS_X:
172                 case ABS_Y:
173                 case ABS_MT_POSITION_X:
174                 case ABS_MT_POSITION_Y:
175                         return 1;
176                 }
177         }
178
179         return 0;
180 }
181
182 static void
183 evdev_flush_motion(struct evdev_input_device *device, uint32_t time)
184 {
185         struct weston_seat *master = &device->master->base;
186
187         if (!device->pending_events)
188                 return;
189
190         if (device->pending_events & EVDEV_RELATIVE_MOTION) {
191                 notify_motion(&master->seat, time,
192                               master->seat.pointer->x + device->rel.dx,
193                               master->seat.pointer->y + device->rel.dy);
194                 device->pending_events &= ~EVDEV_RELATIVE_MOTION;
195                 device->rel.dx = 0;
196                 device->rel.dy = 0;
197         }
198         if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN) {
199                 notify_touch(&master->seat, time,
200                              device->mt.slot,
201                              wl_fixed_from_int(device->mt.x[device->mt.slot]),
202                              wl_fixed_from_int(device->mt.y[device->mt.slot]),
203                              WL_TOUCH_DOWN);
204                 device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
205                 device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
206         }
207         if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION) {
208                 notify_touch(&master->seat, time,
209                              device->mt.slot,
210                              wl_fixed_from_int(device->mt.x[device->mt.slot]),
211                              wl_fixed_from_int(device->mt.y[device->mt.slot]),
212                              WL_TOUCH_MOTION);
213                 device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
214                 device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
215         }
216         if (device->pending_events & EVDEV_ABSOLUTE_MT_UP) {
217                 notify_touch(&master->seat, time, device->mt.slot, 0, 0,
218                              WL_TOUCH_UP);
219                 device->pending_events &= ~EVDEV_ABSOLUTE_MT_UP;
220         }
221         if (device->pending_events & EVDEV_ABSOLUTE_MOTION) {
222                 notify_motion(&master->seat, time,
223                               wl_fixed_from_int(device->abs.x),
224                               wl_fixed_from_int(device->abs.y));
225                 device->pending_events &= ~EVDEV_ABSOLUTE_MOTION;
226         }
227 }
228
229 static void
230 fallback_process(struct evdev_dispatch *dispatch,
231                  struct evdev_input_device *device,
232                  struct input_event *event,
233                  uint32_t time)
234 {
235         switch (event->type) {
236         case EV_REL:
237                 evdev_process_relative(device, event, time);
238                 break;
239         case EV_ABS:
240                 evdev_process_absolute(device, event);
241                 break;
242         case EV_KEY:
243                 evdev_process_key(device, event, time);
244                 break;
245         }
246 }
247
248 static void
249 fallback_destroy(struct evdev_dispatch *dispatch)
250 {
251         free(dispatch);
252 }
253
254 struct evdev_dispatch_interface fallback_interface = {
255         fallback_process,
256         fallback_destroy
257 };
258
259 static struct evdev_dispatch *
260 fallback_dispatch_create(void)
261 {
262         struct evdev_dispatch *dispatch = malloc(sizeof *dispatch);
263         if (dispatch == NULL)
264                 return NULL;
265
266         dispatch->interface = &fallback_interface;
267
268         return dispatch;
269 }
270
271 static void
272 evdev_process_events(struct evdev_input_device *device,
273                      struct input_event *ev, int count)
274 {
275         struct evdev_dispatch *dispatch = device->dispatch;
276         struct input_event *e, *end;
277         uint32_t time = 0;
278
279         device->pending_events = 0;
280
281         e = ev;
282         end = e + count;
283         for (e = ev; e < end; e++) {
284                 time = e->time.tv_sec * 1000 + e->time.tv_usec / 1000;
285
286                 /* we try to minimize the amount of notifications to be
287                  * forwarded to the compositor, so we accumulate motion
288                  * events and send as a bunch */
289                 if (!is_motion_event(e))
290                         evdev_flush_motion(device, time);
291
292                 dispatch->interface->process(dispatch, device, e, time);
293         }
294
295         evdev_flush_motion(device, time);
296 }
297
298 static int
299 evdev_input_device_data(int fd, uint32_t mask, void *data)
300 {
301         struct weston_compositor *ec;
302         struct evdev_input_device *device = data;
303         struct input_event ev[32];
304         int len;
305
306         ec = device->master->base.compositor;
307         if (!ec->focus)
308                 return 1;
309
310         /* If the compositor is repainting, this function is called only once
311          * per frame and we have to process all the events available on the
312          * fd, otherwise there will be input lag. */
313         do {
314                 if (device->mtdev)
315                         len = mtdev_get(device->mtdev, fd, ev,
316                                         ARRAY_LENGTH(ev)) *
317                                 sizeof (struct input_event);
318                 else
319                         len = read(fd, &ev, sizeof ev);
320
321                 if (len < 0 || len % sizeof ev[0] != 0) {
322                         /* FIXME: call device_removed when errno is ENODEV. */
323                         return 1;
324                 }
325
326                 evdev_process_events(device, ev, len / sizeof ev[0]);
327
328         } while (len > 0);
329
330         return 1;
331 }
332
333 static int
334 evdev_configure_device(struct evdev_input_device *device)
335 {
336         struct input_absinfo absinfo;
337         unsigned long ev_bits[NBITS(EV_MAX)];
338         unsigned long abs_bits[NBITS(ABS_MAX)];
339         unsigned long rel_bits[NBITS(REL_MAX)];
340         unsigned long key_bits[NBITS(KEY_MAX)];
341         int has_key, has_abs;
342         unsigned int i;
343
344         has_key = 0;
345         has_abs = 0;
346         device->caps = 0;
347
348         ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits);
349         if (TEST_BIT(ev_bits, EV_ABS)) {
350                 has_abs = 1;
351
352                 ioctl(device->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)),
353                       abs_bits);
354                 if (TEST_BIT(abs_bits, ABS_X)) {
355                         ioctl(device->fd, EVIOCGABS(ABS_X), &absinfo);
356                         device->abs.min_x = absinfo.minimum;
357                         device->abs.max_x = absinfo.maximum;
358                         device->caps |= EVDEV_MOTION_ABS;
359                 }
360                 if (TEST_BIT(abs_bits, ABS_Y)) {
361                         ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
362                         device->abs.min_y = absinfo.minimum;
363                         device->abs.max_y = absinfo.maximum;
364                         device->caps |= EVDEV_MOTION_ABS;
365                 }
366                 if (TEST_BIT(abs_bits, ABS_MT_SLOT)) {
367                         device->is_mt = 1;
368                         device->mt.slot = 0;
369                         device->caps |= EVDEV_TOUCH;
370                 }
371         }
372         if (TEST_BIT(ev_bits, EV_REL)) {
373                 ioctl(device->fd, EVIOCGBIT(EV_REL, sizeof(rel_bits)),
374                       rel_bits);
375                 if (TEST_BIT(rel_bits, REL_X) || TEST_BIT(rel_bits, REL_Y))
376                         device->caps |= EVDEV_MOTION_REL;
377         }
378         if (TEST_BIT(ev_bits, EV_KEY)) {
379                 has_key = 1;
380                 ioctl(device->fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)),
381                       key_bits);
382                 if (TEST_BIT(key_bits, BTN_TOOL_FINGER) &&
383                     !TEST_BIT(key_bits, BTN_TOOL_PEN) &&
384                     has_abs)
385                         device->dispatch = evdev_touchpad_create(device);
386                 for (i = KEY_ESC; i < KEY_MAX; i++) {
387                         if (i >= BTN_MISC && i < KEY_OK)
388                                 continue;
389                         if (TEST_BIT(key_bits, i)) {
390                                 device->caps |= EVDEV_KEYBOARD;
391                                 break;
392                         }
393                 }
394                 for (i = BTN_MISC; i < KEY_OK; i++) {
395                         if (TEST_BIT(key_bits, i)) {
396                                 device->caps |= EVDEV_BUTTON;
397                                 break;
398                         }
399                 }
400         }
401
402         /* This rule tries to catch accelerometer devices and opt out. We may
403          * want to adjust the protocol later adding a proper event for dealing
404          * with accelerometers and implement here accordingly */
405         if (has_abs && !has_key)
406                 return -1;
407
408         return 0;
409 }
410
411 static struct evdev_input_device *
412 evdev_input_device_create(struct evdev_seat *master,
413                           struct wl_display *display, const char *path)
414 {
415         struct evdev_input_device *device;
416         struct weston_compositor *ec;
417
418         device = malloc(sizeof *device);
419         if (device == NULL)
420                 return NULL;
421
422         ec = master->base.compositor;
423         device->output =
424                 container_of(ec->output_list.next, struct weston_output, link);
425
426         device->master = master;
427         device->is_mt = 0;
428         device->mtdev = NULL;
429         device->devnode = strdup(path);
430         device->mt.slot = -1;
431         device->rel.dx = 0;
432         device->rel.dy = 0;
433         device->dispatch = NULL;
434
435         /* Use non-blocking mode so that we can loop on read on
436          * evdev_input_device_data() until all events on the fd are
437          * read.  mtdev_get() also expects this. */
438         device->fd = weston_launcher_open(ec, path, O_RDONLY | O_NONBLOCK);
439         if (device->fd < 0)
440                 goto err0;
441
442         if (evdev_configure_device(device) == -1)
443                 goto err1;
444
445         /* If the dispatch was not set up use the fallback. */
446         if (device->dispatch == NULL)
447                 device->dispatch = fallback_dispatch_create();
448         if (device->dispatch == NULL)
449                 goto err1;
450
451
452         if (device->is_mt) {
453                 device->mtdev = mtdev_new_open(device->fd);
454                 if (!device->mtdev)
455                         fprintf(stderr, "mtdev failed to open for %s\n", path);
456         }
457
458         device->source = wl_event_loop_add_fd(ec->input_loop, device->fd,
459                                               WL_EVENT_READABLE,
460                                               evdev_input_device_data, device);
461         if (device->source == NULL)
462                 goto err2;
463
464         wl_list_insert(master->devices_list.prev, &device->link);
465
466         return device;
467
468 err2:
469         device->dispatch->interface->destroy(device->dispatch);
470 err1:
471         close(device->fd);
472 err0:
473         free(device->devnode);
474         free(device);
475         return NULL;
476 }
477
478 static const char default_seat[] = "seat0";
479
480 static void
481 device_added(struct udev_device *udev_device, struct evdev_seat *master)
482 {
483         struct weston_compositor *c;
484         const char *devnode;
485         const char *device_seat;
486
487         device_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
488         if (!device_seat)
489                 device_seat = default_seat;
490
491         if (strcmp(device_seat, master->seat_id))
492                 return;
493
494         c = master->base.compositor;
495         devnode = udev_device_get_devnode(udev_device);
496         evdev_input_device_create(master, c->wl_display, devnode);
497 }
498
499 static void
500 device_removed(struct evdev_input_device *device)
501 {
502         struct evdev_dispatch *dispatch;
503
504         dispatch = device->dispatch;
505         if (dispatch)
506                 dispatch->interface->destroy(dispatch);
507
508         wl_event_source_remove(device->source);
509         wl_list_remove(&device->link);
510         if (device->mtdev)
511                 mtdev_close_delete(device->mtdev);
512         close(device->fd);
513         free(device->devnode);
514         free(device);
515 }
516
517 static void
518 evdev_notify_keyboard_focus(struct evdev_seat *seat)
519 {
520         struct evdev_input_device *device;
521         struct wl_array keys;
522         unsigned int i, set;
523         char evdev_keys[(KEY_CNT + 7) / 8], all_keys[(KEY_CNT + 7) / 8];
524         uint32_t *k;
525         int ret;
526
527         memset(all_keys, 0, sizeof all_keys);
528         wl_list_for_each(device, &seat->devices_list, link) {
529                 memset(evdev_keys, 0, sizeof evdev_keys);
530                 ret = ioctl(device->fd,
531                             EVIOCGKEY(sizeof evdev_keys), evdev_keys);
532                 if (ret < 0) {
533                         fprintf(stderr, "failed to get keys for device %s\n",
534                                 device->devnode);
535                         continue;
536                 }
537                 for (i = 0; i < ARRAY_LENGTH(evdev_keys); i++)
538                         all_keys[i] |= evdev_keys[i];
539         }
540
541         wl_array_init(&keys);
542         for (i = 0; i < KEY_CNT; i++) {
543                 set = all_keys[i >> 3] & (1 << (i & 7));
544                 if (set) {
545                         k = wl_array_add(&keys, sizeof *k);
546                         *k = i;
547                 }
548         }
549
550         notify_keyboard_focus(&seat->base.seat, &keys);
551
552         wl_array_release(&keys);
553 }
554
555 void
556 evdev_add_devices(struct udev *udev, struct weston_seat *seat_base)
557 {
558         struct evdev_seat *seat = (struct evdev_seat *) seat_base;
559         struct udev_enumerate *e;
560         struct udev_list_entry *entry;
561         struct udev_device *device;
562         const char *path, *sysname;
563
564         e = udev_enumerate_new(udev);
565         udev_enumerate_add_match_subsystem(e, "input");
566         udev_enumerate_scan_devices(e);
567         udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
568                 path = udev_list_entry_get_name(entry);
569                 device = udev_device_new_from_syspath(udev, path);
570
571                 sysname = udev_device_get_sysname(device);
572                 if (strncmp("event", sysname, 5) != 0) {
573                         udev_device_unref(device);
574                         continue;
575                 }
576
577                 device_added(device, seat);
578
579                 udev_device_unref(device);
580         }
581         udev_enumerate_unref(e);
582
583         evdev_notify_keyboard_focus(seat);
584
585         if (wl_list_empty(&seat->devices_list)) {
586                 fprintf(stderr,
587                         "warning: no input devices on entering Weston. "
588                         "Possible causes:\n"
589                         "\t- no permissions to read /dev/input/event*\n"
590                         "\t- seats misconfigured "
591                         "(Weston backend option 'seat', "
592                         "udev device property ID_SEAT)\n");
593         }
594 }
595
596 static int
597 evdev_udev_handler(int fd, uint32_t mask, void *data)
598 {
599         struct evdev_seat *master = data;
600         struct udev_device *udev_device;
601         struct evdev_input_device *device, *next;
602         const char *action;
603         const char *devnode;
604
605         udev_device = udev_monitor_receive_device(master->udev_monitor);
606         if (!udev_device)
607                 return 1;
608
609         action = udev_device_get_action(udev_device);
610         if (action) {
611                 if (strncmp("event", udev_device_get_sysname(udev_device), 5) != 0)
612                         return 0;
613
614                 if (!strcmp(action, "add")) {
615                         device_added(udev_device, master);
616                 }
617                 else if (!strcmp(action, "remove")) {
618                         devnode = udev_device_get_devnode(udev_device);
619                         wl_list_for_each_safe(device, next,
620                                               &master->devices_list, link)
621                                 if (!strcmp(device->devnode, devnode)) {
622                                         device_removed(device);
623                                         break;
624                                 }
625                 }
626         }
627         udev_device_unref(udev_device);
628
629         return 0;
630 }
631
632 int
633 evdev_enable_udev_monitor(struct udev *udev, struct weston_seat *seat_base)
634 {
635         struct evdev_seat *master = (struct evdev_seat *) seat_base;
636         struct wl_event_loop *loop;
637         struct weston_compositor *c = master->base.compositor;
638         int fd;
639
640         master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
641         if (!master->udev_monitor) {
642                 fprintf(stderr, "udev: failed to create the udev monitor\n");
643                 return 0;
644         }
645
646         udev_monitor_filter_add_match_subsystem_devtype(master->udev_monitor,
647                         "input", NULL);
648
649         if (udev_monitor_enable_receiving(master->udev_monitor)) {
650                 fprintf(stderr, "udev: failed to bind the udev monitor\n");
651                 udev_monitor_unref(master->udev_monitor);
652                 return 0;
653         }
654
655         loop = wl_display_get_event_loop(c->wl_display);
656         fd = udev_monitor_get_fd(master->udev_monitor);
657         master->udev_monitor_source =
658                 wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
659                                      evdev_udev_handler, master);
660         if (!master->udev_monitor_source) {
661                 udev_monitor_unref(master->udev_monitor);
662                 return 0;
663         }
664
665         return 1;
666 }
667
668 void
669 evdev_disable_udev_monitor(struct weston_seat *seat_base)
670 {
671         struct evdev_seat *seat = (struct evdev_seat *) seat_base;
672
673         if (!seat->udev_monitor)
674                 return;
675
676         udev_monitor_unref(seat->udev_monitor);
677         seat->udev_monitor = NULL;
678         wl_event_source_remove(seat->udev_monitor_source);
679         seat->udev_monitor_source = NULL;
680 }
681
682 void
683 evdev_input_create(struct weston_compositor *c, struct udev *udev,
684                    const char *seat_id)
685 {
686         struct evdev_seat *seat;
687
688         seat = malloc(sizeof *seat);
689         if (seat == NULL)
690                 return;
691
692         memset(seat, 0, sizeof *seat);
693         weston_seat_init(&seat->base, c);
694
695         wl_list_init(&seat->devices_list);
696         seat->seat_id = strdup(seat_id);
697         if (!evdev_enable_udev_monitor(udev, &seat->base)) {
698                 free(seat->seat_id);
699                 free(seat);
700                 return;
701         }
702
703         evdev_add_devices(udev, &seat->base);
704
705         c->seat = &seat->base;
706 }
707
708 void
709 evdev_remove_devices(struct weston_seat *seat_base)
710 {
711         struct evdev_seat *seat = (struct evdev_seat *) seat_base;
712         struct evdev_input_device *device, *next;
713
714         wl_list_for_each_safe(device, next, &seat->devices_list, link)
715                 device_removed(device);
716
717         notify_keyboard_focus(&seat->base.seat, NULL);
718 }
719
720 void
721 evdev_input_destroy(struct weston_seat *seat_base)
722 {
723         struct evdev_seat *seat = (struct evdev_seat *) seat_base;
724
725         evdev_remove_devices(seat_base);
726         evdev_disable_udev_monitor(&seat->base);
727
728         wl_list_remove(&seat->base.link);
729         free(seat->seat_id);
730         free(seat);
731 }