[PATCH libinput v3 2/3] touchpad: Add code to get the touchpad model / manufacturer

Peter Hutterer peter.hutterer at who-t.net
Mon Nov 24 23:17:52 PST 2014


On Mon, Nov 24, 2014 at 12:16:05PM +0100, Hans de Goede wrote:
> This is useful to know in some cases, it is e.g. necessary to figure out
> which percentage of a touchpads range to use as edge for edge-scrolling.
> 
> Note this is a slightly cleaned up copy of the same code in
> xf86-input-synaptics.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>

pushed, thanks

   92d178f..6a4ceed  master -> master

Cheers,
   Peter

> ---
>  src/evdev-mt-touchpad.c | 36 ++++++++++++++++++++++++++++++++++++
>  src/evdev-mt-touchpad.h | 10 ++++++++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index 7a1c32d..6d4b583 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -1146,6 +1146,40 @@ tp_change_to_left_handed(struct evdev_device *device)
>  	device->buttons.left_handed = device->buttons.want_left_handed;
>  }
>  
> +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)
>  {
> @@ -1155,6 +1189,8 @@ 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_destroy(&tp->base);
>  		return NULL;
> diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> index 11c4d49..7f3ce49 100644
> --- a/src/evdev-mt-touchpad.h
> +++ b/src/evdev-mt-touchpad.h
> @@ -42,6 +42,15 @@ enum touchpad_event {
>  	TOUCHPAD_EVENT_BUTTON_RELEASE	= (1 << 2),
>  };
>  
> +enum touchpad_model {
> +	MODEL_UNKNOWN = 0,
> +	MODEL_SYNAPTICS,
> +	MODEL_ALPS,
> +	MODEL_APPLETOUCH,
> +	MODEL_ELANTECH,
> +	MODEL_UNIBODY_MACBOOK
> +};
> +
>  enum touch_state {
>  	TOUCH_NONE = 0,
>  	TOUCH_BEGIN,
> @@ -156,6 +165,7 @@ struct tp_dispatch {
>  	unsigned int slot;			/* current slot */
>  	bool has_mt;
>  	bool semi_mt;
> +	enum touchpad_model model;
>  
>  	unsigned int real_touches;		/* number of slots */
>  	unsigned int ntouches;			/* no slots inc. fakes */
> -- 
> 2.1.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list