Re: [PATCH libinput] test: add tablet test for out-of-bounds motion coordinates

2016-02-11 Thread Carlos Garnacho
Hey :),

On Thu, Feb 11, 2016 at 8:31 AM, Peter Hutterer
 wrote:
> The newer Cintiqs have a minimum value of 400/400 advertised by the kernel but
> the actual sensor goes past the 0/0 origin. Test this, make sure that a value
> outside the boundaries generates negative mm values.
>
> Signed-off-by: Peter Hutterer 
> ---
> Mostly just documenting this and adding a test. The behaviour is that any
> out-of-bounds motion may provide negative coordinates, when transformed may
> provide something outside the [0, max-range].
>
> Now, this is documenting the API behaviour. For the Cintiq I think it might
> be better to put a device-specific quirk in to simply supress those events
> since we don't have anything outside of these boundaries. Jason, Carlos, any
> comments?

I agree, reporting those would mean that such tablets could move
"outside" the crtc they're mapped to, even if not too far around the
borders. Although that same thought comes from any other tablet that
happens to behave the same. Not that we can preemptively add quirks
for these, but we probably should too when we know of these.

Cheers,
  Carlos

>
>  doc/svg/tablet-out-of-bounds.svg | 271 
> +++
>  doc/tablet-support.dox   |  22 
>  src/libinput.h   |  12 ++
>  test/tablet.c|  58 +
>  4 files changed, 363 insertions(+)
>  create mode 100644 doc/svg/tablet-out-of-bounds.svg
>
> diff --git a/doc/svg/tablet-out-of-bounds.svg 
> b/doc/svg/tablet-out-of-bounds.svg
> new file mode 100644
> index 000..83e5021
> --- /dev/null
> +++ b/doc/svg/tablet-out-of-bounds.svg
> @@ -0,0 +1,271 @@
> +
> +
> +
> + +   xmlns:dc="http://purl.org/dc/elements/1.1/;
> +   xmlns:cc="http://creativecommons.org/ns#;
> +   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;
> +   xmlns:svg="http://www.w3.org/2000/svg;
> +   xmlns="http://www.w3.org/2000/svg;
> +   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd;
> +   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape;
> +   width="134.12477mm"
> +   height="73.121971mm"
> +   viewBox="0 0 475.24525 259.0936"
> +   id="svg2"
> +   version="1.1"
> +   inkscape:version="0.91 r13725"
> +   sodipodi:docname="tablet-out-of-bounds.svg">
> +   + id="defs4" />
> +   + id="base"
> + pagecolor="#ff"
> + bordercolor="#66"
> + borderopacity="1.0"
> + inkscape:pageopacity="0.0"
> + inkscape:pageshadow="2"
> + inkscape:zoom="5.6"
> + inkscape:cx="105.43109"
> + inkscape:cy="265.46934"
> + inkscape:document-units="px"
> + inkscape:current-layer="layer1"
> + showgrid="false"
> + showguides="true"
> + inkscape:guide-bbox="true"
> + inkscape:window-width="1920"
> + inkscape:window-height="1136"
> + inkscape:window-x="0"
> + inkscape:window-y="27"
> + inkscape:window-maximized="1"
> + fit-margin-top="0"
> + fit-margin-left="0"
> + fit-margin-right="0"
> + fit-margin-bottom="0">
> + +   position="63.6133,240.91614"
> +   orientation="0,1"
> +   id="guide4164" />
> + +   position="61.08792,13.126743"
> +   orientation="0,1"
> +   id="guide4166" />
> +  
> +   + id="metadata7">
> +
> +   + rdf:about="">
> +image/svg+xml
> + +   rdf:resource="http://purl.org/dc/dcmitype/StillImage; />
> +
> +  
> +
> +  
> +   + inkscape:label="tablet"
> + inkscape:groupmode="layer"
> + id="layer1"
> + style="display:inline"
> + transform="translate(-139.42736,-156.36219)">
> + +   
> style="opacity:0.9202;fill:#4d4d4d;fill-opacity:1;stroke:#4d4d4d;stroke-width:0.9201867;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:3.68074643,
>  0.92018661;stroke-dashoffset:0;stroke-opacity:1"
> +   id="rect4136"
> +   width="474.32504"
> +   height="258.1734"
> +   x="139.88745"
> +   y="156.82228"
> +   rx="5" />
> + +   y="175.42407"
> +   x="199.33878"
> +   height="226.52563"
> +   width="357.34042"
> +   id="rect4140"
> +   
> style="opacity:0.9202;fill:#a44d4d;fill-opacity:1;stroke:#4d4d4d;stroke-width:0.7483;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
>  />
> + +   id="g7041"
> +   transform="translate(12,0)">
> +   + transform="matrix(0.53265351,0,0,0.53265351,92.308091,96.440418)"
> + id="g7023">
> + +   
> style="opacity:0.9202;fill:#4d4d4d;fill-opacity:1;stroke:#4d4d4d;stroke-width:0.9892;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:3.956,
>  0.989;stroke-dashoffset:0;stroke-opacity:1"
> +   id="path4158"
> +   cx="135.61298"
> +   cy="287.06125"
> +   r="22.98097" />
> + +   cy="287.06125"
> +   cx="135.61298"
> +   

