touchpad: always enable palm detection on apple touchpads

They don't set resolution so we can't calculate the size but we know they're
big enough to need palm detection.

And fix the descriptor for the bcm5974. For some reason this was advertising
synaptics coordinates. Fix it to represent (one of) the apple touchpads.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2014-07-21 14:20:35 +10:00
parent f179c70bb5
commit 0915c2c51a
5 changed files with 29 additions and 16 deletions

View file

@ -521,7 +521,7 @@ tp_init_buttons(struct tp_dispatch *tp,
tp->buttons.motion_dist = diagonal * DEFAULT_BUTTON_MOTION_THRESHOLD;
if (libevdev_get_id_vendor(device->evdev) == 0x5ac) /* Apple */
if (libevdev_get_id_vendor(device->evdev) == VENDOR_ID_APPLE)
tp->buttons.use_clickfinger = true;
if (tp->buttons.is_clickpad && !tp->buttons.use_clickfinger) {

View file

@ -757,17 +757,20 @@ tp_init_palmdetect(struct tp_dispatch *tp,
tp->palm.right_edge = INT_MAX;
tp->palm.left_edge = INT_MIN;
/* We don't know how big the touchpad is */
if (device->abs.absinfo_x->resolution == 1)
return 0;
width = abs(device->abs.absinfo_x->maximum -
device->abs.absinfo_x->minimum);
/* Enable palm detection on touchpads >= 80 mm. Anything smaller
probably won't need it, until we find out it does */
if (width/device->abs.absinfo_x->resolution < 80)
return 0;
/* Apple touchpads are always big enough to warrant palm detection */
if (evdev_device_get_id_vendor(device) != VENDOR_ID_APPLE) {
/* We don't know how big the touchpad is */
if (device->abs.absinfo_x->resolution == 1)
return 0;
/* Enable palm detection on touchpads >= 80 mm. Anything smaller
probably won't need it, until we find out it does */
if (width/device->abs.absinfo_x->resolution < 80)
return 0;
}
/* palm edges are 5% of the width on each side */
tp->palm.right_edge = device->abs.absinfo_x->maximum - width * 0.05;

View file

@ -33,6 +33,8 @@
#define TOUCHPAD_HISTORY_LENGTH 4
#define TOUCHPAD_MIN_SAMPLES 4
#define VENDOR_ID_APPLE 0x5ac
enum touchpad_event {
TOUCHPAD_EVENT_NONE = 0,
TOUCHPAD_EVENT_MOTION = (1 << 0),

View file

@ -65,13 +65,18 @@ static struct litest_device_interface interface = {
};
static struct input_absinfo absinfo[] = {
{ ABS_X, 1472, 5472, 0, 0, 75 },
{ ABS_Y, 1408, 4448, 0, 0, 129 },
{ ABS_PRESSURE, 0, 255, 0, 0, 0 },
{ ABS_TOOL_WIDTH, 0, 15, 0, 0, 0 },
{ ABS_MT_SLOT, 0, 1, 0, 0, 0 },
{ ABS_MT_POSITION_X, 1472, 5472, 0, 0, 75 },
{ ABS_MT_POSITION_Y, 1408, 4448, 0, 0, 129 },
{ ABS_X, -4824, 4824, 0, 0, 0 },
{ ABS_Y, -172, 4290, 0, 0, 0 },
{ ABS_PRESSURE, 0, 256, 5, 0, 0 },
{ ABS_TOOL_WIDTH, 0, 16, 0, 0, 0 },
{ ABS_MT_SLOT, 0, 15, 0, 0, 0 },
{ ABS_MT_POSITION_X, -4824, 4824, 17, 0, 0 },
{ ABS_MT_POSITION_Y, -172, 4290, 17, 0, 0 },
{ ABS_MT_ORIENTATION, -16384, 16384, 3276, 0, 0 },
{ ABS_MT_TOUCH_MAJOR, 0, 2048, 81, 0, 0 },
{ ABS_MT_TOUCH_MINOR, 0, 2048, 81, 0, 0 },
{ ABS_MT_WIDTH_MAJOR, 0, 2048, 81, 0, 0 },
{ ABS_MT_WIDTH_MINOR, 0, 2048, 81, 0, 0 },
{ ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
{ ABS_MT_PRESSURE, 0, 255, 0, 0, 0 },
{ .value = -1 },

View file

@ -1247,6 +1247,9 @@ touchpad_has_palm_detect_size(struct litest_device *dev)
double width, height;
int rc;
if (libinput_device_get_id_vendor(dev->libinput_device) == 0x5ac) /* Apple */
return 1;
rc = libinput_device_get_size(dev->libinput_device, &width, &height);
return rc == 0 && width >= 80;