On Wed, Mar 16, 2011 at 03:55:51PM -0700, Ping Cheng wrote:
> This patch will need to be updated when XInput 2.1 is ready to
> process MT events.
>
> Signed-off-by: Ping Cheng <[email protected]>
> ---
> src/wcmUSB.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 60 insertions(+), 2 deletions(-)
>
> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
> index 3cc8bab..6fe5926 100644
> --- a/src/wcmUSB.c
> +++ b/src/wcmUSB.c
> @@ -1251,6 +1251,47 @@ static int usbParseBTNEvent(WacomCommonPtr common,
> return change;
> }
>
> +/***
> + * Retrieve the tool type from an USB data packet.
how? this is the point of the documentation, should say something like
"Retrieve the tool type from an USB data packet by looking at the event
codes. Specific event codes signal specific tool types"
> + *
> + * @param private A poitner to struct wcmUSBData to access device specific
> data.
typo
> + *
> + * @return devcie_type The device type comes with the data packet.
typo
> + * 0 is returned when type is found.
should probably be "when no type is found"
this is an example for using retval:
@retval 0 if no matching type is found
> + */
> +static int usbGetToolType(wcmUSBData *private)
can we name this "data"? it just happens to be "private" in the caller but
the function should make sense on its own.
also, since we dont use anthing but wcmEvents and wcmEventCnt, why not just
pass those two in (const for the event pointer)?
> +{
> + int i, device_type = 0;
> + struct input_event* event;
> +
> + for (i=0; i<private->wcmEventCnt; ++i)
spaces please
!device_type && i < private->wcmEventCnt seems sensible here to exit early.
> + {
> + event = private->wcmEvents + i;
> +
> + switch (event->code)
> + {
> + case BTN_TOOL_PEN:
> + case BTN_TOOL_PENCIL:
> + case BTN_TOOL_BRUSH:
> + case BTN_TOOL_AIRBRUSH:
> + device_type = STYLUS_ID;
> + break;
> +
> + case BTN_TOOL_FINGER:
> + case ABS_MT_SLOT:
> + case ABS_MT_TRACKING_ID:
> + device_type = TOUCH_ID;
> + break;
> +
> + case BTN_TOOL_RUBBER:
> + device_type = ERASER_ID;
> + break;
> + }
> + }
> + return device_type;
> +}
> +
> +
> static void usbDispatchEvents(InputInfoPtr pInfo)
> {
> int i;
> @@ -1258,13 +1299,30 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
> struct input_event* event;
> WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
> WacomCommonPtr common = priv->common;
> - int channel;
> + int channel, device_type = 0;
> int channel_change = 0, btn_channel_change = 0, mt_channel_change = 0;
> - WacomDeviceState dslast;
> + WacomDeviceState dslast = common->wcmChannel[0].valid.state;
one day, we should start using a macro/function for this. doesn't have to be
today though ;)
Cheers,
Peter
> wcmUSBData* private = common->private;
>
> DBG(6, common, "%d events received\n", private->wcmEventCnt);
>
> + if (private->wcmPenTouch)
> + {
> + device_type = usbGetToolType(private);
> +
> + /* don't process touch event when pen is in-prox.
> + * Touch events will be posted to the userland when XInput 2.1
> + * is ready.
> + */
> + if ((device_type == TOUCH_ID) &&
> + ((dslast.device_type == STYLUS_ID ||
> + dslast.device_type == ERASER_ID) && dslast.proximity))
> + {
> + private->wcmEventCnt = 0;
> + return;
> + }
> + }
> +
> channel = usbChooseChannel(common);
>
> /* couldn't decide channel? invalid data */
> --
> 1.7.4
>
>
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel