<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 15, 2016 at 9:47 PM, Peter Hutterer <span dir="ltr"><<a href="mailto:peter.hutterer@who-t.net" target="_blank">peter.hutterer@who-t.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Wacom Cintiqs and some DTK/DTU devices have a sensor larger than the<br>
underlying display. Clamp any data outside the screen area to the screen area.<br>
<br>
Signed-off-by: Peter Hutterer <<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>><br>
---<br>
 src/evdev-tablet.c                     | 27 +++++++++++++++++--------<br>
 src/evdev.c                            |  1 +<br>
 src/evdev.h                            |  1 +<br>
 test/tablet.c                          |  8 ++++----<br>
 udev/90-libinput-model-quirks.hwdb     | 36 ++++++++++++++++++++++++++++++++++<br>
 udev/<a href="http://90-libinput-model-quirks.rules.in" rel="noreferrer" target="_blank">90-libinput-model-quirks.rules.in</a> |  4 ++++<br>
 6 files changed, 65 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c<br>
index 1e5c2cd..50ecf25 100644<br>
--- a/src/evdev-tablet.c<br>
+++ b/src/evdev-tablet.c<br>
@@ -244,9 +244,9 @@ adjust_tilt(const struct input_absinfo *absinfo)<br>
 }<br>
<br>
 static inline int32_t<br>
-invert_axis(const struct input_absinfo *absinfo)<br>
+invert_axis(const struct input_absinfo *absinfo, int value)<br>
 {<br>
-       return absinfo->maximum - (absinfo->value - absinfo->minimum);<br>
+       return absinfo->maximum - (value - absinfo->minimum);<br>
 }<br>
<br>
 static void<br>
@@ -292,6 +292,18 @@ normalize_wheel(struct tablet_dispatch *tablet,<br>
        return value * device->scroll.wheel_click_angle;<br>
 }<br>
<br>
+static inline int<br>
+tablet_get_ranged_value(struct evdev_device *device,<br>
+                       const struct input_absinfo *abs)<br>
+{<br>
+       int value = abs->value;<br>
+<br>
+       if (device->model_flags & EVDEV_MODEL_WACOM_SENSOR_OFFSET)<br>
+               value = max(min(value, abs->maximum), abs->minimum);<br></blockquote><div><br></div><div>If we trim data here, we lost the benefit of actually reported values for calibration.</div><div><br></div><div>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.</div><div><br></div><div>This patch potentially leaves some screen area unreachable, which could be reached with the introduction of outbound values.</div><div><br></div><div>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.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+ <br>
+       return value;<br>
+}<br>
+<br>
 static inline void<br>
 tablet_handle_xy(struct tablet_dispatch *tablet,<br>
                 struct evdev_device *device,<br>
@@ -305,26 +317,25 @@ tablet_handle_xy(struct tablet_dispatch *tablet,<br>
<br>
        if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X)) {<br>
                absinfo = libevdev_get_abs_info(device->evdev, ABS_X);<br>
+               value = tablet_get_ranged_value(device, absinfo);<br>
<br>
                if (device->left_handed.enabled)<br>
-                       value = invert_axis(absinfo);<br>
-               else<br>
-                       value = absinfo->value;<br>
+                       value = invert_axis(absinfo, value);<br>
<br>
                if (!tablet_has_status(tablet,<br>
                                       TABLET_TOOL_ENTERING_PROXIMITY))<br>
                        delta.x = value - tablet->axes.point.x;<br>
                tablet->axes.point.x = value;<br>
+<br>
        }<br>
        point.x = tablet->axes.point.x;<br>
<br>
        if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y)) {<br>
                absinfo = libevdev_get_abs_info(device->evdev, ABS_Y);<br>
+               value = tablet_get_ranged_value(device, absinfo);<br>
<br>
                if (device->left_handed.enabled)<br>
-                       value = invert_axis(absinfo);<br>
-               else<br>
-                       value = absinfo->value;<br>
+                       value = invert_axis(absinfo, value);<br>
<br>
                if (!tablet_has_status(tablet,<br>
                                       TABLET_TOOL_ENTERING_PROXIMITY))<br>
diff --git a/src/evdev.c b/src/evdev.c<br>
index 51768fe..ccfd7e4 100644<br>
--- a/src/evdev.c<br>
+++ b/src/evdev.c<br>
@@ -1680,6 +1680,7 @@ evdev_read_model_flags(struct evdev_device *device)<br>
                { "LIBINPUT_MODEL_CYBORG_RAT", EVDEV_MODEL_CYBORG_RAT },<br>
                { "LIBINPUT_MODEL_CYAPA", EVDEV_MODEL_CYAPA },<br>
                { "LIBINPUT_MODEL_ALPS_RUSHMORE", EVDEV_MODEL_ALPS_RUSHMORE },<br>
+               { "LIBINPUT_MODEL_WACOM_SENSOR_OFFSET", EVDEV_MODEL_WACOM_SENSOR_OFFSET },<br>
                { NULL, EVDEV_MODEL_DEFAULT },<br>
        };<br>
        const struct model_map *m = model_map;<br>
diff --git a/src/evdev.h b/src/evdev.h<br>
index 482712b..80f1606 100644<br>
--- a/src/evdev.h<br>
+++ b/src/evdev.h<br>
@@ -113,6 +113,7 @@ enum evdev_device_model {<br>
        EVDEV_MODEL_CYBORG_RAT = (1 << 14),<br>
        EVDEV_MODEL_CYAPA = (1 << 15),<br>
        EVDEV_MODEL_ALPS_RUSHMORE = (1 << 16),<br>
+       EVDEV_MODEL_WACOM_SENSOR_OFFSET = (1 << 17),<br>
 };<br>
