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

common->tablet_id is used in wcmInit() to decide things
like defaulting to relative mode for bamboo P&T's but
it is not set until after return from first call to
wcmInit().

Now qeury and store the tablet_id at same time that we are
discoverying its other features.

Call to get USB product ID is no longer needed in usbWcmInit()
since tablet_id contains correct value.

Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com>
---
 src/wcmConfig.c         |    9 +++++++--
 src/wcmUSB.c            |   34 +++++++++++++---------------------
 src/wcmValidateDevice.c |   33 +++++++++++++++++++++++++++++++--
 3 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 30dafe1..b5d07f2 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -34,7 +34,8 @@ extern int wcmNeedAutoHotplug(LocalDevicePtr local,
 extern int wcmAutoProbeDevice(LocalDevicePtr local);
 extern int wcmParseOptions(LocalDevicePtr local, unsigned long* keys);
 extern void wcmHotplugOthers(LocalDevicePtr local, unsigned long* keys);
-extern int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys);
+extern int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys,
+                            int* tablet_id);
 
 static int wcmAllocate(LocalDevicePtr local, char* name, int flag);
 
@@ -323,6 +324,7 @@ static LocalDevicePtr wcmInit(InputDriverPtr drv, IDevPtr 
dev, int flags)
        static int      numberWacom = 0;
        int             need_hotplug = 0;
        unsigned long   keys[NBITS(KEY_MAX)];
+       int             tablet_id = 0;
 
        gWacomModule.wcmDrv = drv;
 
@@ -338,7 +340,7 @@ static LocalDevicePtr wcmInit(InputDriverPtr drv, IDevPtr 
dev, int flags)
        xf86CollectInputOptions(local, default_options, NULL);
 
        /* initialize supported keys */
-       wcmDeviceTypeKeys(local, keys);
+       wcmDeviceTypeKeys(local, keys, &tablet_id);
 
        device = xf86SetStrOption(local->options, "Device", NULL);
        type = xf86FindOptionValue(local->options, "Type");
@@ -365,6 +367,9 @@ static LocalDevicePtr wcmInit(InputDriverPtr drv, IDevPtr 
dev, int flags)
 
        common->wcmDevice = device;
 
+       /* Hardware specific initialization relies on tablet_id */
+       common->tablet_id = tablet_id;
+
        /* Auto-probe the device if required, otherwise just noop. */
        if (numberWacom)
                if (!wcmAutoProbeDevice(local))
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 954af06..3d0ec45 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -503,7 +503,6 @@ static struct
 Bool usbWcmInit(LocalDevicePtr local, char* id, float *version)
 {
        int i;
-       struct input_id sID;
        unsigned long keys[NBITS(KEY_MAX)] = {0};
        WacomDevicePtr priv = (WacomDevicePtr)local->private;
        WacomCommonPtr common = priv->common;
@@ -511,8 +510,7 @@ Bool usbWcmInit(LocalDevicePtr local, char* id, float 
*version)
        DBG(1, priv, "initializing USB tablet\n");
        *version = 0.0;
 
-       /* fetch vendor, product, and model name */
-       ioctl(local->fd, EVIOCGID, &sID);
+       /* fetch model name */
        ioctl(local->fd, EVIOCGNAME(sizeof(id)), id);
 
        /* retrieve tool type, device type and buttons from the kernel */
@@ -522,26 +520,20 @@ Bool usbWcmInit(LocalDevicePtr local, char* id, float 
*version)
                return FALSE;
        }
 
