On Mon, Aug 13, 2012 at 06:05:09PM -0700, Jason Gerecke wrote: > Making use of the new mouse button information present in my > "feature/pad-mousebutton" libwacom branch on github. After > building the list of buttons the old-fashioned way (which lets > us get away with the libwacom database being less complete than > the kernel database) we add any mouse buttons that libwacom is > aware of. > > Signed-off-by: Jason Gerecke <killert...@gmail.com> > --- > This patch uses the libwacom RFC patch I posted to the list on August > 2nd. With no activity on that particular patch, here's how xf86-input-wacom > would look making use of it. Again, please provide any feedback on this > or the previously-mentioned libwacom patch if you have concerns about > how this integration works.
hmm, not sure where this original patch ended up, but it took me quite a while to dig this out of my mailboxes. sorry about that, it got misfiled. > configure.ac | 3 +++ > src/Makefile.am | 3 ++- > src/wcmUSB.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- > 3 files changed, 45 insertions(+), 11 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 916c69e..f16d032 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -58,6 +58,9 @@ PKG_CHECK_MODULES(X11, x11 xi xrandr xinerama) > # Obtain compiler/linker options for libudev used by ISDV4 code > PKG_CHECK_MODULES(UDEV, libudev) > > +# Obtain compiler/linker options for libwacom > +PKG_CHECK_MODULES(WACOM, [libwacom >= 0.6]) > + > # X Server SDK location is required to install wacom header files > # This location is also relayed in the xorg-wacom.pc file > sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server` > diff --git a/src/Makefile.am b/src/Makefile.am > index b9fecc6..956af83 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -32,6 +32,7 @@ include common.mk > @DRIVER_NAME@_drv_ladir = @inputdir@ > > AM_CPPFLAGS=-I$(top_srcdir)/include/ > -AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) $(UDEV_CFLAGS) > +AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) $(UDEV_CFLAGS) $(WACOM_CFLAGS) > +LIBS = $(WACOM_LIBS) this should be @DRIVER_NAME@_drv_la_LIBADD = $(WACOM_LIBS) coincidentally, this likely also needs $(UDEV_LIBS) in the same line to avoid an issue like this: http://lists.freedesktop.org/archives/xorg-devel/2012-August/033130.html > @DRIVER_NAME@_drv_la_SOURCES = $(DRIVER_SOURCES) > diff --git a/src/wcmUSB.c b/src/wcmUSB.c > index 58a54af..f2dac68 100644 > --- a/src/wcmUSB.c > +++ b/src/wcmUSB.c > @@ -28,6 +28,8 @@ > #include <sys/utsname.h> > #include <linux/version.h> > > +#include <libwacom/libwacom.h> > + > #define MAX_USB_EVENTS 32 > > typedef struct { > @@ -371,6 +373,9 @@ static Bool usbWcmInit(InputInfoPtr pInfo, char* id, > float *version) > } > > if (IsPad(priv)) { > + WacomDeviceDatabase* db = libwacom_database_new(); > + WacomDevice* dev = libwacom_new_from_usbid(db, sID.vendor, > sID.product, NULL); > + diff is a bit hard to read, but I think you're leaking db and dev here. looks good in general, though I've just replied to the libwacom patch on the other thread re: WMOUSE_* button flags. again, sorry for the delay. Cheers, Peter > /* Find out supported button codes. */ > usbdata->npadkeys = 0; > for (i = 0; i < ARRAY_SIZE(padkey_codes); i++) { > @@ -380,14 +385,40 @@ static Bool usbWcmInit(InputInfoPtr pInfo, char* id, > float *version) > usbdata->npadkeys++; > } > } > - } > > - if (IsCursor(priv) || (IsPad(priv) && usbdata->npadkeys == 0)) { > - /* If no pad keys were detected, entertain the possibility that > any > - * mouse buttons which exist may belong to the pad (e.g. > Graphire4). > - * If we're wrong, this will over-state the capabilities of the > pad > - * but that shouldn't actually cause problems. > - */ > + /* Look for mouse buttons */ > + for (i = 0; dev && i < libwacom_get_num_buttons(dev); i++) { > + WacomButtonFlags flags = libwacom_get_button_flag(dev, > 'A' + i); > + switch (flags & WACOM_BUTTON_MOUSEBUTTON) { > + case WMOUSE_LEFT: > + priv->button_default[i] = 1; > + usbdata->padkey_code[i] = BTN_LEFT; > + usbdata->npadkeys++; > + break; > + case WMOUSE_MIDDLE: > + priv->button_default[i] = 2; > + usbdata->padkey_code[i] = BTN_MIDDLE; > + usbdata->npadkeys++; > + break; > + case WMOUSE_RIGHT: > + priv->button_default[i] = 3; > + usbdata->padkey_code[i] = BTN_RIGHT; > + usbdata->npadkeys++; > + break; > + case WMOUSE_BACK: > + priv->button_default[i] = 8; > + usbdata->padkey_code[i] = BTN_BACK; > + usbdata->npadkeys++; > + break; > + case WMOUSE_FORWARD: > + priv->button_default[i] = 9; > + usbdata->padkey_code[i] = BTN_FORWARD; > + usbdata->npadkeys++; > + break; > + } > + } > + } > + else if (IsCursor(priv)) { > for (i = 0; i < ARRAY_SIZE(mouse_codes); i++) > if (ISBITSET(common->wcmKeys, mouse_codes[i])) > usbdata->padkey_code [usbdata->npadkeys++] = > mouse_codes[i]; > @@ -404,14 +435,13 @@ static Bool usbWcmInit(InputInfoPtr pInfo, char* id, > float *version) > } > } > } > - > - if (IsPen(priv)) { > + else if (IsPen(priv)) { > priv->button_default[0] = 1; > priv->button_default[1] = 2; > priv->button_default[2] = 3; > } > > - if (IsTouch(priv)) { > + else if (IsTouch(priv)) { > /* We only simulate left and right click */ > priv->button_default[0] = 1; > priv->button_default[1] = 3; > -- > 1.7.11.4 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel