summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-01-06 14:47:18 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-01-22 16:16:55 +1000
commit108a191a3ec868c00e5ee72be383b437894b2fc5 (patch)
tree561e4575c75b0dc3619cad36199d448ff88bd392 /src
parent91a568d1a1339829f4e3969bde3a4935fef9542b (diff)
tablet: add support for relative x/y motion deltas
Instead of an explicit tablet mode that device must be changed into, let the caller decide which coordinates are preferred. The tablet mode may be application-specific and usually depends on the tool as well. This patch adds an interface to get a motion delta for the x/y axes in pixel-like coordinates. libinput provides some magic to convert the tablet data into something that resembles pixels from a mouse motion. For unaccelerated relative motion, the caller should use the mm values from the tablet and calculate deltas manually. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'src')
-rw-r--r--src/libinput-private.h1
-rw-r--r--src/libinput.c26
-rw-r--r--src/libinput.h34
-rw-r--r--src/libinput.sym2
4 files changed, 63 insertions, 0 deletions
diff --git a/src/libinput-private.h b/src/libinput-private.h
index ff43d007..d78be646 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -71,6 +71,7 @@ struct threshold {
struct tablet_axes {
struct device_coords point;
+ struct normalized_coords delta;
double distance;
double pressure;
struct normalized_range_coords tilt;
diff --git a/src/libinput.c b/src/libinput.c
index 2f80f039..a0dc6d68 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1090,6 +1090,32 @@ libinput_event_tablet_tool_get_y(struct libinput_event_tablet_tool *event)
}
LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_dx(struct libinput_event_tablet_tool *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+ LIBINPUT_EVENT_TABLET_TOOL_TIP,
+ LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+ return event->axes.delta.x;
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_dy(struct libinput_event_tablet_tool *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_TABLET_TOOL_AXIS,
+ LIBINPUT_EVENT_TABLET_TOOL_TIP,
+ LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+
+ return event->axes.delta.y;
+}
+
+LIBINPUT_EXPORT double
libinput_event_tablet_tool_get_pressure(struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
diff --git a/src/libinput.h b/src/libinput.h
index 1cf690b9..500224df 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1583,6 +1583,40 @@ libinput_event_tablet_tool_get_y(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
+ * Return the delta between the last event and the current event.
+ * If the tool employs pointer acceleration, the delta returned by this
+ * function is the accelerated delta.
+ *
+ * This value is in screen coordinate space, the delta is to be interpreted
+ * like the return value of libinput_event_pointer_get_dx().
+ * See @ref tablet-relative-motion for more details.
+ *
+ * @param event The libinput tablet event
+ * @return The relative x movement since the last event
+ */
+double
+libinput_event_tablet_tool_get_dx(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Return the delta between the last event and the current event.
+ * If the tool employs pointer acceleration, the delta returned by this
+ * function is the accelerated delta.
+ *
+ * This value is in screen coordinate space, the delta is to be interpreted
+ * like the return value of libinput_event_pointer_get_dx().
+ * See @ref tablet-relative-motion for more details.
+ *
+ * @param event The libinput tablet event
+ * @return The relative y movement since the last event
+ */
+double
+libinput_event_tablet_tool_get_dy(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
* Returns the current pressure being applied on the tool in use, normalized
* to the range [0, 1].
*
diff --git a/src/libinput.sym b/src/libinput.sym
index 22a8dd82..666f3668 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -194,6 +194,8 @@ LIBINPUT_TABLET_SUPPORT {
libinput_event_tablet_tool_tilt_y_has_changed;
libinput_event_tablet_tool_wheel_has_changed;
libinput_event_tablet_tool_slider_has_changed;
+ libinput_event_tablet_tool_get_dx;
+ libinput_event_tablet_tool_get_dy;
libinput_event_tablet_tool_get_x;
libinput_event_tablet_tool_get_y;
libinput_event_tablet_tool_get_pressure;