[PATCH libinput] test: add tablet test for out-of-bounds motion coordinates

2016-02-10 Thread Peter Hutterer
The newer Cintiqs have a minimum value of 400/400 advertised by the kernel but
the actual sensor goes past the 0/0 origin. Test this, make sure that a value
outside the boundaries generates negative mm values.

Signed-off-by: Peter Hutterer 
---
Mostly just documenting this and adding a test. The behaviour is that any
out-of-bounds motion may provide negative coordinates, when transformed may
provide something outside the [0, max-range].

Now, this is documenting the API behaviour. For the Cintiq I think it might
be better to put a device-specific quirk in to simply supress those events
since we don't have anything outside of these boundaries. Jason, Carlos, any
comments?

 doc/svg/tablet-out-of-bounds.svg | 271 +++
 doc/tablet-support.dox   |  22 
 src/libinput.h   |  12 ++
 test/tablet.c|  58 +
 4 files changed, 363 insertions(+)
 create mode 100644 doc/svg/tablet-out-of-bounds.svg

diff --git a/doc/svg/tablet-out-of-bounds.svg b/doc/svg/tablet-out-of-bounds.svg
new file mode 100644
index 000..83e5021
--- /dev/null
+++ b/doc/svg/tablet-out-of-bounds.svg
@@ -0,0 +1,271 @@
+
+
+
+http://purl.org/dc/elements/1.1/;
+   xmlns:cc="http://creativecommons.org/ns#;
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;
+   xmlns:svg="http://www.w3.org/2000/svg;
+   xmlns="http://www.w3.org/2000/svg;
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd;
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape;
+   width="134.12477mm"
+   height="73.121971mm"
+   viewBox="0 0 475.24525 259.0936"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="tablet-out-of-bounds.svg">
+  
+  
+
+
+  
+  
+
+  
+image/svg+xml
+http://purl.org/dc/dcmitype/StillImage; />
+
+  
+
+  
+  
+
+
+
+  
+
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+
+  
+
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+
+  
+  
+
diff --git a/doc/tablet-support.dox b/doc/tablet-support.dox
index ff4e460..0e719b7 100644
--- a/doc/tablet-support.dox
+++ b/doc/tablet-support.dox
@@ -186,4 +186,26 @@ Intuos 3, 4, 5, Wacon Cintiq and Wacom Intuos Pro series. 
The tool ID can
 be used to distinguish between e.g. a Wacom Classic Pen or a Wacom Pro Pen.
 It is  the caller's responsibility to interpret the tool ID.
 
+@section tablet-bounds Out-of-bounds motion events
+
+Some tablets integrated into a screen (e.g. Wacom Cintiq 24HD, 27QHD and
+13HD series, etc.) have a sensor larger than the display area. libinput uses
+the range advertised by the kernel as the valid range unless device-specific
+quirks are present. Events outside this range will produce coordinates that
+may be negative or larger than the tablet's width and/or height. It is up to
+the caller to ignore these events.
+
+@image html tablet-out-of-bounds.svg "Illustration of the out-of-bounds area 
on a tablet"
+
+In the image above, the display area is shown in black. The red area around
+the display illustrates the sensor area that generates input events. Events
+within this area will have negative coordinate or coordinates larger than
+the width/height of the tablet.
+
+If events outside the logical bounds of the input area are scaled into a
+custom range with libinput_event_tablet_tool_get_x_transformed() and
+libinput_event_tablet_tool_get_y_transformed() the resulting value may be
+less than 0 or larger than the upper range provided. It is up to the caller
+to test for this and handle or ignore these events accordingly.
+
 */
diff --git a/src/libinput.h b/src/libinput.h
index b14c281..cf33492 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1562,6 +1562,9 @@ libinput_event_tablet_tool_wheel_has_changed(
  * libinput_event_tablet_tool_get_x_transformed() for transforming the axis
  * value into a different coordinate space.
  *
+ * @note On some devices, returned value may be negative or larger than the
+ * width of the device. See @ref tablet-bounds for more details.
+ *
  * @param event The libinput tablet tool event
  * @return The current value of the the axis
  */
@@ -1576,6 +1579,9 @@ libinput_event_tablet_tool_get_x(struct 
libinput_event_tablet_tool *event);
  * libinput_event_tablet_tool_get_y_transformed() for transforming the axis
  * value into a different coordinate space.
  *
+ * @note On some devices, returned value may be negative or larger than the
+ * width of the device. See @ref tablet-bounds for more details.
+ *
  * @param event The libinput tablet tool event
  * @return The current value of the the axis
  */
@@ -1754,6 +1760,9 @@ libinput_event_tablet_tool_get_wheel_delta_discrete(
  * libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
  * libinput always includes all device axes in the