2 * Copyright © 2011, 2012 Intel Corporation
3 * Copyright © 2013 Jonas Ådahl
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of the copyright holders not be used in
10 * advertising or publicity pertaining to distribution of the software
11 * without specific, written prior permission. The copyright holders make
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 #include "linux/input.h"
30 #include <libevdev/libevdev.h>
32 #include "libinput-private.h"
34 enum evdev_event_type {
36 EVDEV_ABSOLUTE_TOUCH_DOWN,
37 EVDEV_ABSOLUTE_MOTION,
38 EVDEV_ABSOLUTE_TOUCH_UP,
39 EVDEV_ABSOLUTE_MT_DOWN,
40 EVDEV_ABSOLUTE_MT_MOTION,
42 EVDEV_RELATIVE_MOTION,
45 enum evdev_device_seat_capability {
46 EVDEV_DEVICE_POINTER = (1 << 0),
47 EVDEV_DEVICE_KEYBOARD = (1 << 1),
48 EVDEV_DEVICE_TOUCH = (1 << 2)
57 struct libinput_device base;
59 struct libinput_source *source;
61 struct evdev_dispatch *dispatch;
62 struct libevdev *evdev;
69 const struct input_absinfo *absinfo_x, *absinfo_y;
75 int apply_calibration;
81 struct mt_slot *slots;
90 enum evdev_event_type pending_event;
91 enum evdev_device_seat_capability seat_caps;
96 struct motion_filter *filter;
99 /* Bitmask of pressed keys used to ignore initial release events from
101 unsigned long key_mask[NLONGS(KEY_CNT)];
102 /* Key counter used for multiplexing button events internally in
104 uint8_t key_count[KEY_CNT];
107 #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
109 struct evdev_dispatch;
111 struct evdev_dispatch_interface {
112 /* Process an evdev input event. */
113 void (*process)(struct evdev_dispatch *dispatch,
114 struct evdev_device *device,
115 struct input_event *event,
118 /* Destroy an event dispatch handler and free all its resources. */
119 void (*destroy)(struct evdev_dispatch *dispatch);
122 struct evdev_dispatch {
123 struct evdev_dispatch_interface *interface;
126 struct evdev_device *
127 evdev_device_create(struct libinput_seat *seat,
129 const char *sysname);
131 struct evdev_dispatch *
132 evdev_touchpad_create(struct evdev_device *device);
134 struct evdev_dispatch *
135 evdev_mt_touchpad_create(struct evdev_device *device);
138 evdev_device_proces_event(struct libinput_event *event);
141 evdev_device_led_update(struct evdev_device *device, enum libinput_led leds);
144 evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size);
147 evdev_device_get_output(struct evdev_device *device);
150 evdev_device_get_sysname(struct evdev_device *device);
153 evdev_device_get_name(struct evdev_device *device);
156 evdev_device_get_id_product(struct evdev_device *device);
159 evdev_device_get_id_vendor(struct evdev_device *device);
162 evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
165 evdev_device_has_capability(struct evdev_device *device,
166 enum libinput_device_capability capability);
169 evdev_device_get_size(struct evdev_device *device,
174 evdev_device_transform_x(struct evdev_device *device,
179 evdev_device_transform_y(struct evdev_device *device,
184 evdev_keyboard_notify_key(struct evdev_device *device,
187 enum libinput_key_state state);
190 evdev_pointer_notify_button(struct evdev_device *device,
193 enum libinput_button_state state);
196 evdev_device_remove(struct evdev_device *device);
199 evdev_device_destroy(struct evdev_device *device);
202 evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
204 double value = v - absinfo->minimum;
205 return value/absinfo->resolution;