This is only the BaudRate for ISDV4 devices but nonetheless, it's nicer abstracted this way.
Signed-off-by: Peter Hutterer <[email protected]> --- src/wcmISDV4.c | 29 +++++++++++++++++++++++++++++ src/wcmUSB.c | 1 + src/wcmValidateDevice.c | 22 ++++++---------------- src/xf86WacomDefs.h | 1 + 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c index 61275d2..041e6c8 100644 --- a/src/wcmISDV4.c +++ b/src/wcmISDV4.c @@ -35,6 +35,7 @@ #define RESET_RELATIVE(ds) do { (ds).relwheel = 0; } while (0) static Bool isdv4Detect(LocalDevicePtr); +static Bool isdv4ParseOptions(LocalDevicePtr local); static Bool isdv4Init(LocalDevicePtr, char* id, float *version); static void isdv4InitISDV4(WacomCommonPtr, const char* id, float version); static int isdv4GetRanges(LocalDevicePtr); @@ -59,6 +60,7 @@ static inline int isdv4ParseCoordinateData(const unsigned char *buffer, const si WacomDeviceClass gWacomISDV4Device = { isdv4Detect, + isdv4ParseOptions, isdv4Init, }; @@ -155,6 +157,33 @@ static Bool isdv4Detect(LocalDevicePtr local) } /***************************************************************************** + * isdv4ParseOptions -- parse ISDV4-specific options + ****************************************************************************/ +static Bool isdv4ParseOptions(LocalDevicePtr local) +{ + WacomDevicePtr priv = (WacomDevicePtr)local->private; + WacomCommonPtr common = priv->common; + int baud; + + baud = xf86SetIntOption(local->options, "BaudRate", 38400); + + switch (baud) + { + case 38400: + case 19200: + common->wcmISDV4Speed = baud; + break; + default: + xf86Msg(X_ERROR, "%s: Illegal speed value " + "(must be 19200 or 38400).", + local->name); + return FALSE; + } + + return TRUE; +} + +/***************************************************************************** * isdv4Init -- ****************************************************************************/ diff --git a/src/wcmUSB.c b/src/wcmUSB.c index 62a1d38..bd7b113 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -57,6 +57,7 @@ static int usbChooseChannel(WacomCommonPtr common, int serial); WacomDeviceClass gWacomUSBDevice = { usbDetect, + NULL, /* no USB-specific options */ usbWcmInit, }; diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c index 0a08a75..08915bd 100644 --- a/src/wcmValidateDevice.c +++ b/src/wcmValidateDevice.c @@ -422,7 +422,7 @@ int wcmParseOptions(LocalDevicePtr local, int hotplugged) WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; char *s, b[12]; - int i, oldButton, baud; + int i, oldButton; WacomToolPtr tool = NULL; WacomToolAreaPtr area = NULL; @@ -694,21 +694,6 @@ int wcmParseOptions(LocalDevicePtr local, int hotplugged) priv->button[i] = xf86SetIntOption(local->options, b, priv->button[i]); } - baud = xf86SetIntOption(local->options, "BaudRate", 38400); - - switch (baud) - { - case 38400: - case 19200: - common->wcmISDV4Speed = baud; - break; - default: - xf86Msg(X_ERROR, "%s: Illegal speed value " - "(must be 19200 or 38400).", - local->name); - break; - } - s = xf86SetStrOption(local->options, "Twinview", NULL); if (s && xf86NameCmp(s, "none") == 0) priv->twinview = TV_NONE; @@ -735,6 +720,11 @@ int wcmParseOptions(LocalDevicePtr local, int hotplugged) else priv->numScreen = screenInfo.numScreens; + /* Now parse class-specific options */ + if (common->wcmDevCls->ParseOptions && + !common->wcmDevCls->ParseOptions(local)) + goto error; + return 1; error: free(area); diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index b2afd93..4c61856 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -333,6 +333,7 @@ struct _WacomChannel struct _WacomDeviceClass { Bool (*Detect)(LocalDevicePtr local); /* detect device */ + Bool (*ParseOptions)(LocalDevicePtr local); /* parse class-specific options */ Bool (*Init)(LocalDevicePtr local, char* id, float *version); /* initialize device */ }; -- 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
