/*
* Copyright © 2011, 2012 Intel Corporation
+ * Copyright © 2013 Jonas Ådahl
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
#include "config.h"
-#include <linux/input.h>
-#include <wayland-util.h>
+#include "linux/input.h"
+#include <libevdev/libevdev.h>
-#define MAX_SLOTS 16
+#include "libinput-private.h"
enum evdev_event_type {
- EVDEV_ABSOLUTE_MOTION = (1 << 0),
- EVDEV_ABSOLUTE_MT_DOWN = (1 << 1),
- EVDEV_ABSOLUTE_MT_MOTION = (1 << 2),
- EVDEV_ABSOLUTE_MT_UP = (1 << 3),
- EVDEV_RELATIVE_MOTION = (1 << 4),
- EVDEV_SYN_OR_SLOT = (1 << 5),
+ EVDEV_NONE,
+ EVDEV_ABSOLUTE_TOUCH_DOWN,
+ EVDEV_ABSOLUTE_MOTION,
+ EVDEV_ABSOLUTE_TOUCH_UP,
+ EVDEV_ABSOLUTE_MT_DOWN,
+ EVDEV_ABSOLUTE_MT_MOTION,
+ EVDEV_ABSOLUTE_MT_UP,
+ EVDEV_RELATIVE_MOTION,
};
-enum evdev_device_capability {
- EVDEV_KEYBOARD = (1 << 0),
- EVDEV_BUTTON = (1 << 1),
- EVDEV_MOTION_ABS = (1 << 2),
- EVDEV_MOTION_REL = (1 << 3),
- EVDEV_TOUCH = (1 << 4),
+enum evdev_device_seat_capability {
+ EVDEV_DEVICE_POINTER = (1 << 0),
+ EVDEV_DEVICE_KEYBOARD = (1 << 1),
+ EVDEV_DEVICE_TOUCH = (1 << 2)
+};
+
+struct mt_slot {
+ int32_t seat_slot;
+ int32_t x, y;
};
struct evdev_device {
- struct weston_seat *seat;
- struct wl_list link;
- struct wl_event_source *source;
- struct weston_output *output;
+ struct libinput_device base;
+
+ struct libinput_source *source;
+
struct evdev_dispatch *dispatch;
+ struct libevdev *evdev;
+ char *output_name;
char *devnode;
- char *devname;
+ char *sysname;
+ const char *devname;
int fd;
struct {
- int min_x, max_x, min_y, max_y;
+ const struct input_absinfo *absinfo_x, *absinfo_y;
+ int fake_resolution;
+
int32_t x, y;
+ int32_t seat_slot;
int apply_calibration;
float calibration[6];
struct {
int slot;
- int32_t x[MAX_SLOTS];
- int32_t y[MAX_SLOTS];
+ struct mt_slot *slots;
+ size_t slots_len;
} mt;
struct mtdev *mtdev;
struct {
- wl_fixed_t dx, dy;
+ int dx, dy;
} rel;
- enum evdev_event_type pending_events;
- enum evdev_device_capability caps;
+ enum evdev_event_type pending_event;
+ enum evdev_device_seat_capability seat_caps;
int is_mt;
-};
-/* copied from udev/extras/input_id/input_id.c */
-/* we must use this kernel-compatible implementation */
-#define BITS_PER_LONG (sizeof(unsigned long) * 8)
-#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
-#define OFF(x) ((x)%BITS_PER_LONG)
-#define BIT(x) (1UL<<OFF(x))
-#define LONG(x) ((x)/BITS_PER_LONG)
-#define TEST_BIT(array, bit) ((array[LONG(bit)] >> OFF(bit)) & 1)
-/* end copied */
+ struct {
+ struct motion_filter *filter;
+ } pointer;
+
+ /* Bitmask of pressed keys used to ignore initial release events from
+ * the kernel. */
+ unsigned long key_mask[NLONGS(KEY_CNT)];
+ /* Key counter used for multiplexing button events internally in
+ * libinput. */
+ uint8_t key_count[KEY_CNT];
+};
#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
void (*process)(struct evdev_dispatch *dispatch,
struct evdev_device *device,
struct input_event *event,
- uint32_t time);
+ uint64_t time);
/* Destroy an event dispatch handler and free all its resources. */
void (*destroy)(struct evdev_dispatch *dispatch);
struct evdev_dispatch_interface *interface;
};
+struct evdev_device *
+evdev_device_create(struct libinput_seat *seat,
+ const char *devnode,
+ const char *sysname);
+
struct evdev_dispatch *
evdev_touchpad_create(struct evdev_device *device);
+struct evdev_dispatch *
+evdev_mt_touchpad_create(struct evdev_device *device);
+
void
-evdev_led_update(struct evdev_device *device, enum weston_led leds);
+evdev_device_proces_event(struct libinput_event *event);
-struct evdev_device *
-evdev_device_create(struct weston_seat *seat, const char *path, int device_fd);
+void
+evdev_device_led_update(struct evdev_device *device, enum libinput_led leds);
+
+int
+evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size);
+
+const char *
+evdev_device_get_output(struct evdev_device *device);
+
+const char *
+evdev_device_get_sysname(struct evdev_device *device);
+
+const char *
+evdev_device_get_name(struct evdev_device *device);
+
+unsigned int
+evdev_device_get_id_product(struct evdev_device *device);
+
+unsigned int
+evdev_device_get_id_vendor(struct evdev_device *device);
void
-evdev_device_destroy(struct evdev_device *device);
+evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
+
+int
+evdev_device_has_capability(struct evdev_device *device,
+ enum libinput_device_capability capability);
+
+int
+evdev_device_get_size(struct evdev_device *device,
+ double *w,
+ double *h);
+
+double
+evdev_device_transform_x(struct evdev_device *device,
+ double x,
+ uint32_t width);
+
+double
+evdev_device_transform_y(struct evdev_device *device,
+ double y,
+ uint32_t height);
void
-evdev_notify_keyboard_focus(struct weston_seat *seat,
- struct wl_list *evdev_devices);
+evdev_keyboard_notify_key(struct evdev_device *device,
+ uint32_t time,
+ int key,
+ enum libinput_key_state state);
+
+void
+evdev_pointer_notify_button(struct evdev_device *device,
+ uint32_t time,
+ int button,
+ enum libinput_button_state state);
+
+void
+evdev_device_remove(struct evdev_device *device);
+
+void
+evdev_device_destroy(struct evdev_device *device);
+
+static inline double
+evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
+{
+ double value = v - absinfo->minimum;
+ return value/absinfo->resolution;
+}
#endif /* EVDEV_H */