-       /* vendor is wacom */
-       if (sID.vendor == WACOM_VENDOR_ID)
-       {
-               common->tablet_id = sID.product;
-
-               for (i = 0; i < sizeof (WacomModelDesc) / sizeof 
(WacomModelDesc [0]); i++)
-                       if (common->tablet_id == WacomModelDesc [i].model_id)
-                       {
-                               common->wcmModel = WacomModelDesc [i].model;
-                               common->wcmResolX = WacomModelDesc [i].xRes;
-                               common->wcmResolY = WacomModelDesc [i].yRes;
-                       }
-
-               if (common->wcmModel &&
-                       strstr(common->wcmModel->name, "TabletPC"))
+       for (i = 0; i < sizeof (WacomModelDesc) / sizeof (WacomModelDesc [0]); 
i++)
+               if (common->tablet_id == WacomModelDesc [i].model_id)
                {
-                       /* For penabled Tablet PCs, Tablet PC Button
-                        * are on by default */
-                       common->wcmTPCButtonDefault = 1;
+                       common->wcmModel = WacomModelDesc [i].model;
+                       common->wcmResolX = WacomModelDesc [i].xRes;
+                       common->wcmResolY = WacomModelDesc [i].yRes;
                }
+
+       if (common->wcmModel &&
+           strstr(common->wcmModel->name, "TabletPC"))
+       {
+               /* For penabled Tablet PCs, Tablet PC Button
+                * are on by default */
+               common->wcmTPCButtonDefault = 1;
        }
 
        if (!common->wcmModel)
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index 07632de..271f918 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -36,7 +36,8 @@ void wcmHotplugOthers(LocalDevicePtr local, unsigned long* 
keys);
 int wcmAutoProbeDevice(LocalDevicePtr local);
 int wcmParseOptions(LocalDevicePtr local, unsigned long* keys);
 int wcmIsDuplicate(char* device, LocalDevicePtr local);
-int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys);
+int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys,
+                     int* tablet_id);
 
 /* wcmCheckSource - Check if there is another source defined this device
  * before or not: don't add the tool by hal/udev if user has defined at least
@@ -184,7 +185,8 @@ Bool wcmIsAValidType(const char* type, unsigned long* keys)
    device ID. This matching only works for wacom devices (serial ID of
    WACf), all others are simply assumed to be pen + erasor.
  */
-int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys)
+int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* keys,
+                     int* tablet_id)
 {
        int ret = 1;
        int fd = -1;
@@ -201,6 +203,8 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* 
keys)
                return 0;
        }
 
+       *tablet_id = 0;
+
        /* serial ISDV4 devices */
        if (ioctl(fd, TIOCGSERIAL, &tmp) == 0)
        {
@@ -248,9 +252,25 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* 
keys)
                        keys[LONG(BTN_TOOL_PEN)] &= ~BIT(BTN_TOOL_PEN);
                        keys[LONG(BTN_TOOL_RUBBER)] &= ~BIT(BTN_TOOL_RUBBER);
                }
+
+               /* 0x9a and 0x9f are only detected by communicating
+                * with device.  This means tablet_id will be updated/refined
+                * at later stage and true knowledge of capacitive
+                * support will be delayed until that point.
+                */
+               if (id >= 0x0 && id <= 0x7)
+                       *tablet_id = 0x90;
+               else if (id >= 0x8 && id <= 0xa)
+                       *tablet_id = 0x93;
+               else if (id >= 0xb && id <= 0xe)
+                       *tablet_id = 0xe3;
+               else if (id == 0x10)
+                       *tablet_id = 0xe2;
        }
        else /* USB devices */
        {
+               struct input_id wacom_id;
+
                if (ioctl(fd, EVIOCGBIT(EV_KEY, (sizeof(unsigned long)
                         * NBITS(KEY_MAX))), keys) < 0)
                {
@@ -258,6 +278,15 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned long* 
keys)
                                "ioctl USB key bits.\n", local->name);
                        ret = 0;
                }
+
+               if (ioctl(fd, EVIOCGID, &wacom_id) < 0)
+               {
+                       xf86Msg(X_ERROR, "%s: wcmDeviceTypeKeys unable to "
+                               "ioctl Device ID.\n", local->name);
+                       ret = 0;
+               }
+               else
+                       *tablet_id = wacom_id.product;
        }
        close(fd);
        return ret;
-- 
1.6.6


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to