Signed-off-by: Peter Hutterer <[email protected]>
---
 src/wcmConfig.c |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 3fef429..c46eabf 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -376,13 +376,19 @@ static Bool wcmMatchDevice(LocalDevicePtr pLocal)
        return 0;
 }
 
+/**
+ * Detect the device's device class. We only support two classes right now,
+ * USB and ISDV4. Let each class try to detect the type by checking what's
+ * behind the fd.
+ */
 static Bool
-wcmInitModel(LocalDevicePtr local)
+wcmDetectDeviceClass(const LocalDevicePtr local)
 {
        WacomDevicePtr priv = (WacomDevicePtr)local->private;
        WacomCommonPtr common = priv->common;
-       char id[BUFFER_SIZE];
-       float version;
+
+       if (common->wcmDevCls)
+               return TRUE;
 
        /* Bluetooth is also considered as USB */
        if (gWacomISDV4Device.Detect(local))
@@ -390,11 +396,18 @@ wcmInitModel(LocalDevicePtr local)
        else if (gWacomUSBDevice.Detect(local))
                common->wcmDevCls = &gWacomUSBDevice;
        else
-       {
-               xf86Msg(X_ERROR, "%s: wcmInitModel found undetectable "
-                       " %s \n", local->name, common->wcmDevice);
-               return FALSE;
-       }
+               xf86Msg(X_ERROR, "%s: cannot identify device class.\n", 
local->name);
+
+       return (common->wcmDevCls == NULL);
+}
+
+static Bool
+wcmInitModel(LocalDevicePtr local)
+{
+       WacomDevicePtr priv = (WacomDevicePtr)local->private;
+       WacomCommonPtr common = priv->common;
+       char id[BUFFER_SIZE];
+       float version;
 
        /* Initialize the tablet */
        if(common->wcmDevCls->Init(local, id, &version) != Success ||
@@ -498,6 +511,10 @@ static LocalDevicePtr wcmPreInit(InputDriverPtr drv, 
IDevPtr dev, int flags)
        if (!wcmSetType(local, type))
                goto SetupProc_fail;
 
+       /* Try to guess whether it's USB or ISDV4 */
+       if (!wcmDetectDeviceClass(local))
+               goto SetupProc_fail;
+
        /* Process the common options. */
        xf86ProcessCommonOptions(local, local->options);
        if (!wcmParseOptions(local, need_hotplug))
-- 
1.7.0.1


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to