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

This allows new tochpad/touchscreens to be supported
without modifications to xf86-input-wacom.

BTN_TOOL_FINGER/DOUBLETAP/TRIPLETAP have incompatible meanings
between generic and protocol 4/5 devices.  Add logic to detect
generic devices very early and override default value of
wcmProtocolLevel to help out wcmKeys parsing.

Newer touchscreens will work in relative mode because currently only
tablet_id informs this.  Generic protocols may eventually have
something in kernel that can be queried for touchscreen vs.
touchpad.

Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com>
---
 src/wcmUSB.c            |   15 +++++++++++++++
 src/wcmValidateDevice.c |   33 +++++++++++++++++++++------------
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index c25e67c..765b41e 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -1364,6 +1364,7 @@ static int usbProbeKeys(InputInfoPtr pInfo)
        struct input_id wacom_id;
        WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
        WacomCommonPtr  common = priv->common;
+       unsigned long abs[NBITS(ABS_MAX)] = {0};
 
        if (ioctl(pInfo->fd, EVIOCGBIT(EV_KEY, (sizeof(unsigned long)
                                                * NBITS(KEY_MAX))), 
common->wcmKeys) < 0)
@@ -1380,6 +1381,20 @@ static int usbProbeKeys(InputInfoPtr pInfo)
                return 0;
        }
 
+        if (ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(abs)), abs) < 0)
+       {
+               xf86Msg(X_ERROR, "%s: usbProbeKeys unable to ioctl "
+                       "abs bits.\n", pInfo->name);
+               return 0;
+       }
+
+       /* The wcmKeys stored above have different meaning for generic
+        * protocol.  Detect that and change default protocol 4 to
+        * generic.
+        */
+       if (!ISBITSET(abs, ABS_MISC))
+               common->wcmProtocolLevel = WCM_PROTOCOL_GENERIC;
+
        return wacom_id.product;
 }
 
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index b7312a3..e3764a4 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -256,28 +256,16 @@ int wcmDeviceTypeKeys(InputInfoPtr pInfo)
                case 0xE3: /* TPC with 2FGT */
                        priv->common->tablet_type = WCM_TPC;
                        priv->common->tablet_type |= WCM_LCD;
-                       /* fall through */
-               case 0xD0:  /* Bamboo with 2FGT */
-               case 0xD1:  /* Bamboo with 2FGT */
-               case 0xD2:  /* Bamboo with 2FGT */
-               case 0xD3:  /* Bamboo with 2FGT */
-               case 0xD8:  /* Bamboo with 2FGT */
-               case 0xDA:  /* Bamboo with 2FGT */
-               case 0xDB:  /* Bamboo with 2FGT */
-                       priv->common->tablet_type |= WCM_2FGT;
                        break;
 
                case 0x93: /* TPC with 1FGT */
                case 0x9A: /* TPC with 1FGT */
-                       priv->common->tablet_type = WCM_1FGT;
-                       /* fall through */
                case 0x90: /* TPC */
                        priv->common->tablet_type |= WCM_TPC;
                        priv->common->tablet_type |= WCM_LCD;
                        break;
 
                case 0x9F:
-                       priv->common->tablet_type = WCM_1FGT;
                        priv->common->tablet_type |= WCM_LCD;
                        break;
 
@@ -291,6 +279,27 @@ int wcmDeviceTypeKeys(InputInfoPtr pInfo)
                priv->common->tablet_type |= WCM_PAD;
        }
 
+       /* This handles both protocol 4 and 5 meanings of wcmKeys */
+       if (common->wcmProtocolLevel == WCM_PROTOCOL_4)
+       {
+               /* TRIPLETAP means 2 finger touch */
+               /* DOUBLETAP without TRIPLETAP means 1 finger touch */
+               if (ISBITSET(common->wcmKeys, BTN_TOOL_TRIPLETAP))
+                       priv->common->tablet_type |= WCM_2FGT;
+               else if (ISBITSET(common->wcmKeys, BTN_TOOL_DOUBLETAP))
+                       priv->common->tablet_type |= WCM_1FGT;
+       }
+
+       if (common->wcmProtocolLevel == WCM_PROTOCOL_GENERIC)
+       {
+               /* DOUBLETAP means 2 finger touch */
+               /* FINGER without DOUBLETAP means 1 finger touch */
+               if (ISBITSET(common->wcmKeys, BTN_TOOL_DOUBLETAP))
+                       priv->common->tablet_type |= WCM_2FGT;
+               else if (ISBITSET(common->wcmKeys, BTN_TOOL_FINGER))
+                       priv->common->tablet_type |= WCM_1FGT;
+       }
+
        return ret;
 }
 
-- 
1.7.3.4


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to