summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-01-19 12:02:51 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-01-19 12:02:51 +1000
commit91a568d1a1339829f4e3969bde3a4935fef9542b (patch)
treed87be87b2199ea489f922f06eb1e538e196ffdff /src
parentf5200c532527644d7a32da6149bb7edb5d8fc9b1 (diff)
parent999cbc8933c6b01d5045afed8203aeba7dfdcb6f (diff)
Merge branch 'master' into tablet-support
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad.c51
-rw-r--r--src/evdev-mt-touchpad.h2
-rw-r--r--src/evdev.c19
-rw-r--r--src/evdev.h1
-rw-r--r--src/libinput-util.h1
-rw-r--r--src/libinput.h2
6 files changed, 35 insertions, 41 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 8014cc91..11cd1c30 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1285,6 +1285,8 @@ tp_want_dwt(struct evdev_device *touchpad,
{
unsigned int bus_tp = libevdev_get_id_bustype(touchpad->evdev),
bus_kbd = libevdev_get_id_bustype(keyboard->evdev);
+ unsigned int vendor_tp = evdev_device_get_id_vendor(touchpad);
+ unsigned int vendor_kbd = evdev_device_get_id_vendor(keyboard);
if (tp_dwt_device_is_blacklisted(touchpad) ||
tp_dwt_device_is_blacklisted(keyboard))
@@ -1295,6 +1297,13 @@ tp_want_dwt(struct evdev_device *touchpad,
if (bus_tp == BUS_I8042 && bus_kbd != bus_tp)
return false;
+ /* For Apple touchpads, always use its internal keyboard */
+ if (vendor_tp == VENDOR_ID_APPLE) {
+ return vendor_kbd == vendor_tp &&
+ keyboard->model_flags &
+ EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD;
+ }
+
/* everything else we don't really know, so we have to assume
they go together */
@@ -1488,7 +1497,8 @@ tp_init_slots(struct tp_dispatch *tp,
* explanation.
*/
if (tp->semi_mt &&
- (device->model_flags & EVDEV_MODEL_JUMPING_SEMI_MT)) {
+ (device->model_flags &
+ (EVDEV_MODEL_JUMPING_SEMI_MT|EVDEV_MODEL_ELANTECH_TOUCHPAD))) {
tp->num_slots = 1;
tp->slot = 0;
tp->has_mt = false;
@@ -1772,8 +1782,7 @@ tp_init_palmdetect(struct tp_dispatch *tp,
width = device->abs.dimensions.x;
height = device->abs.dimensions.y;
- /* Wacom doesn't have internal touchpads,
- * Apple touchpads are always big enough to warrant palm detection */
+ /* Wacom doesn't have internal touchpads */
if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD)
return 0;
@@ -2086,40 +2095,6 @@ tp_change_to_left_handed(struct evdev_device *device)
device->left_handed.enabled = device->left_handed.want_enabled;
}
-struct model_lookup_t {
- uint16_t vendor;
- uint16_t product_start;
- uint16_t product_end;
- enum touchpad_model model;
-};
-
-static struct model_lookup_t model_lookup_table[] = {
- { 0x0002, 0x0007, 0x0007, MODEL_SYNAPTICS },
- { 0x0002, 0x0008, 0x0008, MODEL_ALPS },
- { 0x0002, 0x000e, 0x000e, MODEL_ELANTECH },
- { 0x05ac, 0, 0x0222, MODEL_APPLETOUCH },
- { 0x05ac, 0x0223, 0x0228, MODEL_UNIBODY_MACBOOK },
- { 0x05ac, 0x0229, 0x022b, MODEL_APPLETOUCH },
- { 0x05ac, 0x022c, 0xffff, MODEL_UNIBODY_MACBOOK },
- { 0, 0, 0, 0 }
-};
-
-static enum touchpad_model
-tp_get_model(struct evdev_device *device)
-{
- struct model_lookup_t *lookup;
- uint16_t vendor = libevdev_get_id_vendor(device->evdev);
- uint16_t product = libevdev_get_id_product(device->evdev);
-
- for (lookup = model_lookup_table; lookup->vendor; lookup++) {
- if (lookup->vendor == vendor &&
- lookup->product_start <= product &&
- product <= lookup->product_end)
- return lookup->model;
- }
- return MODEL_UNKNOWN;
-}
-
struct evdev_dispatch *
evdev_mt_touchpad_create(struct evdev_device *device)
{
@@ -2129,8 +2104,6 @@ evdev_mt_touchpad_create(struct evdev_device *device)
if (!tp)
return NULL;
- tp->model = tp_get_model(device);
-
if (tp_init(tp, device) != 0) {
tp_interface_destroy(&tp->base);
return NULL;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index f42fb02d..eb6702d3 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -227,7 +227,6 @@ struct tp_dispatch {
bool has_mt;
bool semi_mt;
bool reports_distance; /* does the device support true hovering */
- enum touchpad_model model;
unsigned int num_slots; /* number of slots */
unsigned int ntouches; /* no slots inc. fakes */
@@ -396,6 +395,7 @@ struct normalized_coords
tp_filter_motion(struct tp_dispatch *tp,
const struct normalized_coords *unaccelerated,
uint64_t time);
+
struct normalized_coords
tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
const struct normalized_coords *unaccelerated,
diff --git a/src/evdev.c b/src/evdev.c
index 85ca640a..82359237 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1663,6 +1663,7 @@ evdev_read_model_flags(struct evdev_device *device)
{ "LIBINPUT_MODEL_SYNAPTICS_SERIAL_TOUCHPAD", EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD },
{ "LIBINPUT_MODEL_JUMPING_SEMI_MT", EVDEV_MODEL_JUMPING_SEMI_MT },
{ "LIBINPUT_MODEL_ELANTECH_TOUCHPAD", EVDEV_MODEL_ELANTECH_TOUCHPAD },
+ { "LIBINPUT_MODEL_APPLE_INTERNAL_KEYBOARD", EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD },
{ NULL, EVDEV_MODEL_DEFAULT },
};
const struct model_map *m = model_map;
@@ -1869,7 +1870,8 @@ evdev_reject_device(struct evdev_device *device)
libevdev_has_event_code(evdev, EV_REL, REL_Y))
return -1;
- if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ^
+ if (!evdev_is_fake_mt_device(device) &&
+ libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ^
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
return -1;
@@ -2223,6 +2225,17 @@ evdev_set_device_group(struct evdev_device *device,
return 0;
}
+static inline void
+evdev_drain_fd(int fd)
+{
+ struct input_event ev[24];
+ size_t sz = sizeof ev;
+
+ while (read(fd, &ev, sz) == (int)sz) {
+ /* discard all pending events */
+ }
+}
+
struct evdev_device *
evdev_device_create(struct libinput_seat *seat,
struct udev_device *udev_device)
@@ -2256,6 +2269,8 @@ evdev_device_create(struct libinput_seat *seat,
libinput_device_init(&device->base, seat);
libinput_seat_ref(seat);
+ evdev_drain_fd(fd);
+
rc = libevdev_new_from_fd(fd, &device->evdev);
if (rc != 0)
goto err;
@@ -2705,6 +2720,8 @@ evdev_device_resume(struct evdev_device *device)
return -ENODEV;
}
+ evdev_drain_fd(fd);
+
device->fd = fd;
if (evdev_need_mtdev(device)) {
diff --git a/src/evdev.h b/src/evdev.h
index 09c05e9d..cf0eda9b 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -109,6 +109,7 @@ enum evdev_device_model {
EVDEV_MODEL_JUMPING_SEMI_MT = (1 << 10),
EVDEV_MODEL_ELANTECH_TOUCHPAD = (1 << 11),
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = (1 << 12),
+ EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD = (1 << 13),
};
struct mt_slot {
diff --git a/src/libinput-util.h b/src/libinput-util.h
index 25ab5f1e..93f7f0e4 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -38,6 +38,7 @@
#define VENDOR_ID_APPLE 0x5ac
#define VENDOR_ID_WACOM 0x56a
#define VENDOR_ID_SYNAPTICS_SERIAL 0x002
+#define PRODUCT_ID_APPLE_KBD_TOUCHPAD 0x273
#define PRODUCT_ID_SYNAPTICS_SERIAL 0x007
/* The HW DPI rate we normalize to before calculating pointer acceleration */
diff --git a/src/libinput.h b/src/libinput.h
index 3b90f0b0..1cf690b9 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -3249,6 +3249,8 @@ libinput_device_config_calibration_get_default_matrix(struct libinput_device *de
float matrix[6]);
/**
+ * @ingroup config
+ *
* The send-event mode of a device defines when a device may generate events
* and pass those events to the caller.
*/