From: Chris Bagwell <ch...@cnpbagwell.com>

Its natural for newer touchpads, such as Bamboo Touch,
to report buttons that overlap with mouse tools.

These will get remapped to pad device based on previous
patches but button count was not correctly initialed
to account for this remapping.

Now, make sure minimum nkeypad value is based on
maximum mouse buttons when it detects supporting
one or more mouse buttons.

Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com>
---
 src/wcmUSB.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index df8737b..b4f50c2 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -160,6 +160,11 @@ static unsigned short padkey_codes [] = {
 #define WCM_USB_MAX_MOUSE_BUTTONS 5
 #define WCM_USB_MAX_STYLUS_BUTTONS 3
 
+static unsigned short mouse_codes [] = {
+       BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_BACK, BTN_FORWARD,
+       BTN_SIDE, BTN_EXTRA
+};
+
 static struct
 {
        const unsigned int vendor_id;
@@ -335,13 +340,29 @@ static Bool usbWcmInit(InputInfoPtr pInfo, char* id, 
float *version)
                common->wcmResolX = common->wcmResolY = 1016;
        }
 
-       /* Find out supported button codes - except mouse button codes
-        * BTN_LEFT and BTN_RIGHT, which are always fixed. */
+       /* Find out supported button codes. */
        common->npadkeys = 0;
        for (i = 0; i < sizeof (padkey_codes) / sizeof (padkey_codes [0]); i++)
                if (ISBITSET (common->wcmKeys, padkey_codes [i]))
                        common->padkey_code [common->npadkeys++] = padkey_codes 
[i];
 
+       if (!(ISBITSET (common->wcmKeys, BTN_TOOL_MOUSE)))
+       {
+               /* If mouse buttons detected but no mouse tool
+                * then they must be associated with pad buttons.
+                */
+               for (i = sizeof(mouse_codes)/sizeof(mouse_codes[0]);
+                    i > 0; i--)
+                       if (ISBITSET(common->wcmKeys, mouse_codes[i]))
+                               break;
+
+               /* Make sure room for fixed map mouse buttons.  This
+                * means mappings may overlap with padkey_codes[].
+                */
+               if (i != 0 && common->npadkeys < WCM_USB_MAX_MOUSE_BUTTONS)
+                       common->npadkeys = WCM_USB_MAX_MOUSE_BUTTONS;
+       }
+
        /* nbuttons tracks maximum buttons on all tools (stylus/mouse).
         *
         * Mouse support left, middle, right, side, and extra side button.
-- 
1.7.3.2


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to