[PATCH libinput 2/5] tablet: rename axis_get_value into an axis-specific API set
Peter Hutterer
peter.hutterer at who-t.net
Sun Dec 13 18:00:11 PST 2015
Second part of the big revamp to get rid of libinput_tablet_tool_axis and
replace it with a set of axis-specific APIs.
Note that this commit drops the ability to get the absolute value from a
relative wheel. The previous API always returned 0 for this case, it is not
needed anymore.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/libinput.c | 58 +++++++++++++-
src/libinput.h | 153 +++++++++++++++++++++++++----------
src/libinput.sym | 9 ++-
test/tablet.c | 227 ++++++++++++++++++----------------------------------
tools/event-debug.c | 22 ++---
tools/event-gui.c | 12 +--
6 files changed, 265 insertions(+), 216 deletions(-)
diff --git a/src/libinput.c b/src/libinput.c
index f37d174..27fe297 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1047,7 +1047,7 @@ libinput_event_tablet_tool_wheel_has_changed(
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
}
-LIBINPUT_EXPORT double
+static double
libinput_event_tablet_tool_get_axis_value(struct libinput_event_tablet_tool *event,
enum libinput_tablet_tool_axis axis)
{
@@ -1082,6 +1082,62 @@ libinput_event_tablet_tool_get_axis_value(struct libinput_event_tablet_tool *eve
}
LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_x(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_X);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_y(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_Y);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_pressure(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_distance(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_tilt_x(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_tilt_y(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_rotation(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_tablet_tool_get_slider_position(struct libinput_event_tablet_tool *event)
+{
+ return libinput_event_tablet_tool_get_axis_value(event,
+ LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
+}
+
+LIBINPUT_EXPORT double
libinput_event_tablet_tool_get_axis_delta(struct libinput_event_tablet_tool *event,
enum libinput_tablet_tool_axis axis)
{
diff --git a/src/libinput.h b/src/libinput.h
index 8bd1480..1503152 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1510,47 +1510,118 @@ libinput_event_tablet_tool_wheel_has_changed(
/**
* @ingroup event_tablet
*
- * Return the axis value of a given axis for a tablet. The interpretation of the
- * value is dependent on the axis:
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_X and @ref LIBINPUT_TABLET_TOOL_AXIS_Y - the X and
- * Y coordinates of the tablet tool, in mm from the top left corner of the
- * tablet. Use libinput_event_tablet_tool_get_x_transformed() and
- * libinput_event_tablet_tool_get_y_transformed() for transforming each
- * respective axis value into a different coordinate space.
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_DISTANCE - The distance from the tablet's
- * sensor, normalized from 0 to 1
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_PRESSURE - The current pressure being applied on
- * the tool in use, normalized from 0 to 1
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_TILT_X and @ref LIBINPUT_TABLET_TOOL_AXIS_TILT_Y -
- * normalized value between -1 and 1 that indicates the X or Y tilt of the
- * tool
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z - The z rotation of the tool in
- * degrees, clockwise from the tool's logical neutral position. For the
- * @ref LIBINPUT_TABLET_TOOL_TYPE_MOUSE and @ref LIBINPUT_TABLET_TOOL_TYPE_LENS tools
- * the logical neutral position is pointing to the current logical north
- * of the tablet. For the @ref LIBINPUT_TABLET_TOOL_TYPE_BRUSH tool, the logical
- * neutral position is with the buttons pointing up.
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_SLIDER - A slider on the tool, normalized
- * from 0 to 1. e.g. the wheel-like tool on the Wacom Airbrush.
- * - @ref LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL - A relative wheel on the tool,
- * similar or equivalent to a mouse wheel. The value is always 0, use
- * libinput_event_tablet_tool_get_axis_delta() instead.
- *
- * @note This function may be called for a specific axis even if
- * libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
- * libinput always includes all device axes in the event.
- *
- * If the event is of type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY and the
- * event is a proximity out event, the value returned is the last known
- * value of the tool before it left proximity.
- *
- * @param event The libinput tablet event
- * @param axis The axis to retrieve the value of
- * @return The current value of the the axis
- */
-double
-libinput_event_tablet_tool_get_axis_value(struct libinput_event_tablet_tool *event,
- enum libinput_tablet_tool_axis axis);
+ * Returns the X coordinate of tablet tool, in mm from the top left corner
+ * of the tablet. Use libinput_event_tablet_tool_get_x_transformed() for
+ * transforming the axis value into a different coordinate space.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_x(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Returns the Y coordinate of tablet tool, in mm from the top left corner
+ * of the tablet. Use libinput_event_tablet_tool_get_y_transformed() for
+ * transforming the axis value into a different coordinate space.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_y(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].
+ *
+ * If this axis does not exist on the device, this function returns 0.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_pressure(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Returns the current distance from the tablet's sensor, normalized to the
+ * range [0, 1].
+ *
+ * If this axis does not exist on the device, this function returns 0.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_distance(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Returns the current tilt along the X axis of the tablet's logical
+ * orientation, normalized to the range [-1, 1].
+ *
+ * If this axis does not exist on the device, this function returns 0.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_tilt_x(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Returns the current tilt along the Y axis of the tablet's logical
+ * orientation, normalized to the range [-1, 1].
+ *
+ * If this axis does not exist on the device, this function returns 0.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_tilt_y(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Returns the current z rotation of the tool in degrees, clockwise from the
+ * tool's logical neutral position.
+ *
+ * For tools of type @ref LIBINPUT_TABLET_TOOL_TYPE_MOUSE and @ref
+ * LIBINPUT_TABLET_TOOL_TYPE_LENS the logical neutral position is
+ * pointing to the current logical north of the tablet. For tools of type @ref
+ * LIBINPUT_TABLET_TOOL_TYPE_BRUSH, the logical neutral position is with the
+ * buttons pointing up.
+ *
+ * If this axis does not exist on the device, this function returns 0.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_rotation(struct libinput_event_tablet_tool *event);
+
+/**
+ * @ingroup event_tablet
+ *
+ * Returns the current position of the slider on the tool, normalized to the
+ * range [-1, 1]. This axis is available on e.g. the Wacom Airbrush.
+ *
+ * If this axis does not exist on the device, this function returns 0.
+ *
+ * @param event The libinput tablet event
+ * @return The current value of the the axis
+ */
+double
+libinput_event_tablet_tool_get_slider_position(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
diff --git a/src/libinput.sym b/src/libinput.sym
index bee03b9..ba4c537 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -194,9 +194,16 @@ 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_x;
+ libinput_event_tablet_tool_get_y;
+ libinput_event_tablet_tool_get_pressure;
+ libinput_event_tablet_tool_get_distance;
+ libinput_event_tablet_tool_get_tilt_x;
+ libinput_event_tablet_tool_get_tilt_y;
+ libinput_event_tablet_tool_get_rotation;
+ libinput_event_tablet_tool_get_slider_position;
libinput_event_tablet_tool_get_axis_delta;
libinput_event_tablet_tool_get_axis_delta_discrete;
- libinput_event_tablet_tool_get_axis_value;
libinput_event_tablet_tool_get_base_event;
libinput_event_tablet_tool_get_button;
libinput_event_tablet_tool_get_button_state;
diff --git a/test/tablet.c b/test/tablet.c
index 724feb3..7e674ed 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -323,10 +323,8 @@ START_TEST(tip_down_motion)
event = libinput_get_event(li);
tablet_event = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_AXIS);
- last_x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- last_y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ last_x = libinput_event_tablet_tool_get_x(tablet_event);
+ last_y = libinput_event_tablet_tool_get_y(tablet_event);
libinput_event_destroy(event);
libinput_dispatch(li);
@@ -335,10 +333,8 @@ START_TEST(tip_down_motion)
LIBINPUT_EVENT_TABLET_TOOL_TIP);
ck_assert_int_eq(libinput_event_tablet_tool_get_tip_state(tablet_event),
LIBINPUT_TABLET_TOOL_TIP_DOWN);
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
ck_assert_double_eq(last_x, x);
ck_assert_double_eq(last_y, y);
libinput_event_destroy(event);
@@ -374,10 +370,8 @@ START_TEST(tip_up_motion)
event = libinput_get_event(li);
tablet_event = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_AXIS);
- last_x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- last_y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ last_x = libinput_event_tablet_tool_get_x(tablet_event);
+ last_y = libinput_event_tablet_tool_get_y(tablet_event);
libinput_event_destroy(event);
libinput_dispatch(li);
@@ -386,10 +380,8 @@ START_TEST(tip_up_motion)
LIBINPUT_EVENT_TABLET_TOOL_TIP);
ck_assert_int_eq(libinput_event_tablet_tool_get_tip_state(tablet_event),
LIBINPUT_TABLET_TOOL_TIP_UP);
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
ck_assert_double_eq(last_x, x);
ck_assert_double_eq(last_y, y);
libinput_event_destroy(event);
@@ -724,10 +716,8 @@ START_TEST(proximity_has_axes)
ck_assert(libinput_event_tablet_tool_x_has_changed(tablet_event));
ck_assert(libinput_event_tablet_tool_y_has_changed(tablet_event));
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_ne(x, 0);
litest_assert_double_ne(y, 0);
@@ -736,9 +726,7 @@ START_TEST(proximity_has_axes)
ck_assert(libinput_event_tablet_tool_distance_has_changed(
tablet_event));
- distance = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ distance = libinput_event_tablet_tool_get_distance(tablet_event);
litest_assert_double_ne(distance, 0);
}
@@ -749,12 +737,8 @@ START_TEST(proximity_has_axes)
ck_assert(libinput_event_tablet_tool_tilt_y_has_changed(
tablet_event));
- x = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
- y = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ x = libinput_event_tablet_tool_get_tilt_x(tablet_event);
+ y = libinput_event_tablet_tool_get_tilt_y(tablet_event);
litest_assert_double_ne(x, 0);
litest_assert_double_ne(y, 0);
@@ -772,22 +756,15 @@ START_TEST(proximity_has_axes)
event = libinput_get_event(li);
tablet_event = libinput_event_get_tablet_tool_event(event);
- last_x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- last_y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ last_x = libinput_event_tablet_tool_get_x(tablet_event);
+ last_y = libinput_event_tablet_tool_get_y(tablet_event);
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE))
- last_distance = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ last_distance = libinput_event_tablet_tool_get_distance(
+ tablet_event);
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) &&
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
- last_tx = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
- last_ty = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ last_tx = libinput_event_tablet_tool_get_tilt_x(tablet_event);
+ last_ty = libinput_event_tablet_tool_get_tilt_y(tablet_event);
}
libinput_event_destroy(event);
@@ -804,10 +781,8 @@ START_TEST(proximity_has_axes)
ck_assert(!libinput_event_tablet_tool_x_has_changed(tablet_event));
ck_assert(!libinput_event_tablet_tool_y_has_changed(tablet_event));
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_eq(x, last_x);
litest_assert_double_eq(y, last_y);
@@ -815,9 +790,8 @@ START_TEST(proximity_has_axes)
ck_assert(!libinput_event_tablet_tool_distance_has_changed(
tablet_event));
- distance = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ distance = libinput_event_tablet_tool_get_distance(
+ tablet_event);
litest_assert_double_eq(distance, last_distance);
}
@@ -828,12 +802,8 @@ START_TEST(proximity_has_axes)
ck_assert(!libinput_event_tablet_tool_tilt_y_has_changed(
tablet_event));
- x = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
- y = libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ x = libinput_event_tablet_tool_get_tilt_x(tablet_event);
+ y = libinput_event_tablet_tool_get_tilt_y(tablet_event);
litest_assert_double_eq(x, last_tx);
litest_assert_double_eq(y, last_ty);
@@ -883,10 +853,8 @@ START_TEST(motion)
ck_assert(x_changed);
ck_assert(y_changed);
- reported_x = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
- reported_y = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ reported_x = libinput_event_tablet_tool_get_x(tablet_event);
+ reported_y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_lt(reported_x, reported_y);
@@ -918,10 +886,10 @@ START_TEST(motion)
ck_assert(x_changed);
ck_assert(y_changed);
- reported_x = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
- reported_y = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ reported_x = libinput_event_tablet_tool_get_x(
+ tablet_event);
+ reported_y = libinput_event_tablet_tool_get_y(
+ tablet_event);
litest_assert_double_gt(reported_x,
last_reported_x);
@@ -962,12 +930,9 @@ START_TEST(motion_delta)
event = libinput_get_event(li);
tablet_event = libinput_event_get_tablet_tool_event(event);
- x1 = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y1 = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
- dist1 = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ x1 = libinput_event_tablet_tool_get_x(tablet_event);
+ y1 = libinput_event_tablet_tool_get_y(tablet_event);
+ dist1 = libinput_event_tablet_tool_get_distance(tablet_event);
libinput_event_destroy(event);
axes[0].value = 40;
@@ -978,12 +943,9 @@ START_TEST(motion_delta)
-1);
event = libinput_get_event(li);
tablet_event = libinput_event_get_tablet_tool_event(event);
- x2 = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y2 = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
- dist2 = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ x2 = libinput_event_tablet_tool_get_x(tablet_event);
+ y2 = libinput_event_tablet_tool_get_y(tablet_event);
+ dist2 = libinput_event_tablet_tool_get_distance(tablet_event);
delta = libinput_event_tablet_tool_get_axis_delta(tablet_event,
LIBINPUT_TABLET_TOOL_AXIS_X);
@@ -1079,10 +1041,8 @@ START_TEST(left_handed)
while ((event = libinput_get_event(li))) {
tablet_event = libinput_event_get_tablet_tool_event(event);
- last_x = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
- last_y = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ last_x = libinput_event_tablet_tool_get_x(tablet_event);
+ last_y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_eq(last_x, 0);
litest_assert_double_eq(last_y, libinput_max_y);
@@ -1097,10 +1057,8 @@ START_TEST(left_handed)
double x, y;
tablet_event = libinput_event_get_tablet_tool_event(event);
- x = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_eq(x, libinput_max_x);
litest_assert_double_eq(y, 0);
@@ -1125,10 +1083,8 @@ START_TEST(left_handed)
while ((event = libinput_get_event(li))) {
tablet_event = libinput_event_get_tablet_tool_event(event);
- last_x = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
- last_y = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ last_x = libinput_event_tablet_tool_get_x(tablet_event);
+ last_y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_eq(last_x, libinput_max_x);
litest_assert_double_eq(last_y, 0);
@@ -1143,10 +1099,8 @@ START_TEST(left_handed)
double x, y;
tablet_event = libinput_event_get_tablet_tool_event(event);
- x = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
litest_assert_double_eq(x, 0);
litest_assert_double_eq(y, libinput_max_y);
@@ -1203,10 +1157,8 @@ START_TEST(motion_event_state)
tablet_event = libinput_event_get_tablet_tool_event(event);
ck_assert_notnull(tablet_event);
- last_x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- last_y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ last_x = libinput_event_tablet_tool_get_x(tablet_event);
+ last_y = libinput_event_tablet_tool_get_y(tablet_event);
/* mark with a button event, then go back to bottom/left */
litest_event(dev, EV_KEY, BTN_STYLUS, 1);
@@ -1231,10 +1183,8 @@ START_TEST(motion_event_state)
tablet_event = libinput_event_get_tablet_tool_event(event);
ck_assert_notnull(tablet_event);
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
ck_assert(x > last_x);
ck_assert(y < last_y);
@@ -1323,8 +1273,8 @@ START_TEST(normalization)
if (libinput_event_tablet_tool_pressure_has_changed(
tablet_event)) {
- pressure = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
+ pressure = libinput_event_tablet_tool_get_pressure(
+ tablet_event);
litest_assert_double_eq(pressure, 0);
}
@@ -1332,9 +1282,8 @@ START_TEST(normalization)
if (libinput_event_tablet_tool_tilt_x_has_changed(
tablet_event)) {
tilt_vertical =
- libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
+ libinput_event_tablet_tool_get_tilt_x(
+ tablet_event);
litest_assert_double_eq(tilt_vertical, -1);
}
@@ -1342,9 +1291,8 @@ START_TEST(normalization)
if (libinput_event_tablet_tool_tilt_y_has_changed(
tablet_event)) {
tilt_horizontal =
- libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ libinput_event_tablet_tool_get_tilt_y(
+ tablet_event);
litest_assert_double_eq(tilt_horizontal, -1);
}
@@ -1382,8 +1330,8 @@ START_TEST(normalization)
if (libinput_event_tablet_tool_pressure_has_changed(
tablet_event)) {
- pressure = libinput_event_tablet_tool_get_axis_value(
- tablet_event, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
+ pressure = libinput_event_tablet_tool_get_pressure(
+ tablet_event);
litest_assert_double_eq(pressure, 1);
}
@@ -1391,9 +1339,8 @@ START_TEST(normalization)
if (libinput_event_tablet_tool_tilt_x_has_changed(
tablet_event)) {
tilt_vertical =
- libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
+ libinput_event_tablet_tool_get_tilt_x(
+ tablet_event);
litest_assert_double_eq(tilt_vertical, 1);
}
@@ -1401,9 +1348,8 @@ START_TEST(normalization)
if (libinput_event_tablet_tool_tilt_y_has_changed(
tablet_event)) {
tilt_horizontal =
- libinput_event_tablet_tool_get_axis_value(
- tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ libinput_event_tablet_tool_get_tilt_y(
+ tablet_event);
litest_assert_double_eq(tilt_horizontal, 1);
}
@@ -1959,8 +1905,7 @@ START_TEST(mouse_rotation)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
ck_assert(libinput_event_tablet_tool_rotation_has_changed(tev));
- val = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
+ val = libinput_event_tablet_tool_get_rotation(tev);
/* rounding error galore, we can't test for anything more
precise than these */
@@ -2021,9 +1966,6 @@ START_TEST(mouse_wheel)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
ck_assert(libinput_event_tablet_tool_wheel_has_changed(tev));
- val = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
- ck_assert_int_eq(val, 0);
val = libinput_event_tablet_tool_get_axis_delta(tev,
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
@@ -2051,9 +1993,6 @@ START_TEST(mouse_wheel)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
ck_assert(!libinput_event_tablet_tool_wheel_has_changed(tev));
- val = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
- ck_assert_int_eq(val, 0);
val = libinput_event_tablet_tool_get_axis_delta(tev,
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
@@ -2147,8 +2086,7 @@ START_TEST(airbrush_wheel)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
ck_assert(libinput_event_tablet_tool_slider_has_changed(tev));
- val = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
+ val = libinput_event_tablet_tool_get_slider_position(tev);
ck_assert_int_eq(val, (v - abs->minimum)/scale);
libinput_event_destroy(event);
@@ -2237,8 +2175,7 @@ START_TEST(artpen_rotation)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
ck_assert(libinput_event_tablet_tool_rotation_has_changed(tev));
- val = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
+ val = libinput_event_tablet_tool_get_rotation(tev);
/* artpen has a 90 deg offset cw */
ck_assert_int_eq(round(val), (angle + 90) % 360);
@@ -2306,10 +2243,8 @@ START_TEST(tablet_pressure_distance_exclusive)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
- pressure = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
- distance = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ pressure = libinput_event_tablet_tool_get_pressure(tev);
+ distance = libinput_event_tablet_tool_get_distance(tev);
ck_assert_double_eq(pressure, 0.0);
ck_assert_double_ne(distance, 0.0);
@@ -2328,10 +2263,8 @@ START_TEST(tablet_pressure_distance_exclusive)
event = libinput_get_event(li);
tev = libinput_event_get_tablet_tool_event(event);
- pressure = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
- distance = libinput_event_tablet_tool_get_axis_value(tev,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+ pressure = libinput_event_tablet_tool_get_pressure(tev);
+ distance = libinput_event_tablet_tool_get_distance(tev);
ck_assert_double_eq(distance, 0.0);
ck_assert_double_ne(pressure, 0.0);
@@ -2395,10 +2328,8 @@ START_TEST(tablet_calibration_set_matrix_delta)
event = libinput_get_event(li);
tablet_event = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
libinput_event_destroy(event);
litest_tablet_motion(dev, 80, 80, axes);
@@ -2408,10 +2339,8 @@ START_TEST(tablet_calibration_set_matrix_delta)
tablet_event = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_AXIS);
- dx = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X) - x;
- dy = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y) - y;
+ dx = libinput_event_tablet_tool_get_x(tablet_event) - x;
+ dy = libinput_event_tablet_tool_get_y(tablet_event) - y;
libinput_event_destroy(event);
litest_tablet_proximity_out(dev);
litest_drain_events(li);
@@ -2425,10 +2354,8 @@ START_TEST(tablet_calibration_set_matrix_delta)
event = libinput_get_event(li);
tablet_event = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
- x = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(tablet_event);
+ y = libinput_event_tablet_tool_get_y(tablet_event);
libinput_event_destroy(event);
litest_tablet_motion(dev, 80, 80, axes);
@@ -2438,10 +2365,8 @@ START_TEST(tablet_calibration_set_matrix_delta)
tablet_event = litest_is_tablet_event(event,
LIBINPUT_EVENT_TABLET_TOOL_AXIS);
- mdx = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_X) - x;
- mdy = libinput_event_tablet_tool_get_axis_value(tablet_event,
- LIBINPUT_TABLET_TOOL_AXIS_Y) - y;
+ mdx = libinput_event_tablet_tool_get_x(tablet_event) - x;
+ mdy = libinput_event_tablet_tool_get_y(tablet_event) - y;
libinput_event_destroy(event);
litest_drain_events(li);
diff --git a/tools/event-debug.c b/tools/event-debug.c
index 54ad1f2..6489546 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -344,8 +344,8 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
#define changed_sym(ev, ax) \
(libinput_event_tablet_tool_##ax##_has_changed(ev) ? "*" : "")
- x = libinput_event_tablet_tool_get_axis_value(t, LIBINPUT_TABLET_TOOL_AXIS_X);
- y = libinput_event_tablet_tool_get_axis_value(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
+ x = libinput_event_tablet_tool_get_x(t);
+ y = libinput_event_tablet_tool_get_x(t);
dx = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_X);
dy = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
printf("\t%.2f%s/%.2f%s (%.2f/%.2f)",
@@ -355,10 +355,8 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
- x = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
- y = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ x = libinput_event_tablet_tool_get_tilt_x(t);
+ y = libinput_event_tablet_tool_get_tilt_y(t);
dx = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
dy = libinput_event_tablet_tool_get_axis_delta(t,
@@ -371,10 +369,8 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE) ||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) {
- dist = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
- pressure = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
+ dist = libinput_event_tablet_tool_get_distance(t);
+ pressure = libinput_event_tablet_tool_get_pressure(t);
if (dist) {
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
@@ -391,8 +387,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
}
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) {
- rotation = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
+ rotation = libinput_event_tablet_tool_get_rotation(t);
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
printf("\trotation: %.2f%s (%.2f)",
@@ -401,8 +396,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
}
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) {
- slider = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
+ slider = libinput_event_tablet_tool_get_slider_position(t);
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
printf("\tslider: %.2f%s (%.2f)",
diff --git a/tools/event-gui.c b/tools/event-gui.c
index 996842e..64a84da 100644
--- a/tools/event-gui.c
+++ b/tools/event-gui.c
@@ -624,14 +624,10 @@ handle_event_tablet(struct libinput_event *ev, struct window *w)
w->width);
w->tool.y = libinput_event_tablet_tool_get_y_transformed(t,
w->height);
- w->tool.pressure = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
- w->tool.distance = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
- w->tool.tilt_x = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
- w->tool.tilt_y = libinput_event_tablet_tool_get_axis_value(t,
- LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
+ w->tool.pressure = libinput_event_tablet_tool_get_pressure(t);
+ w->tool.distance = libinput_event_tablet_tool_get_distance(t);
+ w->tool.tilt_x = libinput_event_tablet_tool_get_tilt_x(t);
+ w->tool.tilt_y = libinput_event_tablet_tool_get_tilt_y(t);
break;
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
x = libinput_event_tablet_tool_get_x_transformed(t, w->width);
--
2.5.0
More information about the wayland-devel
mailing list