usbInitToolType retrieves device type from the kernel when tool
is on the tablet when X server starts. No need to do it again later.

Signed-off-by: Ping Cheng <pi...@wacom.com>
---
 src/wcmUSB.c |   72 ++++------------------------------------------------------
 1 file changed, 5 insertions(+), 67 deletions(-)

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 75caa6b..980dac3 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. <lep...@xfree86.org>
- * Copyright 2002-2010 by Ping Cheng, Wacom. <pi...@wacom.com>
+ * Copyright 2002-2013 by Ping Cheng, Wacom. <pi...@wacom.com>
  *                                                                            
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -1223,25 +1223,6 @@ static void usbParseAbsMTEvent(WacomCommonPtr common, 
struct input_event *event)
        (&common->wcmChannel[private->wcmMTChannel])->dirty |= change;
 }
 
-static struct
-{
-       unsigned long device_type;
-       unsigned long tool_key;
-} wcmTypeToKey [] =
-{
-       { STYLUS_ID, BTN_TOOL_PEN       },
-       { STYLUS_ID, BTN_TOOL_PENCIL    },
-       { STYLUS_ID, BTN_TOOL_BRUSH     },
-       { STYLUS_ID, BTN_TOOL_AIRBRUSH  },
-       { ERASER_ID, BTN_TOOL_RUBBER    },
-       { CURSOR_ID, BTN_TOOL_MOUSE     },
-       { CURSOR_ID, BTN_TOOL_LENS      },
-       { TOUCH_ID,  BTN_TOOL_DOUBLETAP },
-       { TOUCH_ID,  BTN_TOOL_TRIPLETAP },
-       { PAD_ID,    BTN_FORWARD        },
-       { PAD_ID,    BTN_0              }
-};
-
 static void usbParseKeyEvent(WacomCommonPtr common,
                            struct input_event *event, int channel_number)
 {
@@ -1434,6 +1415,8 @@ static void usbParseBTNEvent(WacomCommonPtr common,
                        }
                        if (nkeys >= usbdata->npadkeys)
                                change = 0;
+                       else if (!ds->device_type) /* expresskey pressed at 
startup */
+                               ds->device_type = PAD_ID;
        }
 
        channel->dirty |= change;
@@ -1625,9 +1608,9 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
        ds = &common->wcmChannel[channel].work;
        dslast = common->wcmChannel[channel].valid.state;
 
-       /* no device type? tool was on the tablet at startup, force type and
-          proximity */
+       /* no device type? */
        if (!ds->device_type && private->wcmDeviceType) {
+               /* tool was on tablet at startup, force type and proximity */
                ds->device_type = private->wcmDeviceType;
                ds->proximity = 1;
        }
@@ -1670,54 +1653,9 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
                {
                        usbParseKeyEvent(common, event, channel);
                        usbParseBTNEvent(common, event, private->wcmBTNChannel);
-
-                       /* send PAD events now for generic devices. Otherwise,
-                        * they are filtered out when there are no motion 
events.
-                        */
-                       if ((common->wcmProtocolLevel == WCM_PROTOCOL_GENERIC)
-                           && 
(common->wcmChannel[private->wcmBTNChannel].dirty))
-                        {
-                               DBG(10, common, "Dirty flag set on channel %d; "
-                                   "sending event.\n", private->wcmBTNChannel);
-                               
common->wcmChannel[private->wcmBTNChannel].dirty = FALSE;
-                               wcmEvent(common, private->wcmBTNChannel,
-                                        
&common->wcmChannel[private->wcmBTNChannel].work);
-                       }
                }
        } /* next event */
 
-       /* device type unknown? Tool may be on the tablet when X starts. */
-       if (!ds->device_type && !dslast.proximity)
-       {
-               unsigned long keys[NBITS(KEY_MAX)] = { 0 };
-               int rc;
-
-               if (!ds->proximity) {
-                       DBG(3, common, "Unknown out-of-prox device leaving 
prox. Ignoring.\n");
-                       return;
-               }
-
-               /* Retrieve the type by asking a resend from the kernel */
-               rc = ioctl(common->fd, EVIOCGKEY(sizeof(keys)), keys);
-               if (rc == -1)
-               {
-                       LogMessageVerbSigSafe(X_ERROR, 0,
-                                             "%s: failed to retrieve key 
bits\n",
-                                             pInfo->name);
-                       return;
-               }
-
-               for (i = 0; i < ARRAY_SIZE(wcmTypeToKey); i++)
-               {
-                       if (ISBITSET(keys, wcmTypeToKey[i].tool_key))
-                       {
-                               ds->device_type = wcmTypeToKey[i].device_type;
-                               ds->proximity = 1;
-                               break;
-                       }
-               }
-       }
-
        /* DTF720 and DTF720a don't support eraser */
        if (((common->tablet_id == 0xC0) || (common->tablet_id == 0xC2)) && 
                (ds->device_type == ERASER_ID)) 
-- 
1.7.10.4


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to