Re: [PATCH] shell: Destroy the shell_surface when the xdg_shell interface gets destroyed

2014-06-12 Thread Sjoerd Simons
On Wed, 2014-06-04 at 13:44 +0200, Sjoerd Simons wrote:
 When running gtk3-demo under weston opening comboboxes a second time
 causes the program to bail due to weston returning an error. The
 relevant client trace in this case is:
  - xdg_shell@15.get_xdg_popup(new id xdg_popup@12, wl_surface@28, 
  - xdg_popup@12.destroy()
  - xdg_shell@15.get_xdg_popup(new id xdg_popup@19, wl_surface@28, 
   wl_display@1.error(wl_surface@28, 0,
 xdg_shell::get_xdg_popup already requested)
 
 However, according to the xdg_shell protocol this should be valid as
 calling destroy should remove the xdg_popup interface from the
 wl_surface object.
 
 Fix this by ensuring the internal shell surface also gets destroyed when
 the relevant xdg interface is destroyed and not just when the underlying
 wl_surface gets destroyed.
 
 This patch applies both to Weston 1.5 and master, please apply to both
 if correct.

Turns out this patch is, in fact, not correct. The desktop-shell code
seems to have a bigger assumption on the shell surface having a lifetime
bound to the underlying wl_surface then i first thought. The patch
causes weston to crash if the fade-out animation is running when the xdg
shell surface is destroyed.

One solution here is to rework the code so the shell surface can be
destroyed  recreated seperately. Another one would be to get xdg_shell
more in line with wl_shell when it comes to life-time rules. 

I've put together an initial patch for GTK+ such that it doesn't try to
re-create xdg_shell surfaces anymore and essentially assumes the xdg
surfaces are once-only per wl_surface:
  https://bugzilla.gnome.org/show_bug.cgi?id=727021#c3



 ---
  desktop-shell/shell.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
 index 46c6e18..45a3321 100644
 --- a/desktop-shell/shell.c
 +++ b/desktop-shell/shell.c
 @@ -3153,6 +3153,7 @@ destroy_shell_surface(struct shell_surface *shsurf)
   /* As destroy_resource() use wl_list_for_each_safe(),
* we can always remove the listener.
*/
 + wl_list_remove(shsurf-resource_destroy_listener.link);
   wl_list_remove(shsurf-surface_destroy_listener.link);
   shsurf-surface-configure = NULL;
   free(shsurf-title);
 @@ -3175,6 +3176,7 @@ shell_destroy_shell_surface(struct wl_resource 
 *resource)
   if (!wl_list_empty(shsurf-popup.grab_link))
   remove_popup_grab(shsurf);
   shsurf-resource = NULL;
 + destroy_shell_surface(shsurf);
  }
  
  static void




smime.p7s
Description: S/MIME cryptographic signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Wayland generic dmabuf protocol

2014-06-12 Thread Rob Clark
On Wed, Jun 11, 2014 at 2:26 AM, Thomas Hellstrom thellst...@vmware.com wrote:
 On 06/09/2014 01:23 PM, Daniel Stone wrote:
 Hi,

 On 9 June 2014 12:06, Pekka Paalanen pekka.paala...@collabora.co.uk
 mailto:pekka.paala...@collabora.co.uk wrote:

 On Mon, 9 Jun 2014 11:00:04 +0200
 Benjamin Gaignard benjamin.gaign...@linaro.org
 mailto:benjamin.gaign...@linaro.org wrote:
  One of the main comment on the latest patches was that wl_dmabuf use
  DRM for buffer allocation.
  This appear to be an issue since wayland doesn't want to rely on one
  specific framework (DRM, or V4L2) for buffer allocation, so we have
  start working on a central dmabuf allocation on kernel side. The
  goal is provide some as generic as possible to make it acceptable by
  wayland.

 Why would Wayland need a central allocator for dmabuf?


 I think you've just answered your own question further below:


  On my hardware the patches you have (+ this one on gstwaylandsink
  https://bugzilla.gnome.org/show_bug.cgi?id=711155
 
 https://urldefense.proofpoint.com/v1/url?u=https://bugzilla.gnome.org/show_bug.cgi?id%3D711155k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=l5Ago9ekmVFZ3c4M6eauqrJWGwjf6fTb%2BP3CxbBFkVM%3D%0Am=NHSSDNdXVt2oCxexwhcqQAQSZ3K6Xa8Zvuv0jMYfS2c%3D%0As=f6d8c24d7fa4ccdacae79aeaa8221773d892350a191f96cb3bab4f542fb3ad1c)
 allow me to do zero
  copy between the hardware video decoder and the display engine. I
  don't have implemented GPU yet because my hardware is able to do
  compose few video overlays planes and it was enough for my tests.

 Right.

 What I have been thinking is, that the compositor must be able to use
 the new wl_buffer and we need to guarantee that before-hand. If the
 compositor fails to use a wl_buffer when the client has already
 attached it to a wl_surface and it is time to repaint, it is too late
 and the user will see a glitch. Recovering from that requires asking
 the client to provide a new wl_buffer of a different kind, which might
 take time. Or a very rude compositor would just send a protocol error,
 and then we'd get bug reports like the video player just disappears
 when I try to play (and ps. I have an old kernel that doesn't support
 importing whatever).

 I believe we must allow the compositor to test the wl_buffer before it
 is usable for the client. That is the reason for the roundtrippy
 design
 of the below proposal.


 A central allocator would solve these issues, by having everyone agree
 on the restrictions upfront, instead of working out which of the media
 decode engine, camera, GPU, or display controller is the lowest common
 denominator, and forcing all allocations through there.

 One such solution was discussed a while back WRT ION:
 https://lwn.net/Articles/565469/
 https://urldefense.proofpoint.com/v1/url?u=https://lwn.net/Articles/565469/k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=l5Ago9ekmVFZ3c4M6eauqrJWGwjf6fTb%2BP3CxbBFkVM%3D%0Am=NHSSDNdXVt2oCxexwhcqQAQSZ3K6Xa8Zvuv0jMYfS2c%3D%0As=36b71b58f7fc6f3d594529cc674364a23718e5cbb38a439e4a9c628848a13b3a

 See the 'possible solutions' part for a way for people to agree on
 restrictions wrt tiling, stride, contiguousness, etc.

 Hi!

 I think before deciding on something like this, one needs also to
 account for the virtual drivers like vmwgfx.

 Here, a dma-buf internally holds an opaque handle to an object on the
 host / hypervisor, and the actual memory buffer is only temporarily
 allocated for dma-buf operations that strictly need it. Not to hold the
 data while transferring it between devices or applications.

 Let's say you'd want to use a USB display controller in a virtual
 machine with the vmwgfx exported prime objects, for example. There's no
 common denominator. The vmwgfx driver would need to read the dma-buf
 data from the host object at sg-table export (dma-buf map) time.

 Whereas if you just want to share data between a wayland server and
 client, no pages are ever allocated and the only thing passed
 around is in effect the opaque handle to the host / hypervisor object.

 I'm currently having trouble seeing how a central allocator would be
 able to deal with this?

well, central standalone allocator device would need to know about all
possible devices.  Works ok in a cell phone.  I don't really see it
scaling well to desktop, so it isn't really an option.

BR,
-R

 /Thomas












 Cheers,
 Daniel


 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/wayland-develk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=l5Ago9ekmVFZ3c4M6eauqrJWGwjf6fTb%2BP3CxbBFkVM%3D%0Am=NHSSDNdXVt2oCxexwhcqQAQSZ3K6Xa8Zvuv0jMYfS2c%3D%0As=c4f94901274570868164b5aac297336d544bdba1bc12bda6c09b915fa5495423
___
wayland-devel mailing list

[PATCH libinput 1/3] test: move the interface declaration down

2014-06-12 Thread Peter Hutterer
No functional changes, just some prep work.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 test/litest.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index 0a9cc72..d3f8f0d 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -267,6 +267,23 @@ litest_log_handler(enum libinput_log_priority pri,
vfprintf(stderr, format, args);
 }
 
+static int
+open_restricted(const char *path, int flags, void *userdata)
+{
+   return open(path, flags);
+}
+
+static void
+close_restricted(int fd, void *userdata)
+{
+   close(fd);
+}
+
+struct libinput_interface interface = {
+   .open_restricted = open_restricted,
+   .close_restricted = close_restricted,
+};
+
 static const struct option opts[] = {
{ list, 0, 0, 'l' },
{ verbose, 0, 0, 'v' },
@@ -335,24 +352,6 @@ litest_run(int argc, char **argv) {
return failed;
 }
 
-static int
-open_restricted(const char *path, int flags, void *userdata)
-{
-   return open(path, flags);
-}
-
-static void
-close_restricted(int fd, void *userdata)
-{
-   close(fd);
-}
-
-const struct libinput_interface interface = {
-   .open_restricted = open_restricted,
-   .close_restricted = close_restricted,
-};
-
-
 static struct input_absinfo *
 merge_absinfo(const struct input_absinfo *orig,
  const struct input_absinfo *override)
-- 
1.9.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 3/3] Change the logging system to be per-context

2014-06-12 Thread Peter Hutterer
Rather than a single global logging function, make the logging dependent on
the individual context. This way we won't stomp on each other's feet in the
(admittedly unusual) case of having multiple libinput contexts.

The log handler and the log priority is now a part of the libinput interface.
We can drop the various setters and getters, the caller owns the struct anyway
so we don't need functions to give it those values.

The userdata argument to the log handler was dropped. The caller has a ref to
the libinput context now, any userdata can be attached to that context
instead.

There is no need for a default log function anymore. Any serious caller should
hook into it anyway, those that don't care can just use NULL.

There is no default log priority anymore, a caller must set the desired
priority in the interface.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
There's a side-effect to this that I'm not sure is intended. We don't copy
the interface into libinput, we merely keep a reference. The caller is
already able to change open_restricted/close_restricted at runtime, though
we can't do this ourselves (it's const).

Given that, I figured we can leave the log handler and priority up to the
caller as well then, switching at runtime. That's the main reason for
dropping the set/get priority calls. If that side effect wasn't intended,
then we'll have rework a few things. Jonas?

 src/evdev-mt-touchpad-buttons.c |  15 +++--
 src/evdev-mt-touchpad-tap.c |  13 -
 src/evdev.c |  23 +---
 src/libinput-private.h  |  20 ---
 src/libinput.c  |  73 ++-
 src/libinput.h  |  99 +--
 src/path.c  |  20 +--
 src/timer.c |   4 +-
 src/udev-seat.c |  17 +++---
 test/litest.c   |   9 +--
 test/log.c  | 126 ++--
 test/misc.c |   2 +
 test/path.c |   2 +
 test/udev.c |   7 ++-
 tools/event-debug.c |  28 -
 15 files changed, 194 insertions(+), 264 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index ce48ed0..b86f344 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -452,6 +452,7 @@ tp_button_handle_event(struct tp_dispatch *tp,
   enum button_event event,
   uint64_t time)
 {
+   struct libinput *libinput = tp-device-base.seat-libinput;
enum button_state current = t-button.state;
 
switch(t-button.state) {
@@ -485,7 +486,8 @@ tp_button_handle_event(struct tp_dispatch *tp,
}
 
if (current != t-button.state)
-   log_debug(button state: from %s, event %s to %s\n,
+   log_debug(libinput,
+ button state: from %s, event %s to %s\n,
  button_state_to_str(current),
  button_event_to_str(event),
  button_state_to_str(t-button.state));
@@ -538,11 +540,13 @@ tp_process_button(struct tp_dispatch *tp,
  const struct input_event *e,
  uint64_t time)
 {
+   struct libinput *libinput = tp-device-base.seat-libinput;
uint32_t mask = 1  (e-code - BTN_LEFT);
 
/* Ignore other buttons on clickpads */
if (tp-buttons.is_clickpad  e-code != BTN_LEFT) {
-   log_bug_kernel(received %s button event on a clickpad\n,
+   log_bug_kernel(libinput,
+  received %s button event on a clickpad\n,
   libevdev_event_code_get_name(EV_KEY, e-code));
return 0;
}
@@ -562,6 +566,7 @@ int
 tp_init_buttons(struct tp_dispatch *tp,
struct evdev_device *device)
 {
+   struct libinput *libinput = tp-device-base.seat-libinput;
struct tp_touch *t;
int width, height;
double diagonal;
@@ -574,10 +579,12 @@ tp_init_buttons(struct tp_dispatch *tp,
if (libevdev_has_event_code(device-evdev, EV_KEY, BTN_MIDDLE) ||
libevdev_has_event_code(device-evdev, EV_KEY, BTN_RIGHT)) {
if (tp-buttons.is_clickpad)
-   log_bug_kernel(clickpad advertising right button\n);
+   log_bug_kernel(libinput,
+  clickpad advertising right button\n);
} else {
if (!tp-buttons.is_clickpad)
-   log_bug_kernel(non clickpad without right button?\n);
+   log_bug_kernel(libinput,
+  non clickpad without right button?\n);
}
 
width = abs(device-abs.max_x - device-abs.min_x);
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 34bb0d0..2541218 100644

[PATCH libinput 2/3] udev: split libinput_udev context init into two functions

2014-06-12 Thread Peter Hutterer
This is preparation work for context-specific log handlers.

Callers are now encouraged to first initialize the context with
libinput_udev_create_context() and then set the seat for this context with
libinput_udev_set_seat().

In the upcoming patch to support context-specific log handlers this enables a
caller to set the log handler for a context before any devices are
initialized. Otherwise, a log message generated by a new device may pass a
libinput context that the caller is not yet aware of.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
 doc/libinput.doxygen.in |  3 ++-
 src/libinput.h  | 49 +++-
 src/udev-seat.c | 54 +
 test/udev.c | 48 ---
 tools/event-debug.c |  8 +++-
 5 files changed, 130 insertions(+), 32 deletions(-)

diff --git a/doc/libinput.doxygen.in b/doc/libinput.doxygen.in
index f78b7cf..9f931c3 100644
--- a/doc/libinput.doxygen.in
+++ b/doc/libinput.doxygen.in
@@ -1570,7 +1570,8 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator
 # instead of the = operator.
 
-PREDEFINED = LIBINPUT_ATTRIBUTE_PRINTF(f,a)=
+PREDEFINED = LIBINPUT_ATTRIBUTE_PRINTF(f, a)= \
+LIBINPUT_ATTRIBUTE_DEPRECATED
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
 # this tag can be used to specify a list of macro names that should be 
expanded.
diff --git a/src/libinput.h b/src/libinput.h
index 54c96e5..4501c66 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -33,6 +33,7 @@ extern C {
 
 #define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args) \
__attribute__ ((format (printf, _format, _args)))
+#define LIBINPUT_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
 
 /**
  * @mainpage
@@ -784,6 +785,47 @@ struct libinput_interface {
 /**
  * @ingroup base
  *
+ * Create a new libinput context from udev. This context is inactive until
+ * assigned a seat ID with libinput_udev_set_seat().
+ *
+ * @param interface The callback interface
+ * @param user_data Caller-specific data passed to the various callback
+ * interfaces.
+ * @param udev An already initialized udev context
+ *
+ * @return An initialized, but inactive libinput context or NULL on error
+ */
+struct libinput *
+libinput_udev_create_context(const struct libinput_interface *interface,
+void *user_data,
+struct udev *udev);
+
+/**
+ * @ingroup base
+ *
+ * Assign a seat to this libinput context. New devices or the removal of
+ * existing devices will appear as events during libinput_dispatch().
+ *
+ * libinput_udev_set_seat() succeeds even if no input devices are currently
+ * available on this seat, or if devices are available but fail to open in
+ * @ref libinput_interface::open_restricted. Devices that do not have the
+ * minimum capabilities to be recognized as pointer, keyboard or touch
+ * device are ignored. Such devices and those that failed to open
+ * ignored until the next call to libinput_resume().
+ *
+ * @param libinput A libinput context initialized with
+ * libinput_udev_create_context()
+ * @param seat_id A seat identifier. This string must not be NULL.
+ *
+ * @return 0 on success or -1 on failure.
+ */
+int
+libinput_udev_set_seat(struct libinput *libinput,
+  const char *seat_id);
+
+/**
+ * @ingroup base
+ *
  * Create a new libinput context from udev, for input devices matching
  * the given seat ID. New devices or devices removed will appear as events
  * during libinput_dispatch.
@@ -803,12 +845,17 @@ struct libinput_interface {
  *
  * @return An initialized libinput context, ready to handle events or NULL on
  * error.
+ *
+ * @deprecated This function was deprecated in 0.4.0 and will be removed
+ * soon. Use libinput_udev_create_context() and libinput_udev_set_seat()
+ * instead.
  */
 struct libinput *
 libinput_udev_create_for_seat(const struct libinput_interface *interface,
  void *user_data,
  struct udev *udev,
- const char *seat_id);
+ const char *seat_id)
+   LIBINPUT_ATTRIBUTE_DEPRECATED;
 
 /**
  * @ingroup base
diff --git a/src/udev-seat.c b/src/udev-seat.c
index 38a13b7..1e1307b 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -333,14 +333,13 @@ static const struct libinput_interface_backend 
interface_backend = {
 };
 
 LIBINPUT_EXPORT struct libinput *
-libinput_udev_create_for_seat(const struct libinput_interface *interface,
- void *user_data,
- struct udev *udev,
- const char *seat_id)
+libinput_udev_create_context(const struct libinput_interface *interface,
+void *user_data,
+struct udev 

[PATCH libinput 0/3] Per-context log handlers

2014-06-12 Thread Peter Hutterer

This work was motivated by libevdev, which too started out with a global log
   
handler, and that's biting us now. libevdev is lower-level than libinput, so
   
there's a higher chance of two unrelated bits loading libevdev into the same
   
process. Nonetheless, having a global log handler in a library makes me a   
   
bit nervous now.
   

   
This patchset changes over to a per-context log handler and that breaks the 
   
API in a couple of ways:
   
* the libinput context is now passed into the log function  
   
* the user_data pointer was dropped, use the context's user data if needed  
   
* the log handler/priority is now part of the libinput_interface and managed
   
  by the caller, not by libinput (hence all the libinput_set/get_log*   
   
  functions are gone)   
   
* the udev context creation was split up so we can give the client a
   
  context before calling a log function that uses that context. I've left   
   
  the old function there for now for some backwards compatibility but tbh   
   
  given that everything else changes I think we should just drop
   
  libinput_udev_create_for_seat().  
   

   
Cheers, 
   
  Peter   
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 08/23] tools: Handle LIBINPUT_EVENT_TABLET_PROXIMITY_OUT in event-debug

2014-06-12 Thread Stephen Chandler Paul
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
Reviewed-by: Peter Hutterer peter.hutte...@who-t.net
---
 tools/event-debug.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 7ba1e64..90cdd64 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -221,6 +221,9 @@ print_event_header(struct libinput_event *ev)
case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
type = TABLET_TOOL_UPDATE;
break;
+   case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
+   type = TABLET_PROXIMITY_OUT;
+   break;
}
 
printf(%-7s%s  , libinput_device_get_sysname(dev), type);
@@ -319,6 +322,7 @@ print_pointer_axis_event(struct libinput_event *ev)
val = libinput_event_pointer_get_axis_value(p);
printf(%s %.2f\n, ax, val);
 }
+
 static void
 print_tablet_axis_event(struct libinput_event *ev)
 {
@@ -402,6 +406,14 @@ print_tool_update_event(struct libinput_event *ev)
 }
 
 static void
+print_proximity_out_event(struct libinput_event *ev) {
+   struct libinput_event_tablet *t = libinput_event_get_tablet_event(ev);
+
+   print_event_time(libinput_event_tablet_get_time(t));
+   printf(\n);
+}
+
+static void
 print_touch_event_with_coords(struct libinput_event *ev)
 {
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
@@ -469,6 +481,9 @@ handle_and_print_events(struct libinput *li)
case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
print_tool_update_event(ev);
break;
+   case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
+   print_proximity_out_event(ev);
+   break;
}
 
libinput_event_destroy(ev);
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 00/23] Revised: Tablet support in libinput

2014-06-12 Thread Stephen Chandler Paul
Hello! I've done a ton of revisions and changes to the patches Carlos sent a 
little while ago to add tablet support to libinput. Feel free to let me know 
what you think.

* Tablet events are now in their own group of events.
* Tool update events are no longer emitted when the tool leaves proximity,
  they have been replaced with a more specific
  LIBINPUT_EVENT_TABLET_PROXIMITY_OUT event. This is similar to how X
  handles tools going out of proximity.
* Normalization is now done for both the tilt axes and the pressure axes.
  Pressure is normalized from 0 to 1, and tilt is normalized from *1 to 1. All
  of the other axes are left as-is.
* Axis changes are now compressed into a single TABLET_AXIS_UPDATE event. The
  event contains a bitmask of the changed axes that can be accessed with
  libinput_event_tablet_axis_has_changed(). These bitfields are internally
  managed using modified versions of some of the bitfield helpers from
  libevdev.
* During an axis update, the collected values of all of the axes are available
  to the caller using libinput_event_tablet_axis_get_value(), regardless of
  whether or not they actually updated.
* Tools are now abstracted by libinput as objects. Each tool object contains
  the tool type and the serial number of the tool. These can be retrieved with
  libinput_tool_get_serial() and libinput_tool_get_type().
* Tools now have ref counts and are stored internally in a list. By default,
  every tool is destroyed at the end of an event, but if the caller wishes
  they can increment the reference count of the tool. When this happens, the
  tool is kept in the list and whenever that tool comes into proximity of the
  tablet again the same object whose ref count was incremented is returned by
  libinput.
* Other miscellanious fixes and additions
* Style fixes

Carlos Garnacho (6):
  Add LIBINPUT_DEVICE_CAP_TABLET libinput_device_capability value
  test: Add infrastructure for testing tablet events.
  test: Add Wacom Bamboo 16FG 4x5 Pen device definition
  test: Add Wacom Cintiq 12WX device definition
  test: Add Wacom Intuos5 touch M Pen device definition
  test: Add Wacom ISDv4 E6 Pen device definition

Stephen Chandler Paul (17):
  evdev: Add basic support for tablet devices
  tools: handle TABLET_EVENT_AXIS in event-debug
  Add the libinput_tool object
  Emit LIBINPUT_TABLET_EVENT_TOOL_UPDATE events on tool changes
  tools: handle LIBINPUT_TABLET_EVENT_TOOL_UPDATE in event-debug
  Emit LIBINPUT_EVENT_TABLET_PROXIMITY_OUT when tool leaves proximity
  tools: Handle LIBINPUT_EVENT_TABLET_PROXIMITY_OUT in event-debug
  tablet: Handle button-events
  tools: handle tablet button events in event-debug
  tablet: Report and normalize distance, pressure, and tilt axes
  Sanitize distance and pressure axes before reporting their values
  tools: Handle pressure, tilt, and distance in event-debug
  test: Add litest_assert_double_*() macros
  test: Add proximity-in-out and proximity-out-clear-buttons tests
  test: Add motion event test for tablets
  test: Add bad-distance-events test
  test: Add tests for normalization

 src/Makefile.am   |   2 +
 src/evdev-tablet.c| 469 +
 src/evdev-tablet.h|  93 
 src/evdev.c   |  10 +
 src/evdev.h   |   6 +-
 src/libinput-private.h|  27 +++
 src/libinput-util.h   |   2 +
 src/libinput.c| 256 
 src/libinput.h| 292 ++-
 test/Makefile.am  |  10 +
 test/litest-int.h |   8 +
 test/litest-wacom-bamboo-tablet.c | 105 +
 test/litest-wacom-cintiq-tablet.c | 136 +++
 test/litest-wacom-intuos-tablet.c | 134 +++
 test/litest-wacom-isdv4-tablet.c  |  98 
 test/litest.c |  97 
 test/litest.h |  31 +++
 test/tablet.c | 481 ++
 tools/event-debug.c   | 140 ++-
 19 files changed, 2390 insertions(+), 7 deletions(-)
 create mode 100644 src/evdev-tablet.c
 create mode 100644 src/evdev-tablet.h
 create mode 100644 test/litest-wacom-bamboo-tablet.c
 create mode 100644 test/litest-wacom-cintiq-tablet.c
 create mode 100644 test/litest-wacom-intuos-tablet.c
 create mode 100644 test/litest-wacom-isdv4-tablet.c
 create mode 100644 test/tablet.c

-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 07/23] Emit LIBINPUT_EVENT_TABLET_PROXIMITY_OUT when tool leaves proximity

2014-06-12 Thread Stephen Chandler Paul
This event is just used to notify the caller when the tool's no longer in
proximity. When an event like this occurs, everything from evdev up until the
next EV_SYN event is discarded along with any events that occured since the last
EV_SYN event. This also silences any tool update events where the tool type is
changed to LIBINPUT_TOOL_NONE, so we don't end up filling the tool list with a
bunch of tools that aren't actually tools.

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 src/evdev-tablet.c | 25 +
 src/evdev-tablet.h |  3 ++-
 src/libinput-private.h |  4 
 src/libinput.c | 24 
 src/libinput.h | 11 ---
 5 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 52b3c93..278890d 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -78,6 +78,8 @@ tablet_update_tool(struct tablet_dispatch *tablet,
tablet-current_tool_type = tool;
tablet_set_status(tablet, TABLET_TOOL_UPDATED);
}
+   else if (!enabled)
+   tablet_set_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
 }
 
 static void
@@ -189,12 +191,27 @@ tablet_flush(struct tablet_dispatch *tablet,
 struct evdev_device *device,
 uint32_t time)
 {
-   if (tablet_has_status(tablet, TABLET_TOOL_UPDATED))
-   tablet_notify_tool(tablet, device, time);
+   if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
+   memset(tablet-changed_axes, 0, sizeof(tablet-changed_axes));
+   memset(tablet-axes, 0, sizeof(tablet-axes));
 
-   if (tablet_has_status(tablet, TABLET_AXES_UPDATED)) {
-   tablet_notify_axes(tablet, device, time);
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
+   } else {
+   if (tablet_has_status(tablet, TABLET_TOOL_UPDATED)) {
+   tablet_notify_tool(tablet, device, time);
+   tablet_unset_status(tablet, TABLET_TOOL_UPDATED);
+   }
+
+   if (tablet_has_status(tablet, TABLET_AXES_UPDATED)) {
+   tablet_notify_axes(tablet, device, time);
+   tablet_unset_status(tablet, TABLET_AXES_UPDATED);
+   }
+   }
+
+   /* We want button releases to be sent before the proximity out event */
+   if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
+   tablet_notify_proximity_out(device-base, time);
+   tablet_unset_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
}
 }
 
diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h
index dd5988c..4727ed8 100644
--- a/src/evdev-tablet.h
+++ b/src/evdev-tablet.h
@@ -30,7 +30,8 @@
 enum tablet_status {
TABLET_NONE = 0,
TABLET_AXES_UPDATED = 1  0,
-   TABLET_TOOL_UPDATED = 1  1
+   TABLET_TOOL_UPDATED = 1  1,
+   TABLET_TOOL_LEAVING_PROXIMITY = 1  2
 };
 
 struct tablet_dispatch {
diff --git a/src/libinput-private.h b/src/libinput-private.h
index c2ff194..2db92cd 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -213,6 +213,10 @@ tablet_notify_tool_update(struct libinput_device *device,
  struct libinput_tool *tool);
 
 void
+tablet_notify_proximity_out(struct libinput_device *device,
+   uint32_t time);
+
+void
 touch_notify_frame(struct libinput_device *device,
   uint32_t time);
 #endif /* LIBINPUT_PRIVATE_H */
diff --git a/src/libinput.c b/src/libinput.c
index d5f4ec3..b37f8f6 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -201,6 +201,7 @@ libinput_event_get_pointer_event(struct libinput_event 
*event)
case LIBINPUT_EVENT_TOUCH_FRAME:
case LIBINPUT_EVENT_TABLET_AXIS:
case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
+   case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
break;
}
 
@@ -229,6 +230,7 @@ libinput_event_get_keyboard_event(struct libinput_event 
*event)
case LIBINPUT_EVENT_TOUCH_FRAME:
case LIBINPUT_EVENT_TABLET_AXIS:
case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
+   case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
break;
}
 
@@ -257,6 +259,7 @@ libinput_event_get_touch_event(struct libinput_event *event)
return (struct libinput_event_touch *) event;
case LIBINPUT_EVENT_TABLET_AXIS:
case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
+   case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
break;
}
 
@@ -284,6 +287,7 @@ libinput_event_get_tablet_event(struct libinput_event 
*event)
break;
case LIBINPUT_EVENT_TABLET_AXIS:
case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
+   case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
return (struct libinput_event_tablet *) event;
}
 
@@ -311,6 +315,7 @@ libinput_event_get_device_notify_event(struct 

[PATCH libinput 10/23] tools: handle tablet button events in event-debug

2014-06-12 Thread Stephen Chandler Paul
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
Reviewed-by: Peter Hutterer peter.hutte...@who-t.net
---
 tools/event-debug.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 90cdd64..13b86a4 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -224,6 +224,9 @@ print_event_header(struct libinput_event *ev)
case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
type = TABLET_PROXIMITY_OUT;
break;
+   case LIBINPUT_EVENT_TABLET_BUTTON:
+   type = TABLET_BUTTON;
+   break;
}
 
printf(%-7s%s  , libinput_device_get_sysname(dev), type);
@@ -285,7 +288,7 @@ print_absmotion_event(struct libinput_event *ev)
 }
 
 static void
-print_button_event(struct libinput_event *ev)
+print_pointer_button_event(struct libinput_event *ev)
 {
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
enum libinput_button_state state;
@@ -300,6 +303,21 @@ print_button_event(struct libinput_event *ev)
 }
 
 static void
+print_tablet_button_event(struct libinput_event *ev)
+{
+   struct libinput_event_tablet *p = libinput_event_get_tablet_event(ev);
+   enum libinput_button_state state;
+
+   print_event_time(libinput_event_tablet_get_time(p));
+
+   state = libinput_event_tablet_get_button_state(p);
+   printf(%3d %s, seat count: %u\n,
+  libinput_event_tablet_get_button(p),
+  state == LIBINPUT_BUTTON_STATE_PRESSED ? pressed : released,
+  libinput_event_tablet_get_seat_button_count(p));
+}
+
+static void
 print_pointer_axis_event(struct libinput_event *ev)
 {
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
@@ -455,7 +473,7 @@ handle_and_print_events(struct libinput *li)
print_absmotion_event(ev);
break;
case LIBINPUT_EVENT_POINTER_BUTTON:
-   print_button_event(ev);
+   print_pointer_button_event(ev);
break;
case LIBINPUT_EVENT_POINTER_AXIS:
print_pointer_axis_event(ev);
@@ -484,6 +502,9 @@ handle_and_print_events(struct libinput *li)
case LIBINPUT_EVENT_TABLET_PROXIMITY_OUT:
print_proximity_out_event(ev);
break;
+   case LIBINPUT_EVENT_TABLET_BUTTON:
+   print_tablet_button_event(ev);
+   break;
}
 
libinput_event_destroy(ev);
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 01/23] Add LIBINPUT_DEVICE_CAP_TABLET libinput_device_capability value

2014-06-12 Thread Stephen Chandler Paul
From: Carlos Garnacho carl...@gnome.org

This capability flag would be enabled when events are driven through
a stylus, ie. on a tablet.

Signed-off-by: Carlos Garnacho carl...@gnome.org
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
Reviewed-by: Peter Hutterer peter.hutte...@who-t.net
---
 src/evdev.c| 2 ++
 src/evdev.h| 3 ++-
 src/libinput.h | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 51ad5e3..03f52e4 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -840,6 +840,8 @@ evdev_device_has_capability(struct evdev_device *device,
return !!(device-seat_caps  EVDEV_DEVICE_KEYBOARD);
case LIBINPUT_DEVICE_CAP_TOUCH:
return !!(device-seat_caps  EVDEV_DEVICE_TOUCH);
+   case LIBINPUT_DEVICE_CAP_TABLET:
+   return !!(device-seat_caps  EVDEV_DEVICE_TABLET);
default:
return 0;
}
diff --git a/src/evdev.h b/src/evdev.h
index d057010..bcb7e79 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -45,7 +45,8 @@ enum evdev_event_type {
 enum evdev_device_seat_capability {
EVDEV_DEVICE_POINTER = (1  0),
EVDEV_DEVICE_KEYBOARD = (1  1),
-   EVDEV_DEVICE_TOUCH = (1  2)
+   EVDEV_DEVICE_TOUCH = (1  2),
+   EVDEV_DEVICE_TABLET = (1  3),
 };
 
 struct mt_slot {
diff --git a/src/libinput.h b/src/libinput.h
index 54c96e5..d6f2588 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -121,7 +121,8 @@ enum libinput_log_priority {
 enum libinput_device_capability {
LIBINPUT_DEVICE_CAP_KEYBOARD = 0,
LIBINPUT_DEVICE_CAP_POINTER = 1,
-   LIBINPUT_DEVICE_CAP_TOUCH = 2
+   LIBINPUT_DEVICE_CAP_TOUCH = 2,
+   LIBINPUT_DEVICE_CAP_TABLET = 3
 };
 
 /**
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 11/23] tablet: Report and normalize distance, pressure, and tilt axes

2014-06-12 Thread Stephen Chandler Paul
Report the values for the distance, pressure, and tilt axes. Pressure is
normalized to a range of 0 to 1, and tilt is normalized to a range of -1 to 1.

Based off the patch originally written by Carlos Garnacho

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 src/evdev-tablet.c | 35 +++
 src/evdev-tablet.h | 15 ++-
 src/libinput.h | 14 +-
 3 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 5143759..8cb7d64 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -53,6 +53,10 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
switch (e-code) {
case ABS_X:
case ABS_Y:
+   case ABS_PRESSURE:
+   case ABS_TILT_X:
+   case ABS_TILT_Y:
+   case ABS_DISTANCE:
axis = evcode_to_axis(e-code);
if (axis == LIBINPUT_TABLET_AXIS_NONE) {
log_bug_libinput(Invalid ABS event code %#x\n,
@@ -87,6 +91,23 @@ tablet_update_tool(struct tablet_dispatch *tablet,
tablet_set_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
 }
 
+static inline double
+normalize_pressure(const struct input_absinfo * absinfo) {
+   double range = absinfo-maximum - absinfo-minimum + 1;
+   double value = (absinfo-value + absinfo-minimum) / range;
+
+   return value;
+}
+
+static inline double
+normalize_tilt(const struct input_absinfo * absinfo) {
+   double range = absinfo-maximum - absinfo-minimum + 1;
+   double value = (absinfo-value + absinfo-minimum) / range;
+
+   /* Map to the (-1, 1) range */
+   return (value * 2) - 1;
+}
+
 static void
 tablet_notify_axes(struct tablet_dispatch *tablet,
   struct evdev_device *device,
@@ -103,8 +124,16 @@ tablet_notify_axes(struct tablet_dispatch *tablet,
switch (a) {
case LIBINPUT_TABLET_AXIS_X:
case LIBINPUT_TABLET_AXIS_Y:
+   case LIBINPUT_TABLET_AXIS_DISTANCE:
tablet-axes[a] = tablet-absinfo[a]-value;
break;
+   case LIBINPUT_TABLET_AXIS_PRESSURE:
+   tablet-axes[a] = 
normalize_pressure(tablet-absinfo[a]);
+   break;
+   case LIBINPUT_TABLET_AXIS_TILT_VERTICAL:
+   case LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL:
+   tablet-axes[a] = normalize_tilt(tablet-absinfo[a]);
+   break;
default:
log_bug_libinput(Invalid axis update: %d\n, a);
break;
@@ -169,6 +198,12 @@ tablet_process_key(struct tablet_dispatch *tablet,
tablet_update_tool(tablet, e-code, e-value);
break;
case BTN_TOUCH:
+   if (e-value)
+   tablet_set_status(tablet, TABLET_STYLUS_IN_CONTACT);
+   else
+   tablet_unset_status(tablet, TABLET_STYLUS_IN_CONTACT);
+
+   /* Fall through */
case BTN_STYLUS:
case BTN_STYLUS2:
default:
diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h
index f309173..ffcf33c 100644
--- a/src/evdev-tablet.h
+++ b/src/evdev-tablet.h
@@ -33,7 +33,8 @@ enum tablet_status {
TABLET_TOOL_UPDATED = 1  1,
TABLET_TOOL_LEAVING_PROXIMITY = 1  2,
TABLET_BUTTONS_PRESSED = 1  3,
-   TABLET_BUTTONS_RELEASED = 1  4
+   TABLET_BUTTONS_RELEASED = 1  4,
+   TABLET_STYLUS_IN_CONTACT = 1  5
 };
 
 struct button_state {
@@ -68,6 +69,18 @@ evcode_to_axis(const uint32_t evcode)
case ABS_Y:
axis = LIBINPUT_TABLET_AXIS_Y;
break;
+   case ABS_DISTANCE:
+   axis = LIBINPUT_TABLET_AXIS_DISTANCE;
+   break;
+   case ABS_PRESSURE:
+   axis = LIBINPUT_TABLET_AXIS_PRESSURE;
+   break;
+   case ABS_TILT_X:
+   axis = LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL;
+   break;
+   case ABS_TILT_Y:
+   axis = LIBINPUT_TABLET_AXIS_TILT_VERTICAL;
+   break;
default:
axis = LIBINPUT_TABLET_AXIS_NONE;
break;
diff --git a/src/libinput.h b/src/libinput.h
index 64f460c..8e57499 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -179,7 +179,11 @@ enum libinput_tablet_axis {
LIBINPUT_TABLET_AXIS_NONE = -1,
LIBINPUT_TABLET_AXIS_X = 0,
LIBINPUT_TABLET_AXIS_Y = 1,
-   LIBINPUT_TABLET_AXIS_CNT = LIBINPUT_TABLET_AXIS_Y + 1
+   LIBINPUT_TABLET_AXIS_DISTANCE = 2,
+   LIBINPUT_TABLET_AXIS_PRESSURE = 3,
+   LIBINPUT_TABLET_AXIS_TILT_VERTICAL = 4,
+   LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL = 5,
+   LIBINPUT_TABLET_AXIS_CNT = LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL + 1
 };
 
 /**
@@ -865,6 +869,14 @@ libinput_event_tablet_axis_has_changed(struct 
libinput_event_tablet *event,
  *   however libinput provides 

[PATCH libinput 06/23] tools: handle LIBINPUT_TABLET_EVENT_TOOL_UPDATE in event-debug

2014-06-12 Thread Stephen Chandler Paul
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
Reviewed-by: Peter Hutterer peter.hutte...@who-t.net
---
 tools/event-debug.c | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 5202fc9..7ba1e64 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -218,6 +218,9 @@ print_event_header(struct libinput_event *ev)
case LIBINPUT_EVENT_TABLET_AXIS:
type = TABLET_AXIS;
break;
+   case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
+   type = TABLET_TOOL_UPDATE;
+   break;
}
 
printf(%-7s%s  , libinput_device_get_sysname(dev), type);
@@ -355,6 +358,50 @@ print_touch_event_without_coords(struct libinput_event *ev)
 }
 
 static void
+print_tool_update_event(struct libinput_event *ev)
+{
+   struct libinput_event_tablet *t = libinput_event_get_tablet_event(ev);
+   struct libinput_tool *tool = libinput_event_tablet_get_tool(t);
+   const char *tool_str;
+
+   switch (libinput_tool_get_type(tool)) {
+   case LIBINPUT_TOOL_NONE:
+   tool_str = none;
+   break;
+   case LIBINPUT_TOOL_PEN:
+   tool_str = pen;
+   break;
+   case LIBINPUT_TOOL_ERASER:
+   tool_str = eraser;
+   break;
+   case LIBINPUT_TOOL_BRUSH:
+   tool_str = brush;
+   break;
+   case LIBINPUT_TOOL_PENCIL:
+   tool_str = pencil;
+   break;
+   case LIBINPUT_TOOL_AIRBRUSH:
+   tool_str = airbrush;
+   break;
+   case LIBINPUT_TOOL_FINGER:
+   tool_str = finger;
+   break;
+   case LIBINPUT_TOOL_MOUSE:
+   tool_str = mouse;
+   break;
+   case LIBINPUT_TOOL_LENS:
+   tool_str = lens;
+   break;
+   default:
+   abort();
+   }
+
+   print_event_time(libinput_event_tablet_get_time(t));
+   printf(%s (%#x), tool_str, libinput_tool_get_serial(tool));
+   printf(\n);
+}
+
+static void
 print_touch_event_with_coords(struct libinput_event *ev)
 {
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
@@ -419,6 +466,9 @@ handle_and_print_events(struct libinput *li)
case LIBINPUT_EVENT_TABLET_AXIS:
print_tablet_axis_event(ev);
break;
+   case LIBINPUT_EVENT_TABLET_TOOL_UPDATE:
+   print_tool_update_event(ev);
+   break;
}
 
libinput_event_destroy(ev);
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 13/23] tools: Handle pressure, tilt, and distance in event-debug

2014-06-12 Thread Stephen Chandler Paul
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
Reviewed-by: Peter Hutterer peter.hutte...@who-t.net
---
 tools/event-debug.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 13b86a4..9a5ece2 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -364,6 +364,18 @@ print_tablet_axis_event(struct libinput_event *ev)
case LIBINPUT_TABLET_AXIS_Y:
ax = y;
break;
+   case LIBINPUT_TABLET_AXIS_DISTANCE:
+   ax = distance;
+   break;
+   case LIBINPUT_TABLET_AXIS_PRESSURE:
+   ax = pressure;
+   break;
+   case LIBINPUT_TABLET_AXIS_TILT_VERTICAL:
+   ax = ytilt;
+   break;
+   case LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL:
+   ax = xtilt;
+   break;
}
val = libinput_event_tablet_get_axis_value(t, a);
printf(\t%s = %.2f\n, ax, val);
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 04/23] Add the libinput_tool object

2014-06-12 Thread Stephen Chandler Paul
This will be used to represent a tool in use on a drawing tablet.

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
Reviewed-by: Peter Hutterer peter.hutte...@who-t.net
---
 src/libinput-private.h |  7 +
 src/libinput.c | 29 
 src/libinput.h | 73 ++
 3 files changed, 109 insertions(+)

diff --git a/src/libinput-private.h b/src/libinput-private.h
index f6ba51c..83906f5 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -85,6 +85,13 @@ struct libinput_device {
int refcount;
 };
 
+struct libinput_tool {
+   struct list link;
+   uint32_t serial;
+   enum libinput_tool_type type;
+   int refcount;
+};
+
 typedef void (*libinput_source_dispatch_t)(void *data);
 
 
diff --git a/src/libinput.c b/src/libinput.c
index fee500e..def3e91 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -514,6 +514,35 @@ libinput_event_tablet_get_time(struct 
libinput_event_tablet *event)
return event-time;
 }
 
+LIBINPUT_EXPORT enum libinput_tool_type
+libinput_tool_get_type(struct libinput_tool *tool)
+{
+   return tool-type;
+}
+
+LIBINPUT_EXPORT uint32_t
+libinput_tool_get_serial(struct libinput_tool *tool)
+{
+   return tool-serial;
+}
+
+LIBINPUT_EXPORT void
+libinput_tool_ref(struct libinput_tool *tool)
+{
+   tool-refcount++;
+}
+
+LIBINPUT_EXPORT void
+libinput_tool_unref(struct libinput_tool *tool)
+{
+   assert(tool-refcount  0);
+
+   if (--tool-refcount == 0) {
+   list_remove(tool-link);
+   free(tool);
+   }
+}
+
 struct libinput_source *
 libinput_add_fd(struct libinput *libinput,
int fd,
diff --git a/src/libinput.h b/src/libinput.h
index 18bb726..c0c9fae 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -183,6 +183,32 @@ enum libinput_tablet_axis {
 };
 
 /**
+ * @ingroup device
+ *
+ * An object representing a tool being used by the device. It must have the 
@ref
+ * LIBINPUT_DEVICE_CAP_TABLET capability.
+ */
+struct libinput_tool;
+
+/**
+ * @ingroup device
+ *
+ * Available tool types for a device. It must have the @ref
+ * LIBINPUT_DEVICE_CAP_TABLET capability.
+ */
+enum libinput_tool_type {
+   LIBINPUT_TOOL_NONE = -1,
+   LIBINPUT_TOOL_PEN = 0x140, /* Matches BTN_TOOL_PEN */
+   LIBINPUT_TOOL_ERASER,
+   LIBINPUT_TOOL_BRUSH,
+   LIBINPUT_TOOL_PENCIL,
+   LIBINPUT_TOOL_AIRBRUSH,
+   LIBINPUT_TOOL_FINGER,
+   LIBINPUT_TOOL_MOUSE,
+   LIBINPUT_TOOL_LENS
+};
+
+/**
  * @ingroup base
  *
  * Event type for events returned by libinput_get_event().
@@ -875,6 +901,53 @@ uint32_t
 libinput_event_tablet_get_time(struct libinput_event_tablet *event);
 
 /**
+ * @ingroup event_tablet
+ *
+ * Return the type of tool type for a tool object
+ *
+ * @param tool The libinput tool
+ * @return The tool type for this tool object
+ */
+enum libinput_tool_type
+libinput_tool_get_type(struct libinput_tool *tool);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Increment the ref count of tool by one
+ *
+ * @param tool The tool to increment the ref count of
+ */
+void
+libinput_tool_ref(struct libinput_tool *tool);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Decrement the ref count of tool by one. When the ref count of tool reaches 
0,
+ * the memory allocated for tool will be freed.
+ *
+ * @param tool The tool to decrement the ref count of
+ */
+void
+libinput_tool_unref(struct libinput_tool *tool);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Return the serial number of a tool
+ *
+ * @note Not all tablets report a serial number along with the type of tool
+ * being used. If the hardware does not provide a unique serial number, the
+ * serial number is always 0.
+ *
+ * @param tool The libinput tool
+ * @return The new tool serial triggering this event
+ */
+uint32_t
+libinput_tool_get_serial(struct libinput_tool *tool);
+
+/**
  * @defgroup base Initialization and manipulation of libinput contexts
  */
 
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 14/23] test: Add infrastructure for testing tablet events.

2014-06-12 Thread Stephen Chandler Paul
From: Carlos Garnacho carl...@gnome.org

no vfuncs are used, only input_event arrays.

Signed-off-by: Carlos Garnacho carl...@gnome.org
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com

--- Changes ---
- Removed clear_axes and clear_buttons input_event fields
- Add field for bad distance events
- Add feature to indicate that a tablet is capable of sending distance events
---
 test/litest-int.h |  8 +
 test/litest.c | 89 +++
 test/litest.h | 14 +
 3 files changed, 111 insertions(+)

diff --git a/test/litest-int.h b/test/litest-int.h
index 19e6e68..e64f8b8 100644
--- a/test/litest-int.h
+++ b/test/litest-int.h
@@ -88,6 +88,14 @@ struct litest_device_interface {
struct input_event *touch_move_events;
struct input_event *touch_up_events;
 
+   /**
+* Tablet events, LITEST_AUTO_ASSIGN is allowed on event values for
+* ABS_X, ABS_Y, ABS_DISTANCE and ABS_PRESSURE.
+*/
+   struct input_event *tablet_proximity_in_events;
+   struct input_event *tablet_proximity_out_events;
+   struct input_event *tablet_motion_events;
+
int min[2];
int max[2];
 };
diff --git a/test/litest.c b/test/litest.c
index 0a9cc72..f728707 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -695,6 +695,95 @@ litest_touch_move_to(struct litest_device *d,
litest_touch_move(d, slot, x_to, y_to);
 }
 
+static int32_t
+axis_replacement_value(struct axis_replacement *axes,
+  int32_t evcode)
+{
+   struct axis_replacement *axis = axes;
+
+   while (axis-evcode != -1) {
+   if (axis-evcode == evcode)
+   return axis-value;
+   axis++;
+   }
+
+   return -1;
+}
+
+static int
+auto_assign_tablet_value(struct litest_device *d,
+const struct input_event *ev,
+int x, int y,
+struct axis_replacement *axes)
+{
+   int value = ev-value;
+
+   if (value != LITEST_AUTO_ASSIGN || ev-type != EV_ABS)
+   return value;
+
+   switch (ev-code) {
+   case ABS_X:
+   value = litest_scale(d, ABS_X, x);
+   break;
+   case ABS_Y:
+   value = litest_scale(d, ABS_Y, y);
+   break;
+   default:
+   value = axis_replacement_value(axes, ev-code);
+   break;
+   }
+
+   return value;
+}
+
+static int
+tablet_ignore_event(const struct input_event *ev, int value)
+{
+   return value == -1  (ev-code == ABS_PRESSURE || ev-code == 
ABS_DISTANCE);
+}
+
+void
+litest_tablet_proximity_in(struct litest_device *d, int x, int y, struct 
axis_replacement *axes)
+{
+   struct input_event *ev;
+
+   ev = d-interface-tablet_proximity_in_events;
+   while (ev  (int16_t)ev-type != -1  (int16_t)ev-code != -1) {
+   int value = auto_assign_tablet_value(d, ev, x, y, axes);
+   if (!tablet_ignore_event(ev, value))
+   litest_event(d, ev-type, ev-code, value);
+   ev++;
+   }
+}
+
+void
+litest_tablet_proximity_out(struct litest_device *d)
+{
+   struct input_event *ev;
+
+   ev = d-interface-tablet_proximity_out_events;
+   while (ev  (int16_t)ev-type != -1  (int16_t)ev-code != -1) {
+   int value = auto_assign_tablet_value(d, ev, -1, -1, NULL);
+   if (!tablet_ignore_event(ev, value))
+   litest_event(d, ev-type, ev-code, value);
+   ev++;
+   }
+}
+
+void
+litest_tablet_motion(struct litest_device *d, int x, int y, struct 
axis_replacement *axes)
+{
+   struct input_event *ev;
+
+   ev = d-interface-tablet_motion_events;
+   while (ev  (int16_t)ev-type != -1  (int16_t)ev-code != -1) {
+   int value = auto_assign_tablet_value(d, ev, x, y, axes);
+   if (!tablet_ignore_event(ev, value))
+   litest_event(d, ev-type, ev-code, value);
+   ev++;
+   }
+}
+
 void
 litest_button_click(struct litest_device *d, unsigned int button, bool 
is_press)
 {
diff --git a/test/litest.h b/test/litest.h
index 3e75dd5..ec7026f 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -43,6 +43,7 @@ enum litest_device_type {
LITEST_TRACKPOINT,
LITEST_MOUSE,
LITEST_WACOM_TOUCH,
+   LITEST_WACOM_TABLET,
 };
 
 enum litest_device_feature {
@@ -58,6 +59,8 @@ enum litest_device_feature {
LITEST_SINGLE_TOUCH = 1  7,
LITEST_APPLE_CLICKPAD = 1  8,
LITEST_TOPBUTTONPAD = 1  9,
+   LITEST_TABLET = 1  10,
+   LITEST_DISTANCE = 1  11,
 };
 
 struct litest_device {
@@ -70,6 +73,10 @@ struct litest_device {
 };
 
 struct libinput *litest_create_context(void);
+struct axis_replacement {
+   int32_t evcode;
+   int32_t value;
+};
 
 void litest_add(const char *name, void *func,
enum 

[PATCH libinput 02/23] evdev: Add basic support for tablet devices

2014-06-12 Thread Stephen Chandler Paul
These devices set the LIBINPUT_DEVICE_CAP_STYLUS flag, and emit a lot more axis
information then mice and touchpads. As such, tablet events are in a whole new
group of events that is separate from everything else.

In this commit, only X and Y axes are reported in libinput.

Based off the patch originally written by Carlos Garnacho

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 src/Makefile.am|   2 +
 src/evdev-tablet.c | 170 +
 src/evdev-tablet.h |  64 +++
 src/evdev.c|   8 +++
 src/evdev.h|   3 +
 src/libinput-private.h |   6 ++
 src/libinput-util.h|   2 +
 src/libinput.c | 108 +++
 src/libinput.h | 121 ++-
 9 files changed, 483 insertions(+), 1 deletion(-)
 create mode 100644 src/evdev-tablet.c
 create mode 100644 src/evdev-tablet.h

diff --git a/src/Makefile.am b/src/Makefile.am
index bf56184..b880a69 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,8 @@ libinput_la_SOURCES = \
libinput-util.h \
evdev.c \
evdev.h \
+   evdev-tablet.c  \
+   evdev-tablet.h  \
evdev-mt-touchpad.c \
evdev-mt-touchpad.h \
evdev-mt-touchpad-tap.c \
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
new file mode 100644
index 000..5c73bcb
--- /dev/null
+++ b/src/evdev-tablet.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ * Copyright © 2014 Stephen Chandler Lyude Paul
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include config.h
+#include evdev-tablet.h
+
+#include assert.h
+#include math.h
+#include stdbool.h
+#include string.h
+
+#define tablet_set_status(tablet_,s_) (tablet_-status |= (s_))
+#define tablet_unset_status(tablet_,s_) (tablet_-status = ~(s_))
+#define tablet_has_status(tablet_,s_) (!!(tablet_-status  s_))
+
+static void
+tablet_process_absolute(struct tablet_dispatch *tablet,
+   struct evdev_device *device,
+   struct input_event *e,
+   uint32_t time)
+{
+   enum libinput_tablet_axis axis;
+
+   switch (e-code) {
+   case ABS_X:
+   case ABS_Y:
+   axis = evcode_to_axis(e-code);
+   if (axis == LIBINPUT_TABLET_AXIS_NONE) {
+   log_bug_libinput(Invalid ABS event code %#x\n,
+e-code);
+   break;
+   }
+
+   tablet-absinfo[axis] = libevdev_get_abs_info(device-evdev,
+ e-code);
+
+   set_bit(tablet-changed_axes, axis);
+   tablet_set_status(tablet, TABLET_AXES_UPDATED);
+   break;
+   default:
+   log_info(Unhandled ABS event code %#x\n, e-code);
+   break;
+   }
+}
+
+static void
+tablet_notify_axes(struct tablet_dispatch *tablet,
+  struct evdev_device *device,
+  uint32_t time)
+{
+   struct libinput_device *base = device-base;
+   bool axis_update_needed = false;
+   int a;
+
+   for (a = 0; a  LIBINPUT_TABLET_AXIS_CNT; a++) {
+   if (!bit_is_set(tablet-changed_axes, a))
+   continue;
+
+   switch (a) {
+   case LIBINPUT_TABLET_AXIS_X:
+   case LIBINPUT_TABLET_AXIS_Y:
+   tablet-axes[a] = tablet-absinfo[a]-value;
+   break;
+   default:
+   log_bug_libinput(Invalid axis update: %d\n, a);
+   break;
+   }
+
+   

[PATCH libinput 09/23] tablet: Handle button-events

2014-06-12 Thread Stephen Chandler Paul
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 src/evdev-tablet.c | 113 +
 src/evdev-tablet.h |  12 +-
 src/libinput-private.h |   5 +++
 src/libinput.c |  55 
 src/libinput.h |  51 +-
 5 files changed, 233 insertions(+), 3 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 278890d..5143759 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -32,6 +32,11 @@
 #define tablet_unset_status(tablet_,s_) (tablet_-status = ~(s_))
 #define tablet_has_status(tablet_,s_) (!!(tablet_-status  s_))
 
+#define tablet_get_pressed_buttons(tablet_,field_) \
+   ((tablet_)-button_state.field_  
~((tablet_)-prev_button_state.field_))
+#define tablet_get_released_buttons(tablet_,field_) \
+   ((tablet_)-prev_button_state.field_  
~((tablet_)-button_state.field_))
+
 static struct list tool_list = {
.next = tool_list,
.prev = tool_list
@@ -115,6 +120,37 @@ tablet_notify_axes(struct tablet_dispatch *tablet,
 }
 
 static void
+tablet_update_button(struct tablet_dispatch *tablet,
+uint32_t evcode,
+uint32_t enable)
+{
+   uint32_t button, *flags;
+
+   /* XXX: This really depends on the expected buttons fitting in the mask 
*/
+   if (evcode = BTN_MISC  evcode = BTN_TASK) {
+   flags = tablet-button_state.pad_buttons;
+   button = evcode - BTN_MISC;
+   } else if (evcode = BTN_TOUCH  evcode = BTN_STYLUS2) {
+   flags = tablet-button_state.stylus_buttons;
+   button = evcode - BTN_TOUCH;
+   } else {
+   log_info(Unhandled button %s (%#x)\n,
+libevdev_event_code_get_name(EV_KEY, evcode), evcode);
+   return;
+   }
+
+   if (enable) {
+   (*flags) |= 1  button;
+   tablet_set_status(tablet, TABLET_BUTTONS_PRESSED);
+   } else {
+   (*flags) = ~(1  button);
+   tablet_set_status(tablet, TABLET_BUTTONS_RELEASED);
+   }
+
+   assert(button  32);
+}
+
+static void
 tablet_process_key(struct tablet_dispatch *tablet,
   struct evdev_device *device,
   struct input_event *e,
@@ -132,7 +168,11 @@ tablet_process_key(struct tablet_dispatch *tablet,
/* These codes have an equivalent libinput_tool value */
tablet_update_tool(tablet, e-code, e-value);
break;
+   case BTN_TOUCH:
+   case BTN_STYLUS:
+   case BTN_STYLUS2:
default:
+   tablet_update_button(tablet, e-code, e-value);
break;
}
 }
@@ -187,11 +227,67 @@ tablet_notify_tool(struct tablet_dispatch *tablet,
 }
 
 static void
+tablet_notify_button_mask(struct tablet_dispatch *tablet,
+ struct evdev_device *device,
+ uint32_t time,
+ uint32_t buttons,
+ uint32_t button_base,
+ enum libinput_button_state state)
+{
+   struct libinput_device *base = device-base;
+   int32_t num_button = 0;
+
+   while (buttons) {
+   int enabled;
+
+   num_button++;
+   enabled = (buttons  1);
+   buttons = 1;
+
+   if (!enabled)
+   continue;
+
+   tablet_notify_button(base,
+time,
+num_button + button_base - 1,
+state);
+   }
+}
+
+static void
+tablet_notify_buttons(struct tablet_dispatch *tablet,
+ struct evdev_device *device,
+ uint32_t time,
+ enum libinput_button_state state)
+{
+   uint32_t pad_buttons, stylus_buttons;
+
+   if (state == LIBINPUT_BUTTON_STATE_PRESSED) {
+   pad_buttons = tablet_get_pressed_buttons(tablet, pad_buttons);
+   stylus_buttons =
+   tablet_get_pressed_buttons(tablet, stylus_buttons);
+   } else {
+   pad_buttons = tablet_get_released_buttons(tablet, pad_buttons);
+   stylus_buttons =
+   tablet_get_released_buttons(tablet, stylus_buttons);
+   }
+
+   tablet_notify_button_mask(tablet, device, time,
+ pad_buttons, BTN_MISC, state);
+   tablet_notify_button_mask(tablet, device, time,
+ stylus_buttons, BTN_TOUCH, state);
+}
+
+static void
 tablet_flush(struct tablet_dispatch *tablet,
 struct evdev_device *device,
 uint32_t time)
 {
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
+   /* Release all stylus buttons */
+   tablet-button_state.stylus_buttons = 0;
+   tablet_set_status(tablet, 

[PATCH libinput 20/23] test: Add proximity-in-out and proximity-out-clear-buttons tests

2014-06-12 Thread Stephen Chandler Paul
This tests to make sure proximity events actually work, that they don't output
cooirdinate events after they occur, and that they make sure to release all of
the buttons and clear the values of all the axes

Based off the patch originally written by Carlos Garnacho

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/Makefile.am |   6 ++
 test/tablet.c| 229 +++
 2 files changed, 235 insertions(+)
 create mode 100644 test/tablet.c

diff --git a/test/Makefile.am b/test/Makefile.am
index b6b3a51..0b86d35 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -34,6 +34,7 @@ run_tests = \
test-pointer \
test-touch \
test-log \
+   test-tablet \
test-touchpad \
test-misc \
test-keyboard
@@ -68,6 +69,11 @@ test_log_SOURCES = log.c
 test_log_LDADD = $(TEST_LIBS)
 test_log_LDFLAGS = -static
 
+test_tablet_SOURCES = tablet.c
+test_tablet_CFLAGS = $(AM_CPPFLAGS)
+test_tablet_LDADD = $(TEST_LIBS)
+test_tablet_LDFLAGS = -static
+
 test_touchpad_SOURCES = touchpad.c
 test_touchpad_LDADD = $(TEST_LIBS)
 test_touchpad_LDFLAGS = -static
diff --git a/test/tablet.c b/test/tablet.c
new file mode 100644
index 000..9c5397f
--- /dev/null
+++ b/test/tablet.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ * Copyright © 2014 Stephen Chandler Lyude Paul
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include config.h
+
+#include check.h
+#include errno.h
+#include fcntl.h
+#include libinput.h
+#include unistd.h
+#include stdbool.h
+
+#include libinput-util.h
+#include evdev-tablet.h
+#include litest.h
+
+START_TEST(proximity_in_out)
+{
+   struct litest_device *dev = litest_current_device();
+   struct libinput *li = dev-libinput;
+   struct libinput_event_tablet *tablet_event;
+   struct libinput_event *event;
+   bool have_tool_update = false,
+have_proximity_out = false;
+   uint32_t *axis;
+
+   struct axis_replacement axes[] = {
+   { ABS_DISTANCE, 10 },
+   { -1, -1 }
+   };
+
+   uint32_t test_axes[] = {
+   ABS_X,
+   ABS_Y,
+   ABS_DISTANCE,
+   ABS_PRESSURE,
+   ABS_TILT_X,
+   ABS_TILT_Y
+   };
+
+   litest_drain_events(dev-libinput);
+
+   litest_tablet_proximity_in(dev, 10, 10, axes);
+   libinput_dispatch(li);
+
+   while ((event = libinput_get_event(li))) {
+   if (libinput_event_get_type(event) ==
+   LIBINPUT_EVENT_TABLET_TOOL_UPDATE) {
+   struct libinput_tool * tool;
+
+   have_tool_update++;
+   tablet_event = libinput_event_get_tablet_event(event);
+   tool = libinput_event_tablet_get_tool(tablet_event);
+   ck_assert_int_eq(libinput_tool_get_type(tool),
+LIBINPUT_TOOL_PEN);
+   }
+   libinput_event_destroy(event);
+   }
+   ck_assert(have_tool_update);
+
+   litest_tablet_proximity_out(dev);
+   libinput_dispatch(li);
+
+   while ((event = libinput_get_event(li))) {
+   if (libinput_event_get_type(event) ==
+   LIBINPUT_EVENT_TABLET_PROXIMITY_OUT)
+   have_proximity_out = true;
+
+   libinput_event_destroy(event);
+   }
+   ck_assert(have_proximity_out);
+
+   /* Make sure every axis gets cleared during a proximity out event */
+   ARRAY_FOR_EACH(test_axes, axis) {
+   uint32_t *abs_code;
+   enum libinput_tablet_axis li_axis;
+   int a;
+
+   litest_tablet_proximity_in(dev, 10, 10, axes);
+   ARRAY_FOR_EACH(test_axes, abs_code) {
+   

[PATCH libinput 16/23] test: Add Wacom Bamboo 16FG 4x5 Pen device definition

2014-06-12 Thread Stephen Chandler Paul
From: Carlos Garnacho carl...@gnome.org

Signed-off-by: Carlos Garnacho carl...@gnome.org
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com

--- Changes ---
- Initialized unused fields in absinfo[] for each axis. This fixes complaints
  gcc gives about empty initializers.
  Same goes for the next 3 patches
- Added bad_distance_events struct, contains faulty distance events that can be
  sent by a tablet that we need to test for, same goes for the next 2 patches
- Marked device as capable of sending distance events, same goes for the next 2
  patches
---
 test/Makefile.am  |   1 +
 test/litest-wacom-bamboo-tablet.c | 105 ++
 test/litest.c |   2 +
 3 files changed, 108 insertions(+)
 create mode 100644 test/litest-wacom-bamboo-tablet.c

diff --git a/test/Makefile.am b/test/Makefile.am
index b5dc33c..8ab1f88 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -21,6 +21,7 @@ liblitest_la_SOURCES = \
litest-synaptics-st.c \
litest-synaptics-t440.c \
litest-trackpoint.c \
+   litest-wacom-bamboo-tablet.c \
litest-wacom-touch.c \
litest.c
 
diff --git a/test/litest-wacom-bamboo-tablet.c 
b/test/litest-wacom-bamboo-tablet.c
new file mode 100644
index 000..3a4aa0d
--- /dev/null
+++ b/test/litest-wacom-bamboo-tablet.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided as
+ * is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#if HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include litest.h
+#include litest-int.h
+
+static void litest_wacom_bamboo_tablet_setup(void)
+{
+   struct litest_device *d = litest_create_device(LITEST_WACOM_TABLET);
+   litest_set_current_device(d);
+}
+
+static struct input_event proximity_in[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event proximity_out[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = 0 },
+   { .type = EV_ABS, .code = ABS_Y, .value = 0 },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event motion[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct litest_device_interface interface = {
+   .tablet_proximity_in_events = proximity_in,
+   .tablet_proximity_out_events = proximity_out,
+   .tablet_motion_events = motion,
+};
+
+static struct input_absinfo absinfo[] = {
+   { ABS_X, 0, 14720, 4, 0, 100 },
+   { ABS_Y, 0, 9200, 4, 0, 100 },
+   { ABS_PRESSURE, 0, 1023, 0, 0, 0 },
+   { ABS_DISTANCE, 0, 31, 0, 0, 0 },
+   { .value = -1 },
+};
+
+static struct input_id input_id = {
+   .bustype = 0x3,
+   .vendor = 0x56a,
+   .product = 0xde,
+   .version = 0x100,
+};
+
+static int events[] = {
+   EV_KEY, BTN_TOOL_PEN,
+   EV_KEY, BTN_TOOL_RUBBER,
+   EV_KEY, BTN_TOUCH,
+   EV_KEY, BTN_STYLUS,
+   EV_KEY, BTN_STYLUS2,
+   INPUT_PROP_MAX, INPUT_PROP_POINTER,
+   -1, -1,
+};
+
+struct litest_test_device 

[PATCH libinput 21/23] test: Add motion event test for tablets

2014-06-12 Thread Stephen Chandler Paul
Based off the patch originally written by Carlos Garnacho

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/tablet.c | 65 ++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/test/tablet.c b/test/tablet.c
index 9c5397f..80a70c8 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -130,7 +130,8 @@ START_TEST(proximity_in_out)
int has_changed;
double value;
 
-   has_changed = 
libinput_event_tablet_axis_has_changed(
+   has_changed =
+   libinput_event_tablet_axis_has_changed(
tablet_event, a);
value = libinput_event_tablet_get_axis_value(
tablet_event, a);
@@ -219,11 +220,73 @@ START_TEST(proximity_out_clear_buttons)
 }
 END_TEST
 
+START_TEST(motion)
+{
+   struct litest_device *dev = litest_current_device();
+   struct libinput *li = dev-libinput;
+   struct libinput_event_tablet *tablet_event;
+   struct libinput_event *event;
+   double x1, x2, y1, y2;
+   bool have_motion = false;
+   enum libinput_event_type type;
+   struct axis_replacement axes[] = {
+   { ABS_DISTANCE, 10 },
+   { -1, -1 }
+   };
+
+   litest_drain_events(dev-libinput);
+
+   litest_tablet_proximity_in(dev, 10, 10, axes);
+   libinput_dispatch(li);
+
+   while ((event = libinput_get_event(li))) {
+   tablet_event = libinput_event_get_tablet_event(event);
+   type = libinput_event_get_type(event);
+
+   if (type == LIBINPUT_EVENT_TABLET_AXIS 
+   libinput_event_tablet_axis_has_changed(tablet_event,
+  
LIBINPUT_TABLET_AXIS_X) 
+   libinput_event_tablet_axis_has_changed(tablet_event,
+  
LIBINPUT_TABLET_AXIS_Y)) {
+   x1 = libinput_event_tablet_get_axis_value(
+   tablet_event, LIBINPUT_TABLET_AXIS_X);
+   y1 = libinput_event_tablet_get_axis_value(
+   tablet_event, LIBINPUT_TABLET_AXIS_Y);
+
+   have_motion = true;
+   }
+
+   libinput_event_destroy(event);
+   }
+   ck_assert(have_motion);
+
+   litest_tablet_motion(dev, 20, 20, axes);
+   libinput_dispatch(li);
+
+   while ((event = libinput_get_event(li))) {
+   tablet_event = libinput_event_get_tablet_event(event);
+   type = libinput_event_get_type(event);
+
+   if (type == LIBINPUT_EVENT_TABLET_AXIS) {
+   x2 = libinput_event_tablet_get_axis_value(
+   tablet_event, LIBINPUT_TABLET_AXIS_X);
+   y2 = libinput_event_tablet_get_axis_value(
+   tablet_event, LIBINPUT_TABLET_AXIS_Y);
+   }
+
+   libinput_event_destroy(event);
+   }
+   litest_assert_double_lt(x1, x2);
+   litest_assert_double_lt(y1, y2);
+}
+END_TEST
+
 int
 main(int argc, char **argv)
 {
litest_add(tablet:proximity-out-clear-buttons, 
proximity_out_clear_buttons, LITEST_TABLET, LITEST_ANY);
litest_add(tablet:proximity-in-out, proximity_in_out, LITEST_TABLET, 
LITEST_ANY);
+   litest_add(tablet:motion, motion, LITEST_TABLET, LITEST_ANY);
 
return litest_run(argc, argv);
 }
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 23/23] test: Add tests for normalization

2014-06-12 Thread Stephen Chandler Paul
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/tablet.c | 147 ++
 1 file changed, 147 insertions(+)

diff --git a/test/tablet.c b/test/tablet.c
index e503124..7da84ef 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -322,6 +322,152 @@ START_TEST(bad_distance_events)
 }
 END_TEST
 
+START_TEST(normalization)
+{
+   struct litest_device *dev = litest_current_device();
+   struct libinput *li = dev-libinput;
+   struct libinput_event_tablet *tablet_event;
+   struct libinput_event *event;
+   double pressure,
+  tilt_vertical,
+  tilt_horizontal;
+   const struct input_absinfo *pressure_absinfo,
+   *tilt_vertical_absinfo,
+   *tilt_horizontal_absinfo;
+
+   litest_drain_events(dev-libinput);
+
+   pressure_absinfo = libevdev_get_abs_info(dev-evdev, ABS_PRESSURE);
+   tilt_vertical_absinfo = libevdev_get_abs_info(dev-evdev, ABS_TILT_X);
+   tilt_horizontal_absinfo = libevdev_get_abs_info(dev-evdev, ABS_TILT_Y);
+
+   /* Test minimum */
+   if (pressure_absinfo != NULL)
+   litest_event(dev,
+EV_ABS,
+ABS_PRESSURE,
+pressure_absinfo-minimum);
+
+   if (tilt_vertical_absinfo != NULL)
+   litest_event(dev,
+EV_ABS,
+ABS_TILT_X,
+tilt_vertical_absinfo-minimum);
+
+   if (tilt_horizontal_absinfo != NULL)
+   litest_event(dev,
+EV_ABS,
+ABS_TILT_Y,
+tilt_horizontal_absinfo-minimum);
+
+   litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+   libinput_dispatch(li);
+
+   while ((event = libinput_get_event(li))) {
+   if (libinput_event_get_type(event) == 
LIBINPUT_EVENT_TABLET_AXIS) {
+   tablet_event = libinput_event_get_tablet_event(event);
+
+   if (libinput_event_tablet_axis_has_changed(
+   tablet_event,
+   LIBINPUT_TABLET_AXIS_PRESSURE)) {
+   pressure = libinput_event_tablet_get_axis_value(
+   tablet_event, 
LIBINPUT_TABLET_AXIS_PRESSURE);
+
+   litest_assert_double_eq(pressure, 0);
+   }
+
+   if (libinput_event_tablet_axis_has_changed(
+   tablet_event,
+   LIBINPUT_TABLET_AXIS_TILT_VERTICAL)) {
+   tilt_vertical =
+   libinput_event_tablet_get_axis_value(
+   tablet_event,
+   LIBINPUT_TABLET_AXIS_TILT_VERTICAL);
+
+   litest_assert_double_eq(tilt_vertical, -1);
+   }
+
+   if (libinput_event_tablet_axis_has_changed(
+   tablet_event,
+   LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL)) {
+   tilt_horizontal =
+   libinput_event_tablet_get_axis_value(
+   tablet_event,
+   
LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL);
+
+   litest_assert_double_eq(tilt_horizontal, -1);
+   }
+   }
+
+   libinput_event_destroy(event);
+   }
+
+   /* Test maximum */
+   if (pressure_absinfo != NULL)
+   litest_event(dev,
+EV_ABS,
+ABS_PRESSURE,
+pressure_absinfo-maximum);
+
+   if (tilt_vertical_absinfo != NULL)
+   litest_event(dev,
+EV_ABS,
+ABS_TILT_X,
+tilt_vertical_absinfo-maximum);
+
+   if (tilt_horizontal_absinfo != NULL)
+   litest_event(dev,
+EV_ABS,
+ABS_TILT_Y,
+tilt_horizontal_absinfo-maximum);
+
+   litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+   libinput_dispatch(li);
+
+   while ((event = libinput_get_event(li))) {
+   if (libinput_event_get_type(event) == 
LIBINPUT_EVENT_TABLET_AXIS) {
+   tablet_event = libinput_event_get_tablet_event(event);
+
+   if (libinput_event_tablet_axis_has_changed(
+   tablet_event,
+   LIBINPUT_TABLET_AXIS_PRESSURE)) {
+   pressure = libinput_event_tablet_get_axis_value(
+   

[PATCH libinput 17/23] test: Add Wacom Cintiq 12WX device definition

2014-06-12 Thread Stephen Chandler Paul
From: Carlos Garnacho carl...@gnome.org

Signed-off-by: Carlos Garnacho carl...@gnome.org
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/Makefile.am  |   1 +
 test/litest-wacom-cintiq-tablet.c | 136 ++
 test/litest.c |   2 +
 3 files changed, 139 insertions(+)
 create mode 100644 test/litest-wacom-cintiq-tablet.c

diff --git a/test/Makefile.am b/test/Makefile.am
index 8ab1f88..7f3099e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -22,6 +22,7 @@ liblitest_la_SOURCES = \
litest-synaptics-t440.c \
litest-trackpoint.c \
litest-wacom-bamboo-tablet.c \
+   litest-wacom-cintiq-tablet.c \
litest-wacom-touch.c \
litest.c
 
diff --git a/test/litest-wacom-cintiq-tablet.c 
b/test/litest-wacom-cintiq-tablet.c
new file mode 100644
index 000..416955b
--- /dev/null
+++ b/test/litest-wacom-cintiq-tablet.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided as
+ * is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#if HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include litest.h
+#include litest-int.h
+
+static void litest_wacom_cintiq_tablet_setup(void)
+{
+   struct litest_device *d = litest_create_device(LITEST_WACOM_TABLET);
+   litest_set_current_device(d);
+}
+
+static struct input_event proximity_in[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
+   { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event proximity_out[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = 0 },
+   { .type = EV_ABS, .code = ABS_Y, .value = 0 },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
+   { .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
+   { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
+   { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
+   { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event motion[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct litest_device_interface interface = {
+   .tablet_proximity_in_events = proximity_in,
+   .tablet_proximity_out_events = proximity_out,
+   .tablet_motion_events = motion,
+};
+
+static struct input_absinfo absinfo[] = {
+   { ABS_X, 0, 53020, 4, 0, 200 },
+   { ABS_Y, 0, 33440, 4, 0, 200 },
+   { ABS_Z, -900, 899, 0, 0, 0 },
+   { ABS_RX, 0, 4096, 0, 0, 0 },
+   { ABS_RY, 0, 4096, 0, 0, 0 },
+   { ABS_WHEEL, 0, 1023, 0, 0, 0 },
+   { ABS_PRESSURE, 0, 1023, 0, 0, 0 },
+   { 

[PATCH libinput 18/23] test: Add Wacom Intuos5 touch M Pen device definition

2014-06-12 Thread Stephen Chandler Paul
From: Carlos Garnacho carl...@gnome.org

Signed-off-by: Carlos Garnacho carl...@gnome.org
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/Makefile.am  |   1 +
 test/litest-wacom-intuos-tablet.c | 134 ++
 test/litest.c |   2 +
 3 files changed, 137 insertions(+)
 create mode 100644 test/litest-wacom-intuos-tablet.c

diff --git a/test/Makefile.am b/test/Makefile.am
index 7f3099e..1d11cf6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,6 +23,7 @@ liblitest_la_SOURCES = \
litest-trackpoint.c \
litest-wacom-bamboo-tablet.c \
litest-wacom-cintiq-tablet.c \
+   litest-wacom-intuos-tablet.c \
litest-wacom-touch.c \
litest.c
 
diff --git a/test/litest-wacom-intuos-tablet.c 
b/test/litest-wacom-intuos-tablet.c
new file mode 100644
index 000..4ce9641
--- /dev/null
+++ b/test/litest-wacom-intuos-tablet.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided as
+ * is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#if HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include litest.h
+#include litest-int.h
+
+static void litest_wacom_intuos_tablet_setup(void)
+{
+   struct litest_device *d = litest_create_device(LITEST_WACOM_TABLET);
+   litest_set_current_device(d);
+}
+
+static struct input_event proximity_in[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_MISC, .value = 1050626 },
+   { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event proximity_out[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = 0 },
+   { .type = EV_ABS, .code = ABS_Y, .value = 0 },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
+   { .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
+   { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
+   { .type = EV_ABS, .code = ABS_MISC, .value = 0 },
+   { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event motion[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_MSC, .code = MSC_SERIAL, .value = 578837976 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+static struct litest_device_interface interface = {
+   .tablet_proximity_in_events = proximity_in,
+   .tablet_proximity_out_events = proximity_out,
+   .tablet_motion_events = motion,
+};
+
+static struct input_absinfo absinfo[] = {
+   { ABS_X, 0, 44704, 4, 0, 200 },
+   { ABS_Y, 0, 27940, 4, 0, 200 },
+   { ABS_Z, -900, 899, 0, 0, 0 },
+   { ABS_THROTTLE, -1023, 1023, 0, 0, 0 },
+   { ABS_WHEEL, 0, 1023, 0, 0, 0 },
+   { ABS_PRESSURE, 0, 2047, 0, 0, 0 },
+   { ABS_DISTANCE, 0, 63, 0, 

[PATCH libinput 19/23] test: Add Wacom ISDv4 E6 Pen device definition

2014-06-12 Thread Stephen Chandler Paul
From: Carlos Garnacho carl...@gnome.org

Signed-off-by: Carlos Garnacho carl...@gnome.org
Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/Makefile.am |  1 +
 test/litest-wacom-isdv4-tablet.c | 98 
 test/litest.c|  2 +
 3 files changed, 101 insertions(+)
 create mode 100644 test/litest-wacom-isdv4-tablet.c

diff --git a/test/Makefile.am b/test/Makefile.am
index 1d11cf6..b6b3a51 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -24,6 +24,7 @@ liblitest_la_SOURCES = \
litest-wacom-bamboo-tablet.c \
litest-wacom-cintiq-tablet.c \
litest-wacom-intuos-tablet.c \
+   litest-wacom-isdv4-tablet.c \
litest-wacom-touch.c \
litest.c
 
diff --git a/test/litest-wacom-isdv4-tablet.c b/test/litest-wacom-isdv4-tablet.c
new file mode 100644
index 000..557807e
--- /dev/null
+++ b/test/litest-wacom-isdv4-tablet.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided as
+ * is without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#if HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include litest.h
+#include litest-int.h
+
+static void litest_wacom_isdv4_tablet_setup(void)
+{
+   struct litest_device *d = litest_create_device(LITEST_WACOM_TABLET);
+   litest_set_current_device(d);
+}
+
+static struct input_event proximity_in[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 1 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event proximity_out[] = {
+   { .type = EV_KEY, .code = BTN_TOOL_PEN, .value = 0 },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct input_event motion[] = {
+   { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
+   { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
+   { .type = -1, .code = -1 },
+};
+
+static struct litest_device_interface interface = {
+   .tablet_proximity_in_events = proximity_in,
+   .tablet_proximity_out_events = proximity_out,
+   .tablet_motion_events = motion,
+};
+
+static struct input_absinfo absinfo[] = {
+   { ABS_X, 0, 27760, 4, 0, 100 },
+   { ABS_Y, 0, 15694, 4, 0, 100 },
+   { ABS_PRESSURE, 0, 255, 0, 0, 0 },
+   { .value = -1 },
+};
+
+static struct input_id input_id = {
+   .bustype = 0x3,
+   .vendor = 0x56a,
+   .product = 0xe6,
+};
+
+static int events[] = {
+   EV_KEY, BTN_TOOL_PEN,
+   EV_KEY, BTN_TOOL_RUBBER,
+   EV_KEY, BTN_TOUCH,
+   EV_KEY, BTN_STYLUS,
+   EV_KEY, BTN_STYLUS2,
+   INPUT_PROP_MAX, INPUT_PROP_DIRECT,
+   -1, -1,
+};
+
+struct litest_test_device litest_wacom_isdv4_tablet_device = {
+   .type = LITEST_WACOM_TABLET,
+   .features = LITEST_TABLET,
+   .shortname = wacom-isdv4-tablet,
+   .setup = litest_wacom_isdv4_tablet_setup,
+   .interface = interface,
+
+   .name = Wacom ISDv4 E6 Pen,
+   .id = input_id,
+   .events = events,
+   .absinfo = absinfo,
+};
diff --git a/test/litest.c b/test/litest.c
index bdeaf93..fae8b16 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -86,6 +86,7 @@ extern struct litest_test_device litest_wacom_touch_device;
 extern struct litest_test_device litest_wacom_bamboo_tablet_device;
 extern struct litest_test_device litest_wacom_cintiq_tablet_device;
 extern struct litest_test_device litest_wacom_intuos_tablet_device;
+extern struct litest_test_device litest_wacom_isdv4_tablet_device;
 
 struct 

[PATCH libinput 15/23] test: Add litest_assert_double_*() macros

2014-06-12 Thread Stephen Chandler Paul
Converts two doubles to 24.8 fixed-width integers so assertions can be made with
doubles in tests

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/litest.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/test/litest.h b/test/litest.h
index ec7026f..90cd68d 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -149,6 +149,23 @@ struct libevdev_uinput * 
litest_create_uinput_abs_device(const char *name,
 struct input_id *id,
 const struct 
input_absinfo *abs,
 ...);
+#define litest_assert_double_eq(a_, b_)\
+   ck_assert_int_eq((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_ne(a_, b_)\
+   ck_assert_int_ne((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_lt(a_, b_)\
+   ck_assert_int_lt((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_le(a_, b_)\
+   ck_assert_int_le((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_gt(a_, b_)\
+   ck_assert_int_gt((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_ge(a_, b_)\
+   ck_assert_int_ge((int)(a_ * 256), (int)(b_ * 256))
 
 #ifndef ck_assert_notnull
 #define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL)
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 22/23] test: Add bad-distance-events test

2014-06-12 Thread Stephen Chandler Paul
There's a special distance on wacom tablets where the stylus is close enough to
be (sort of) recongnized by the tablet, but not close enough to send any useful
data. When the pen's in this distance, it will send a distance event with the
value absinfo-maximum or absinfo-minimum, but no other events. Since that
gives the caller the false impression that the tablet is actually in useful
proximity of the tablet, we want to make sure we filter out any events like
this.

Signed-off-by: Stephen Chandler Paul thatsly...@gmail.com
---
 test/tablet.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/test/tablet.c b/test/tablet.c
index 80a70c8..e503124 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -281,12 +281,54 @@ START_TEST(motion)
 }
 END_TEST
 
+START_TEST(bad_distance_events)
+{
+   struct litest_device *dev = litest_current_device();
+   struct libinput *li = dev-libinput;
+   struct libinput_event_tablet *tablet_event;
+   struct libinput_event *event;
+   bool bad_distance_event_received = false,
+axis_has_changed;
+   enum libinput_event_type type;
+   const struct input_absinfo *absinfo;
+
+   litest_drain_events(dev-libinput);
+
+   litest_tablet_proximity_out(dev);
+
+   absinfo = libevdev_get_abs_info(dev-evdev, ABS_DISTANCE);
+   ck_assert(absinfo != NULL);
+
+   litest_event(dev, EV_ABS, ABS_DISTANCE, absinfo-maximum);
+   litest_event(dev, EV_SYN, SYN_REPORT, 0);
+   litest_event(dev, EV_ABS, ABS_DISTANCE, absinfo-minimum);
+   litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+   /* We shouldn't be able to see any of the bad distance events that got
+* sent
+*/
+   while ((event = libinput_get_event(li))) {
+   tablet_event = libinput_event_get_tablet_event(event);
+   type = libinput_event_get_type(event);
+   axis_has_changed = libinput_event_tablet_axis_has_changed(
+   tablet_event, LIBINPUT_TABLET_AXIS_DISTANCE);
+
+   if (type == LIBINPUT_EVENT_TABLET_AXIS  axis_has_changed)
+   bad_distance_event_received = true;
+
+   libinput_event_destroy(event);
+   }
+   ck_assert(!bad_distance_event_received);
+}
+END_TEST
+
 int
 main(int argc, char **argv)
 {
litest_add(tablet:proximity-out-clear-buttons, 
proximity_out_clear_buttons, LITEST_TABLET, LITEST_ANY);
litest_add(tablet:proximity-in-out, proximity_in_out, LITEST_TABLET, 
LITEST_ANY);
litest_add(tablet:motion, motion, LITEST_TABLET, LITEST_ANY);
+   litest_add(tablet:bad-distance-events, bad_distance_events, 
LITEST_TABLET | LITEST_DISTANCE, LITEST_ANY);
 
return litest_run(argc, argv);
 }
-- 
1.8.5.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel