summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-04-11 07:18:07 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-04-12 06:49:36 +1000
commitccc761d059c13cff1386a0fa7e356867fc55dd60 (patch)
tree9d612876ce796d6fa1108007e1c8c89d6486d2f4
parent364e0bb131b204252300f77909dbd6db92fdbc2a (diff)
downloadlibinput-ccc761d059c13cff1386a0fa7e356867fc55dd60.tar.gz
tablet: fix the airbrush slider range
Supposed to be [-1, 1] but we only generated [0, 1] Reported-by: Carlos Garnacho <carlosg@gnome.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Carlos Garnacho <carlosg@gnome.org> (cherry picked from commit 25a9f394fce25b093dce625128c2ddebed8020ec)
-rw-r--r--src/evdev-tablet.c2
-rw-r--r--test/tablet.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 9a1ac52a..84563a8f 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -201,7 +201,7 @@ normalize_dist_slider(const struct input_absinfo *absinfo)
double range = absinfo->maximum - absinfo->minimum;
double value = (absinfo->value - absinfo->minimum) / range;
- return value;
+ return value * 2 - 1;
}
static inline double
diff --git a/test/tablet.c b/test/tablet.c
index ad6ac458..3999c3d7 100644
--- a/test/tablet.c
+++ b/test/tablet.c
@@ -2532,7 +2532,7 @@ START_TEST(airbrush_tool)
}
END_TEST
-START_TEST(airbrush_wheel)
+START_TEST(airbrush_slider)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
@@ -2541,6 +2541,7 @@ START_TEST(airbrush_wheel)
const struct input_absinfo *abs;
double val;
double scale;
+ double expected;
int v;
if (!libevdev_has_event_code(dev->evdev,
@@ -2574,7 +2575,10 @@ START_TEST(airbrush_wheel)
ck_assert(libinput_event_tablet_tool_slider_has_changed(tev));
val = libinput_event_tablet_tool_get_slider_position(tev);
- ck_assert_int_eq(val, (v - abs->minimum)/scale);
+ expected = ((v - abs->minimum)/scale) * 2 - 1;
+ ck_assert_double_eq(val, expected);
+ ck_assert_double_ge(val, -1.0);
+ ck_assert_double_le(val, 1.0);
libinput_event_destroy(event);
litest_assert_empty_queue(li);
}
@@ -3655,7 +3659,7 @@ litest_setup_tests(void)
litest_add("tablet:mouse", mouse_rotation, LITEST_TABLET, LITEST_ANY);
litest_add("tablet:mouse", mouse_wheel, LITEST_TABLET, LITEST_WHEEL);
litest_add("tablet:airbrush", airbrush_tool, LITEST_TABLET, LITEST_ANY);
- litest_add("tablet:airbrush", airbrush_wheel, LITEST_TABLET, LITEST_ANY);
+ litest_add("tablet:airbrush", airbrush_slider, LITEST_TABLET, LITEST_ANY);
litest_add("tablet:artpen", artpen_tool, LITEST_TABLET, LITEST_ANY);
litest_add("tablet:artpen", artpen_rotation, LITEST_TABLET, LITEST_ANY);