[PATCH v2 libinput 4/5] pad: implement wacom pad support

Peter Hutterer peter.hutterer at who-t.net
Tue May 3 06:47:21 UTC 2016


[this got stuck in my drafts folder, sorry]

On Thu, Apr 14, 2016 at 03:33:53PM -0700, Jason Gerecke wrote:
> On 04/10/2016 09:15 PM, Peter Hutterer wrote:
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > Adjustments for the new API in 2/5
> > +static void
> > +pad_init_buttons(struct pad_dispatch *pad,
> > +		 struct evdev_device *device)
> > +{
> > +	unsigned int code;
> > +	size_t i;
> > +	int map = 0;
> > +
> > +	for (i = 0; i < ARRAY_LENGTH(pad->button_map); i++)
> > +		pad->button_map[i] = -1;
> > +
> > +	for (code = BTN_0; code < BTN_MOUSE; code++) {
> > +		if (libevdev_has_event_code(device->evdev, EV_KEY, code))
> > +			pad->button_map[code] = map++;
> > +	}
> > +
> > +	for (code = BTN_A; code < BTN_DIGI; code++) {
> > +		if (libevdev_has_event_code(device->evdev, EV_KEY, code))
> > +			pad->button_map[code] = map++;
> > +	}
> > +
> > +	pad->nbuttons = map;
> > +}
> > +
> 
> For the sake of the compatibility with future devices, I'd recommend
> more strictly following the button ranges used by the kernel:
> http://lxr.free-electrons.com/source/drivers/hid/wacom_wac.c#L2712
> 
> Also, note that you're missing coverage of BTN_BASE and BTN_BASE2.

good point, I squashed this diff in:

diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c
index 8c64830..ad6ead8 100644
--- a/src/evdev-tablet-pad.c
+++ b/src/evdev-tablet-pad.c
@@ -459,12 +459,18 @@ pad_init_buttons(struct pad_dispatch *pad,
 	for (i = 0; i < ARRAY_LENGTH(pad->button_map); i++)
 		pad->button_map[i] = -1;
 
-	for (code = BTN_0; code < BTN_MOUSE; code++) {
+	/* we match wacom_report_numbered_buttons() from the kernel */
+	for (code = BTN_0; code < BTN_0 + 10; code++) {
 		if (libevdev_has_event_code(device->evdev, EV_KEY, code))
 			pad->button_map[code] = map++;
 	}
 
-	for (code = BTN_A; code < BTN_DIGI; code++) {
+	for (code = BTN_A; code < BTN_A + 6; code++) {
+		if (libevdev_has_event_code(device->evdev, EV_KEY, code))
+			pad->button_map[code] = map++;
+	}
+
+	for (code = BTN_BASE; code < BTN_BASE + 2; code++) {
 		if (libevdev_has_event_code(device->evdev, EV_KEY, code))
 			pad->button_map[code] = map++;
 	}


Cheers,
   Peter


More information about the wayland-devel mailing list