Skip to content

Commit

Permalink
Recognize the pad in more situations
Browse files Browse the repository at this point in the history
Allow dial and ring events to be recognized as coming from the pad
when there are no other better sources of information (for example,
BTN_TOOL_* events earlier in the event packet, an ABS_MISC with the
information, or a previously-known tool type).

This fixes an issue where the pad is not recognized (and events are
not generated) if your first interaction is with a relative wheel
rather than a button or touchring. The events types matched by this
function have an ambiguous source on their own, but other earlier
tests would be able to determine the type from other context. If
all other context-sensitive tests fail to find a tool type, it is
reasonably safe to assume we're looking at a pad.

Signed-off-by: Jason Gerecke <[email protected]>
  • Loading branch information
jigpu authored and Pinglinux committed Aug 8, 2024
1 parent 7722f2e commit a91168c
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/wcmUSB.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,8 +1735,8 @@ static int refreshDeviceType(WacomDevicePtr priv, int fd)
return 0;
}

static int deriveDeviceTypeFromButtonEvent(WacomDevicePtr priv,
const struct input_event *event_ptr)
static Bool eventCouldBeFromPad(WacomDevicePtr priv,
const struct input_event *event_ptr)
{
WacomCommonPtr common = priv->common;
wcmUSBData *usbdata = common->private;
Expand All @@ -1752,18 +1752,33 @@ static int deriveDeviceTypeFromButtonEvent(WacomDevicePtr priv,
case BTN_BACK:
case BTN_EXTRA:
case BTN_FORWARD:
return PAD_ID;
return TRUE;
default:
for (nkeys = 0; nkeys < usbdata->npadkeys; nkeys++)
{
if (event_ptr->code == usbdata->padkey_code[nkeys]) {
return PAD_ID;
return TRUE;
}
}
break;
}
}
return 0;
if (event_ptr->type == EV_REL) {
switch (event_ptr->code) {
case REL_WHEEL:
case REL_WHEEL_HI_RES:
return TRUE;
}
}
if (event_ptr->type == EV_ABS) {
switch (event_ptr->code) {
case ABS_WHEEL:
case ABS_THROTTLE:
return TRUE;
}
}

return FALSE;
}

/***
Expand Down Expand Up @@ -1800,7 +1815,8 @@ static int usbInitToolType(WacomDevicePtr priv, int fd,

if (!device_type) /* expresskey pressed at startup or missing type */
for (i = 0; (i < nevents) && !device_type; ++i)
device_type = deriveDeviceTypeFromButtonEvent(priv, &event_ptr[i]);
if (eventCouldBeFromPad(priv, &event_ptr[i]))
device_type = PAD_ID;

return device_type;
}
Expand Down

0 comments on commit a91168c

Please sign in to comment.