Skip to content

Commit

Permalink
tablet: don't set rotation on a tool if we don't have ABS_Z
Browse files Browse the repository at this point in the history
Rotation on a tool can either ABS_Z or in the case of the mouse/lens tools a
combination of ABS_TILT_X/Y. The code assumes that if the rotation on a stylus
(not mouse/lense) changes, we need to fetch it from ABS_Z. This happens on the
very first event from the tablet, proximity in invalidates all axes so we can
send the current state to the caller.

On libwacom-recognized tablets we never set the rotation bit on the stylus, so
that's all fine. On tablets without libwacom support, the stylus may have a
rotation bit copied because we have it set thanks to mouse+tilt on the tablet.
When that first event is handled, we try to access ABS_Z. On tablets without
ABS_Z like Aipteks, we go boom.

Fix this by checking for ABS_Z during tablet init, if we don't have that axis
then never set the rotation bit on the tool. That's the only axis where we
need this, all other axes have a single cause only and thus the tablet bits
are accurate anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=104939

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Feb 9, 2018
1 parent 76cda65 commit cbb4ec1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/evdev-tablet.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,17 @@ tool_set_bits(const struct tablet_dispatch *tablet,
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);

/* Rotation is special, it can be either ABS_Z or
* BTN_TOOL_MOUSE+ABS_TILT_X/Y. Aiptek tablets have
* mouse+tilt (and thus rotation), but they do not have
* ABS_Z. So let's not copy the axis bit if we don't have
* ABS_Z, otherwise we try to get the value from it later on
* proximity in and go boom because the absinfo isn't there.
*/
if (libevdev_has_event_code(tablet->device->evdev, EV_ABS,
ABS_Z))
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
break;
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
case LIBINPUT_TABLET_TOOL_TYPE_LENS:
Expand Down

0 comments on commit cbb4ec1

Please sign in to comment.