[PATCH libinput 8/9] test: loosen up litest to allow major/minor handling

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 29 04:59:07 UTC 2017


The max values on ABS_MT_TOUCH_MAJOR/MINOR aren't hard limits, they basically
represent the size of a finger with (afaict) a suggestion that anything
greater than the max may be a palm. Disable the 0-100% range checks for those
axes so we can send custom events.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/litest.c | 12 ++++++++++--
 test/litest.h | 20 ++++++++++++++++----
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index 91e5d23..836f52b 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -2166,7 +2166,11 @@ litest_scale_axis(const struct litest_device *d,
 	const struct input_absinfo *abs;
 
 	litest_assert_double_ge(val, 0.0);
-	litest_assert_double_le(val, 100.0);
+	/* major/minor must be able to beyond 100% for large fingers */
+	if (axis != ABS_MT_TOUCH_MAJOR &&
+	    axis != ABS_MT_TOUCH_MINOR) {
+		litest_assert_double_le(val, 100.0);
+	}
 
 	abs = libevdev_get_abs_info(d->evdev, axis);
 	litest_assert_notnull(abs);
@@ -2187,8 +2191,12 @@ int
 litest_scale(const struct litest_device *d, unsigned int axis, double val)
 {
 	int min, max;
+
 	litest_assert_double_ge(val, 0.0);
-	litest_assert_double_le(val, 100.0);
+	/* major/minor must be able to beyond 100% for large fingers */
+	if (axis != ABS_MT_TOUCH_MAJOR &&
+	    axis != ABS_MT_TOUCH_MINOR)
+		litest_assert_double_le(val, 100.0);
 
 	if (axis <= ABS_Y) {
 		min = d->interface->min[axis];
diff --git a/test/litest.h b/test/litest.h
index b12cf77..959b172 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -303,12 +303,12 @@ struct axis_replacement {
 	double value;
 };
 
+/**
+ * Same as litest_axis_set_value but allows for ranges outside 0..100%
+ */
 static inline void
-litest_axis_set_value(struct axis_replacement *axes, int code, double value)
+litest_axis_set_value_unchecked(struct axis_replacement *axes, int code, double value)
 {
-	litest_assert_double_ge(value, 0.0);
-	litest_assert_double_le(value, 100.0);
-
 	while (axes->evcode != -1) {
 		if (axes->evcode == code) {
 			axes->value = value;
@@ -320,6 +320,18 @@ litest_axis_set_value(struct axis_replacement *axes, int code, double value)
 	litest_abort_msg("Missing axis code %d\n", code);
 }
 
+/**
+ * Takes a value in percent and sets the given axis to that code.
+ */
+static inline void
+litest_axis_set_value(struct axis_replacement *axes, int code, double value)
+{
+	litest_assert_double_ge(value, 0.0);
+	litest_assert_double_le(value, 100.0);
+
+	litest_axis_set_value_unchecked(axes, code, value);
+}
+
 /* A loop range, resolves to:
    for (i = lower; i < upper; i++)
  */
-- 
2.9.3



More information about the wayland-devel mailing list