Skip to content

Commit

Permalink
Ignore ABS_MISC as a source of device type information for AES pens
Browse files Browse the repository at this point in the history
AES sensors "appear" to use protocol 5 since they send ABS_MISC events
which contain information about the tool type in use. The tool type
information sent by AES sensors does not contain stylus/eraser/puck
information, however, so we need to ignore it or else we may randomly
end up treating the pens as erasers if a certian bit is set.

Fixes: linuxwacom#74
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
  • Loading branch information
jigpu committed Oct 31, 2019
1 parent b40122d commit 2bd54ae
Showing 1 changed file with 52 additions and 8 deletions.
60 changes: 52 additions & 8 deletions src/wcmUSB.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,44 @@ static int usbFilterEvent(WacomCommonPtr common, struct input_event *event)
return 0;
}

/**
* Try to determine if a given tool ID belongs to an AES pen or not.
* Current definitions of the ID format define that bit 0 is a flag
* which indicates this. A few legacy pens have this bit set, however,
* making it hard to distinguish from this information alone. Ideally
* we would have a more robust mechanism that sets up an AES-specific
* protocol type at hotplug, but it seems I'm getting ahead of myself...
*
* @param id The tool id received from the kernel.
* @return 'true' if the tool uses AES, 'false' otherwise.
*/
static Bool toolIdIsAes(int id)
{
if ((id & 0x01) == 0) {
return FALSE;
}

/* If an AES pen is ever released with one of these IDs, this
* code will result in a false negative... *sigh*
*/
switch (id) {
case 0x801: /* Intuos3 Inking pen */
case 0x823: /* Intuos3 Grip Pen */
case 0x813: /* Intuos3 Classic Pen */
case 0x885: /* Intuos3 Marker Pen */
case 0x007: /* Mouse 4D and 2D */
case 0x017: /* Intuos3 2D Mouse */
case 0x097: /* Intuos3 Lens cursor */
case 0x82b: /* Intuos3 Grip Pen Eraser */
case 0x81b: /* Intuos3 Classic Pen Eraser */
case 0x91b: /* Intuos3 Airbrush Eraser */
case 0x913: /* Intuos3 Airbrush */
return FALSE;
}

return TRUE;
}

#define ERASER_BIT 0x008
#define PUCK_BITS 0xf00
#define PUCK_EXCEPTION 0x806
Expand All @@ -1177,14 +1215,20 @@ static int usbIdToType(int id)
if (!id)
return 0;

/* The existing tool ids have the following patten: all pucks, except
* one, have the third byte set to zero; all erasers have the fourth
* bit set. The rest are styli.
*/
if (id & ERASER_BIT)
type = ERASER_ID;
else if (!(id & PUCK_BITS) || (id == PUCK_EXCEPTION))
type = CURSOR_ID;
if (toolIdIsAes(id)) {
/* Type information is not available from the ID for AES */
return 0;
}
else {
/* The existing EMR tool ids have the following patten: all
* pucks, except one, have the third byte set to zero; all
* erasers have the fourth bit set. The rest are styli.
*/
if (id & ERASER_BIT)
type = ERASER_ID;
else if (!(id & PUCK_BITS) || (id == PUCK_EXCEPTION))
type = CURSOR_ID;
}

return type;
}
Expand Down

0 comments on commit 2bd54ae

Please sign in to comment.