From: Ping Cheng <[email protected]>

They said using BTN_TOOL_FINGER is too confusing. But we still
need to configure those tablet buttons and strips/ring. Let's
detect the actual buttons we are going to receive to determine
the existence of a pad tool.

BTN_0 and BTN_FORWARD are the two unique BTN_s that we use for
tablet buttons in the kernel driver.

Signed-off-by: Ping Cheng <[email protected]>
---
 src/wcmUSB.c            |    3 ++-
 src/wcmValidateDevice.c |   41 ++++++++++++++++++++++++-----------------
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 4d8a0fb..98d3c05 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -846,7 +846,8 @@ static struct
        { CURSOR_ID, BTN_TOOL_LENS      },
        { TOUCH_ID,  BTN_TOOL_DOUBLETAP },
        { TOUCH_ID,  BTN_TOOL_TRIPLETAP },
-       { PAD_ID,    BTN_TOOL_FINGER    }
+       { PAD_ID,    BTN_FORWARD        },
+       { PAD_ID,    BTN_0              }
 };
 
 #define MOD_BUTTONS(bit, value) do { \
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index 0968991..0adcab3 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -120,20 +120,20 @@ ret:
 static struct
 {
        const char* type;
-       __u16 tool;
+       __u16 tool [2];
 } wcmType [] =
 {
-       { "stylus", BTN_TOOL_PEN       },
-       { "eraser", BTN_TOOL_RUBBER    },
-       { "cursor", BTN_TOOL_MOUSE     },
-       { "touch",  BTN_TOOL_DOUBLETAP },
-       { "pad",    BTN_TOOL_FINGER    }
+       { "stylus", { BTN_TOOL_PEN,       0     } },
+       { "eraser", { BTN_TOOL_RUBBER,    0     } },
+       { "cursor", { BTN_TOOL_MOUSE,     0     } },
+       { "touch",  { BTN_TOOL_DOUBLETAP, 0     } },
+       { "pad",    { BTN_FORWARD,        BTN_0 } }
 };
 
 /* validate tool type for device/product */
 Bool wcmIsAValidType(InputInfoPtr pInfo, const char* type)
 {
-       int j, ret = FALSE;
+       int j, k, ret = FALSE;
        WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
        WacomCommonPtr common = priv->common;
        char* dsource = xf86CheckStrOption(pInfo->options, "_source", "");
@@ -146,17 +146,24 @@ Bool wcmIsAValidType(InputInfoPtr pInfo, const char* type)
        {
                if (!strcmp(wcmType[j].type, type))
                {
-                       if (ISBITSET (common->wcmKeys, wcmType[j].tool))
+                       for (k = 0; k < 2; k++)
                        {
-                               ret = TRUE;
-                               break;
-                       }
-                       else if (!strlen(dsource)) /* an user defined type */
-                       {
-                               /* assume it is a valid type */
-                               SETBIT(common->wcmKeys, wcmType[j].tool);
-                               ret = TRUE;
-                               break;
+                               if (!wcmType[j].tool[k])
+                               {
+                                       break;
+                               }
+                               if (ISBITSET (common->wcmKeys, 
wcmType[j].tool[k]))
+                               {
+                                       ret = TRUE;
+                                       break;
+                               }
+                               else if (!strlen(dsource)) /* an user defined 
type */
+                               {
+                                       /* assume it is a valid type */
+                                       SETBIT(common->wcmKeys, 
wcmType[j].tool[k]);
+                                       ret = TRUE;
+                                       break;
+                               }
                        }
                }
        }
-- 
1.7.2.3


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to