<br>
 struct mt_slot {<br>
diff --git a/test/tablet.c b/test/tablet.c<br>
index c5dc892..b1f7160 100644<br>
--- a/test/tablet.c<br>
+++ b/test/tablet.c<br>
@@ -1682,12 +1682,12 @@ START_TEST(motion_outside_bounds)<br>
        tablet_event = litest_is_tablet_event(event,<br>
                                              LIBINPUT_EVENT_TABLET_TOOL_AXIS);<br>
        val = libinput_event_tablet_tool_get_x(tablet_event);<br>
-       ck_assert_double_lt(val, 0.0);<br>
+       ck_assert_double_eq(val, 0.0);<br>
        val = libinput_event_tablet_tool_get_y(tablet_event);<br>
        ck_assert_double_gt(val, 0.0);<br>
<br>
        val = libinput_event_tablet_tool_get_x_transformed(tablet_event, 100);<br>
-       ck_assert_double_lt(val, 0.0);<br>
+       ck_assert_double_eq(val, 0.0);<br>
<br>
        libinput_event_destroy(event);<br>
<br>
@@ -1703,10 +1703,10 @@ START_TEST(motion_outside_bounds)<br>
        val = libinput_event_tablet_tool_get_x(tablet_event);<br>
        ck_assert_double_gt(val, 0.0);<br>
        val = libinput_event_tablet_tool_get_y(tablet_event);<br>
-       ck_assert_double_lt(val, 0.0);<br>
+       ck_assert_double_eq(val, 0.0);<br>
<br>
        val = libinput_event_tablet_tool_get_y_transformed(tablet_event, 100);<br>
-       ck_assert_double_lt(val, 0.0);<br>
+       ck_assert_double_eq(val, 0.0);<br>
<br>
        libinput_event_destroy(event);<br>
 }<br>
diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb<br>
index eb2859e..07fb23f 100644<br>
--- a/udev/90-libinput-model-quirks.hwdb<br>
+++ b/udev/90-libinput-model-quirks.hwdb<br>
@@ -131,3 +131,39 @@ libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnSystem76*pvrkudp1*<br>
 ##########################################<br>
 libinput:touchpad:input:b0003v056Ap*<br>
  LIBINPUT_MODEL_WACOM_TOUCHPAD=1<br>
+<br>
+# DTK2241<br>
+libinput:tablet:input:b0003v056Ap0057*<br>
+# DTK2242<br>
+libinput:tablet:input:b0003v056Ap0059*<br>
+# Cintiq 22HDT<br>
+libinput:tablet:input:b0003v056Ap005B*<br>
+# Cintiq 21UX2<br>
+libinput:tablet:input:b0003v056Ap00CC*<br>
+# Cintiq 24HD<br>
+libinput:tablet:input:b0003v056Ap00F4*<br>
+# Cintiq 24HDT<br>
+libinput:tablet:input:b0003v056Ap00F8*<br>
+# Cintiq 22HD<br>
+libinput:tablet:input:b0003v056Ap00FA*<br>
+# DTU1031<br>
+libinput:tablet:input:b0003v056Ap00FB*<br>
+# Cintiq 13HD<br>
+libinput:tablet:input:b0003v056Ap0304*<br>
+# ISDv4 307<br>
+libinput:tablet:input:b0003v056Ap0307*<br>
+# ISDv4 30A<br>
+libinput:tablet:input:b0003v056Ap030A*<br>
+# ISDv4 325<br></blockquote><div><br></div><div>ISDv4 should be ISDv5.</div><div><br></div><div>Thank you.</div><div><br></div><div>Ping</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+libinput:tablet:input:b0003v056Ap0325*<br>
+# Cintiq 27QHD<br>
+libinput:tablet:input:b0003v056Ap032A*<br>
+# Cintiq 27QHDT<br>
+libinput:tablet:input:b0003v056Ap032B*<br>
+# DTU1031X<br>
+libinput:tablet:input:b0003v056Ap032F*<br>
+# Cintiq 13HDT<br>
+libinput:tablet:input:b0003v056Ap0333*<br>
+# DTU1141<br>
+libinput:tablet:input:b0003v056Ap0336*<br>
+ LIBINPUT_MODEL_WACOM_SENSOR_OFFSET=1<br>
diff --git a/udev/<a href="http://90-libinput-model-quirks.rules.in" rel="noreferrer" target="_blank">90-libinput-model-quirks.rules.in</a> b/udev/<a href="http://90-libinput-model-quirks.rules.in" rel="noreferrer" target="_blank">90-libinput-model-quirks.rules.in</a><br>
index 8bff192..4e96bb3 100644<br>
--- a/udev/<a href="http://90-libinput-model-quirks.rules.in" rel="noreferrer" target="_blank">90-libinput-model-quirks.rules.in</a><br>
+++ b/udev/<a href="http://90-libinput-model-quirks.rules.in" rel="noreferrer" target="_blank">90-libinput-model-quirks.rules.in</a><br>
@@ -33,6 +33,10 @@ ENV{ID_INPUT_TOUCHPAD}=="1", \<br>
 ENV{ID_INPUT_MOUSE}=="1", \<br>
   IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:mouse:"<br>
<br>
+# libinput:tablet:<modalias><br>
+ENV{ID_INPUT_TABLET}=="1", \<br>
+  IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:tablet:"<br>
+<br>
 # libinput:name:<name>:dmi:<dmi string><br>
 KERNELS=="input*", \<br>
   IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'"<br>
<span class=""><font color="#888888">--<br>
2.5.0<br>
<br>
</font></span></blockquote></div><br></div></div>