From: Chris Bagwell <ch...@cnpbagwell.com> usbParseEvent() is for queue'ing up events until a full sync window occurs. It was also selecting a channel related to all queued events.
Move channel selection logic to function that processes all events (usbParseChannel()) since its more related to that logic than to queuing logic. Also, rename to usbDispatchEvents() since some WCM_PROTOCOL_GENERIC devices can send events that need to be placed in multiple channels. Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com> Acked-by: Peter Hutterer <peter.hutte...@who-t.net> --- src/wcmUSB.c | 46 ++++++++++++++++++++++++++-------------------- 1 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/wcmUSB.c b/src/wcmUSB.c index c6cc98c..77236c4 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -52,7 +52,7 @@ static int usbParse(InputInfoPtr pInfo, const unsigned char* data, int len); static int usbDetectConfig(InputInfoPtr pInfo); static void usbParseEvent(InputInfoPtr pInfo, const struct input_event* event); -static void usbParseChannel(InputInfoPtr pInfo, int channel); +static void usbDispatchEvents(InputInfoPtr pInfo); static int usbChooseChannel(WacomCommonPtr common); WacomDeviceClass gWacomUSBDevice = @@ -865,7 +865,6 @@ static int usbChooseChannel(WacomCommonPtr common) static void usbParseEvent(InputInfoPtr pInfo, const struct input_event* event) { - int channel; WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; WacomCommonPtr common = priv->common; wcmUSBData* private = common->private; @@ -937,20 +936,8 @@ static void usbParseEvent(InputInfoPtr pInfo, goto skipEvent; } - channel = usbChooseChannel(common); - - /* couldn't decide channel? invalid data */ - if (channel == -1) goto skipEvent; - - if (!common->wcmChannel[channel].work.proximity) - { - memset(&common->wcmChannel[channel],0,sizeof(WacomChannel)); - /* in case the in-prox event was missing */ - common->wcmChannel[channel].work.proximity = 1; - } - - /* dispatch event */ - usbParseChannel(pInfo,channel); + /* dispatch all queued events */ + usbDispatchEvents(pInfo); skipEvent: private->wcmEventCnt = 0; @@ -1205,15 +1192,16 @@ static void usbParseKeyEvent(WacomCommonPtr common, } } -static void usbParseChannel(InputInfoPtr pInfo, int channel) +static void usbDispatchEvents(InputInfoPtr pInfo) { int i; WacomDeviceState* ds; struct input_event* event; WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; WacomCommonPtr common = priv->common; - WacomChannelPtr pChannel = common->wcmChannel + channel; - WacomDeviceState dslast = pChannel->valid.state; + int channel; + WacomChannelPtr pChannel; + WacomDeviceState dslast; wcmUSBData* private = common->private; DBG(6, common, "%d events received\n", private->wcmEventCnt); @@ -1222,7 +1210,25 @@ static void usbParseChannel(InputInfoPtr pInfo, int channel) DBG(6, common, "no real events received\n"); return; } - DBG(6, common, "%d events received\n", private->wcmEventCnt); + + channel = usbChooseChannel(common); + + /* couldn't decide channel? invalid data */ + if (channel == -1) { + private->wcmEventCnt = 0; + return; + } + + pChannel = common->wcmChannel + channel; + dslast = pChannel->valid.state; + + if (!common->wcmChannel[channel].work.proximity) + { + memset(&common->wcmChannel[channel],0,sizeof(WacomChannel)); + + /* in case the in-prox event was missing */ + common->wcmChannel[channel].work.proximity = 1; + } /* all USB data operates from previous context except relative values*/ ds = &common->wcmChannel[channel].work; -- 1.7.3.1 ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel