[PATCH libinput] tablet: add hwdb entries to ignore Wacom Cintiq offsets
Peter Hutterer
peter.hutterer at who-t.net
Wed Feb 17 00:04:58 UTC 2016
On Tue, Feb 16, 2016 at 12:39:09PM -0800, Ping Cheng wrote:
> On Mon, Feb 15, 2016 at 9:47 PM, Peter Hutterer <peter.hutterer at who-t.net>
> wrote:
>
> > Wacom Cintiqs and some DTK/DTU devices have a sensor larger than the
> > underlying display. Clamp any data outside the screen area to the screen
> > area.
> >
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > src/evdev-tablet.c | 27 +++++++++++++++++--------
> > src/evdev.c | 1 +
> > src/evdev.h | 1 +
> > test/tablet.c | 8 ++++----
> > udev/90-libinput-model-quirks.hwdb | 36
> > ++++++++++++++++++++++++++++++++++
> > udev/90-libinput-model-quirks.rules.in | 4 ++++
> > 6 files changed, 65 insertions(+), 12 deletions(-)
> >
> > diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> > index 1e5c2cd..50ecf25 100644
> > --- a/src/evdev-tablet.c
> > +++ b/src/evdev-tablet.c
> > @@ -244,9 +244,9 @@ adjust_tilt(const struct input_absinfo *absinfo)
> > }
> >
> > static inline int32_t
> > -invert_axis(const struct input_absinfo *absinfo)
> > +invert_axis(const struct input_absinfo *absinfo, int value)
> > {
> > - return absinfo->maximum - (absinfo->value - absinfo->minimum);
> > + return absinfo->maximum - (value - absinfo->minimum);
> > }
> >
> > static void
> > @@ -292,6 +292,18 @@ normalize_wheel(struct tablet_dispatch *tablet,
> > return value * device->scroll.wheel_click_angle;
> > }
> >
> > +static inline int
> > +tablet_get_ranged_value(struct evdev_device *device,
> > + const struct input_absinfo *abs)
> > +{
> > + int value = abs->value;
> > +
> > + if (device->model_flags & EVDEV_MODEL_WACOM_SENSOR_OFFSET)
> > + value = max(min(value, abs->maximum), abs->minimum);
> >
>
> If we trim data here, we lost the benefit of actually reported values for
> calibration.
>
> For example, if the actual calibrated tablet area is
> (abs->minimum-30, abs->minimum-12;
> maxX-offset-offset-30, maxY-offset-offset-12), we miss the
> (abs->minimum-30, abs->minimum-12; abs->minimum, abs->minimum) active
> area, which could be mapped to the screen if we don't trim it.
>
> This patch potentially leaves some screen area unreachable, which could be
> reached with the introduction of outbound values.
>
> Tablet (output) area for mapping to screen/display needs to be considered
> separately from tablet input area. Input/raw area/data should be reported
> as-is; output area can be selected/configured by client, as long as we tell
> them the default.
hmm. good point. I forgot about calibration, that needs to be taken into
account here but doning so gets a bit more complicated. I might just drop
this patch for now and let the client worry about handling out-of-range
coordinates. This was mostly supposed to be a convenience patch anyway.
> > +
> > + return value;
> > +}
> > +
> > static inline void
> > tablet_handle_xy(struct tablet_dispatch *tablet,
> > struct evdev_device *device,
> > @@ -305,26 +317,25 @@ tablet_handle_xy(struct tablet_dispatch *tablet,
> >
> > if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X))
> > {
> > absinfo = libevdev_get_abs_info(device->evdev, ABS_X);
> > + value = tablet_get_ranged_value(device, absinfo);
> >
> > if (device->left_handed.enabled)
> > - value = invert_axis(absinfo);
> > - else
> > - value = absinfo->value;
> > + value = invert_axis(absinfo, value);
> >
> > if (!tablet_has_status(tablet,
> > TABLET_TOOL_ENTERING_PROXIMITY))
> > delta.x = value - tablet->axes.point.x;
> > tablet->axes.point.x = value;
> > +
> > }
> > point.x = tablet->axes.point.x;
> >
> > if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y))
> > {
> > absinfo = libevdev_get_abs_info(device->evdev, ABS_Y);
> > + value = tablet_get_ranged_value(device, absinfo);
> >
> > if (device->left_handed.enabled)
> > - value = invert_axis(absinfo);
> > - else
> > - value = absinfo->value;
> > + value = invert_axis(absinfo, value);
> >
> > if (!tablet_has_status(tablet,
> > TABLET_TOOL_ENTERING_PROXIMITY))
> > diff --git a/src/evdev.c b/src/evdev.c
> > index 51768fe..ccfd7e4 100644
> > --- a/src/evdev.c
> > +++ b/src/evdev.c
> > @@ -1680,6 +1680,7 @@ evdev_read_model_flags(struct evdev_device *device)
> > { "LIBINPUT_MODEL_CYBORG_RAT", EVDEV_MODEL_CYBORG_RAT },
> > { "LIBINPUT_MODEL_CYAPA", EVDEV_MODEL_CYAPA },
> > { "LIBINPUT_MODEL_ALPS_RUSHMORE",
> > EVDEV_MODEL_ALPS_RUSHMORE },
> > + { "LIBINPUT_MODEL_WACOM_SENSOR_OFFSET",
> > EVDEV_MODEL_WACOM_SENSOR_OFFSET },
> > { NULL, EVDEV_MODEL_DEFAULT },
> > };
> > const struct model_map *m = model_map;
> > diff --git a/src/evdev.h b/src/evdev.h
> > index 482712b..80f1606 100644
> > --- a/src/evdev.h
> > +++ b/src/evdev.h
> > @@ -113,6 +113,7 @@ enum evdev_device_model {
> > EVDEV_MODEL_CYBORG_RAT = (1 << 14),
> > EVDEV_MODEL_CYAPA = (1 << 15),
> > EVDEV_MODEL_ALPS_RUSHMORE = (1 << 16),
> > + EVDEV_MODEL_WACOM_SENSOR_OFFSET = (1 << 17),
> > };
> >
> > struct mt_slot {
> > diff --git a/test/tablet.c b/test/tablet.c
> > index c5dc892..b1f7160 100644
> > --- a/test/tablet.c
> > +++ b/test/tablet.c
> > @@ -1682,12 +1682,12 @@ START_TEST(motion_outside_bounds)
> > tablet_event = litest_is_tablet_event(event,
> >
> > LIBINPUT_EVENT_TABLET_TOOL_AXIS);
> > val = libinput_event_tablet_tool_get_x(tablet_event);
> > - ck_assert_double_lt(val, 0.0);
> > + ck_assert_double_eq(val, 0.0);
> > val = libinput_event_tablet_tool_get_y(tablet_event);
> > ck_assert_double_gt(val, 0.0);
> >
> > val = libinput_event_tablet_tool_get_x_transformed(tablet_event,
> > 100);
> > - ck_assert_double_lt(val, 0.0);
> > + ck_assert_double_eq(val, 0.0);
> >
> > libinput_event_destroy(event);
> >
> > @@ -1703,10 +1703,10 @@ START_TEST(motion_outside_bounds)
> > val = libinput_event_tablet_tool_get_x(tablet_event);
> > ck_assert_double_gt(val, 0.0);
> > val = libinput_event_tablet_tool_get_y(tablet_event);
> > - ck_assert_double_lt(val, 0.0);
> > + ck_assert_double_eq(val, 0.0);
> >
> > val = libinput_event_tablet_tool_get_y_transformed(tablet_event,
> > 100);
> > - ck_assert_double_lt(val, 0.0);
> > + ck_assert_double_eq(val, 0.0);
> >
> > libinput_event_destroy(event);
> > }
> > diff --git a/udev/90-libinput-model-quirks.hwdb
> > b/udev/90-libinput-model-quirks.hwdb
> > index eb2859e..07fb23f 100644
> > --- a/udev/90-libinput-model-quirks.hwdb
> > +++ b/udev/90-libinput-model-quirks.hwdb
> > @@ -131,3 +131,39 @@ libinput:name:SynPS/2 Synaptics
> > TouchPad:dmi:*svnSystem76*pvrkudp1*
> > ##########################################
> > libinput:touchpad:input:b0003v056Ap*
> > LIBINPUT_MODEL_WACOM_TOUCHPAD=1
> > +
> > +# DTK2241
> > +libinput:tablet:input:b0003v056Ap0057*
> > +# DTK2242
> > +libinput:tablet:input:b0003v056Ap0059*
> > +# Cintiq 22HDT
> > +libinput:tablet:input:b0003v056Ap005B*
> > +# Cintiq 21UX2
> > +libinput:tablet:input:b0003v056Ap00CC*
> > +# Cintiq 24HD
> > +libinput:tablet:input:b0003v056Ap00F4*
> > +# Cintiq 24HDT
> > +libinput:tablet:input:b0003v056Ap00F8*
> > +# Cintiq 22HD
> > +libinput:tablet:input:b0003v056Ap00FA*
> > +# DTU1031
> > +libinput:tablet:input:b0003v056Ap00FB*
> > +# Cintiq 13HD
> > +libinput:tablet:input:b0003v056Ap0304*
> > +# ISDv4 307
> > +libinput:tablet:input:b0003v056Ap0307*
> > +# ISDv4 30A
> > +libinput:tablet:input:b0003v056Ap030A*
> > +# ISDv4 325
> >
>
> ISDv4 should be ISDv5.
huh, force of habit, sorry. Fixed locally.
Cheers,
Peter
More information about the wayland-devel
mailing list