On Mon, Mar 21, 2011 at 05:55:41PM -0700, Ping Cheng wrote:
> Serial model is not supported. So, findDeviceType is only used by
> wcmUSB.c.
>
> Now it is the individual model's, wcmUSB or wcmISDV4, responsibility
> to set the device type locally. For wcmUSB, since kernel input filters
> out duplicated events, we should retrieve the device type and
> associated events directly from the kernel to cover the case when tool
> is on the tablet during driver starts.
>
> wcmCommon.c will treat packet with undefined device_type as invalid.
>
> Signed-off-by: Ping Cheng <[email protected]>
> ---
> src/wcmCommon.c | 95
> ++++++-------------------------------------------------
> src/wcmUSB.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 93 insertions(+), 87 deletions(-)
>
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index d024ad8..1f85853 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -949,88 +949,6 @@ void wcmEvent(WacomCommonPtr common, unsigned int
> channel,
> commonDispatchDevice(common,channel,pChannel, suppress);
> }
>
> -static int idtotype(int id)
> -{
> - int type = CURSOR_ID;
> -
> - /* tools with id, such as Intuos series and Cintiq 21UX */
> - switch (id)
> - {
> - case 0x812: /* Inking pen */
> - case 0x801: /* Intuos3 Inking pen */
> - case 0x012:
> - case 0x822: /* Pen */
> - case 0x842:
> - case 0x852:
> - case 0x823: /* Intuos3 Grip Pen */
> - case 0x813: /* Intuos3 Classic Pen */
> - case 0x885: /* Intuos3 Marker Pen */
> - case 0x022:
> - case 0x832: /* Stroke pen */
> - case 0x032:
> - case 0xd12: /* Airbrush */
> - case 0x912:
> - case 0x112:
> - case 0x913: /* Intuos3 Airbrush */
> - type = STYLUS_ID;
> - break;
> - case 0x82a: /* Eraser */
> - case 0x85a:
> - case 0x91a:
> - case 0xd1a:
> - case 0x0fa:
> - case 0x82b: /* Intuos3 Grip Pen Eraser */
> - case 0x81b: /* Intuos3 Classic Pen Eraser */
> - case 0x91b: /* Intuos3 Airbrush Eraser */
> - type = ERASER_ID;
> - break;
> - }
> - return type;
> -}
> -
> -/**
> - * Identify the device type (STYLUS_ID, etc.) based on the device_id or the
> - * current tool serial number.
> - */
> -static int findDeviceType(const WacomCommonPtr common,
> - const WacomDeviceState *ds)
> -{
> - WacomToolPtr tool = NULL;
> - int device_type = 0;
> -
> - switch (ds->device_id)
> - {
> - case STYLUS_DEVICE_ID:
> - device_type = STYLUS_ID;
> - break;
> - case ERASER_DEVICE_ID:
> - device_type = ERASER_ID;
> - break;
> - case CURSOR_DEVICE_ID:
> - device_type = CURSOR_ID;
> - break;
> - case TOUCH_DEVICE_ID:
> - device_type = TOUCH_ID;
> - break;
> - case PAD_DEVICE_ID:
> - device_type = PAD_ID;
> - break;
> - default:
> - device_type = idtotype(ds->device_id);
> - }
> -
> - if (ds->serial_num)
> - {
> - for (tool = common->wcmTool; tool; tool = tool->next)
> - if (ds->serial_num == tool->serial)
> - {
> - device_type = tool->typeid;
> - break;
> - }
> - }
> - return device_type;
> -}
> -
> /**
> * Find the device the current events are meant for. If multiple tools are
> * configured on this tablet, the one that matches the serial number for the
> @@ -1180,9 +1098,16 @@ static void commonDispatchDevice(WacomCommonPtr
> common, unsigned int channel,
> WacomDevicePtr priv = NULL;
> WacomDeviceState filtered;
>
> - /* if something went wrong, figure out device type by device id */
> - if (!ds->device_type && ds->proximity)
> - ds->device_type = findDeviceType(common, ds);
> + /* device_type should have been retrieved and set in the respect
typo, "respective", fixed locally. merged otherwise, thanks.
Cheers,
Peter
> + * models, wcmISDV4.c or wcmUSB.c. Once it comes here, something
> + * must have been wrong. Ignore the events.
> + */
> + if (!ds->device_type)
> + {
> + DBG(11, common, "no device type matches with"
> + " serial=%u\n", ds->serial_num);
> + return;
> + }
>
> DBG(10, common, "device type = %d\n", ds->device_type);
>
> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
> index cfc3e26..06683dc 100644
> --- a/src/wcmUSB.c
> +++ b/src/wcmUSB.c
> @@ -919,6 +919,88 @@ static int usbFilterEvent(WacomCommonPtr common, struct
> input_event *event)
> return 0;
> }
>
> +static int idtotype(int id)
> +{
> + int type = CURSOR_ID;
> +
> + /* tools with id, such as Intuos series and Cintiq 21UX */
> + switch (id)
> + {
> + case 0x812: /* Inking pen */
> + case 0x801: /* Intuos3 Inking pen */
> + case 0x012:
> + case 0x822: /* Pen */
> + case 0x842:
> + case 0x852:
> + case 0x823: /* Intuos3 Grip Pen */
> + case 0x813: /* Intuos3 Classic Pen */
> + case 0x885: /* Intuos3 Marker Pen */
> + case 0x022:
> + case 0x832: /* Stroke pen */
> + case 0x032:
> + case 0xd12: /* Airbrush */
> + case 0x912:
> + case 0x112:
> + case 0x913: /* Intuos3 Airbrush */
> + type = STYLUS_ID;
> + break;
> + case 0x82a: /* Eraser */
> + case 0x85a:
> + case 0x91a:
> + case 0xd1a:
> + case 0x0fa:
> + case 0x82b: /* Intuos3 Grip Pen Eraser */
> + case 0x81b: /* Intuos3 Classic Pen Eraser */
> + case 0x91b: /* Intuos3 Airbrush Eraser */
> + type = ERASER_ID;
> + break;
> + }
> + return type;
> +}
> +
> +/**
> + * Identify the device type (STYLUS_ID, etc.) based on the device_id or the
> + * current tool serial number.
> + */
> +static int findDeviceType(const WacomCommonPtr common,
> + const WacomDeviceState *ds)
> +{
> + WacomToolPtr tool = NULL;
> + int device_type = 0;
> +
> + switch (ds->device_id)
> + {
> + case STYLUS_DEVICE_ID:
> + device_type = STYLUS_ID;
> + break;
> + case ERASER_DEVICE_ID:
> + device_type = ERASER_ID;
> + break;
> + case CURSOR_DEVICE_ID:
> + device_type = CURSOR_ID;
> + break;
> + case TOUCH_DEVICE_ID:
> + device_type = TOUCH_ID;
> + break;
> + case PAD_DEVICE_ID:
> + device_type = PAD_ID;
> + break;
> + default:
> + device_type = idtotype(ds->device_id);
> + }
> +
> + if (ds->serial_num)
> + {
> + for (tool = common->wcmTool; tool; tool = tool->next)
> + if (ds->serial_num == tool->serial)
> + {
> + device_type = tool->typeid;
> + break;
> + }
> + }
> + return device_type;
> +}
> +
> static int usbParseAbsEvent(WacomCommonPtr common,
> struct input_event *event, WacomDeviceState *ds)
> {
> @@ -970,8 +1052,7 @@ static int usbParseAbsEvent(WacomCommonPtr common,
> if (event->value)
> {
> ds->device_id = event->value;
> - if (ds->device_id == PAD_DEVICE_ID)
> - ds->device_type = PAD_ID;
> + ds->device_type = findDeviceType(common, ds);
> }
> break;
> default:
> --
> 1.7.4
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel