2 * Copyright © 2011, 2012 Intel Corporation
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.
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.
28 #include <linux/input.h>
29 #include <wayland-util.h>
33 enum evdev_event_type {
35 EVDEV_ABSOLUTE_TOUCH_DOWN,
36 EVDEV_ABSOLUTE_MOTION,
37 EVDEV_ABSOLUTE_TOUCH_UP,
38 EVDEV_ABSOLUTE_MT_DOWN,
39 EVDEV_ABSOLUTE_MT_MOTION,
41 EVDEV_RELATIVE_MOTION,
44 enum evdev_device_seat_capability {
45 EVDEV_SEAT_POINTER = (1 << 0),
46 EVDEV_SEAT_KEYBOARD = (1 << 1),
47 EVDEV_SEAT_TOUCH = (1 << 2)
51 struct weston_seat *seat;
53 struct wl_event_source *source;
54 struct weston_output *output;
55 struct evdev_dispatch *dispatch;
56 struct wl_listener output_destroy_listener;
62 int min_x, max_x, min_y, max_y;
66 int apply_calibration;
83 enum evdev_event_type pending_event;
84 enum evdev_device_seat_capability seat_caps;
89 /* copied from udev/extras/input_id/input_id.c */
90 /* we must use this kernel-compatible implementation */
91 #define BITS_PER_LONG (sizeof(unsigned long) * 8)
92 #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
93 #define OFF(x) ((x)%BITS_PER_LONG)
94 #define BIT(x) (1UL<<OFF(x))
95 #define LONG(x) ((x)/BITS_PER_LONG)
96 #define TEST_BIT(array, bit) ((array[LONG(bit)] >> OFF(bit)) & 1)
99 #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
101 struct evdev_dispatch;
103 struct evdev_dispatch_interface {
104 /* Process an evdev input event. */
105 void (*process)(struct evdev_dispatch *dispatch,
106 struct evdev_device *device,
107 struct input_event *event,
110 /* Destroy an event dispatch handler and free all its resources. */
111 void (*destroy)(struct evdev_dispatch *dispatch);
114 struct evdev_dispatch {
115 struct evdev_dispatch_interface *interface;
118 struct evdev_dispatch *
119 evdev_touchpad_create(struct evdev_device *device);
122 evdev_led_update(struct evdev_device *device, enum weston_led leds);
124 struct evdev_device *
125 evdev_device_create(struct weston_seat *seat, const char *path, int device_fd);
128 evdev_device_set_output(struct evdev_device *device,
129 struct weston_output *output);
131 evdev_device_destroy(struct evdev_device *device);
134 evdev_notify_keyboard_focus(struct weston_seat *seat,
135 struct wl_list *evdev_devices);