[PATCH libinput] tablet: fix the airbrush slider range
Hans de Goede
hdegoede at redhat.com
Mon Apr 11 07:22:42 UTC 2016
Hi,
On 11-04-16 01:32, Peter Hutterer wrote:
> Supposed to be [-1, 1] but we only generated [0, 1]
>
> Reported-by: Carlos Garnacho <carlosg at gnome.org>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
Regards,
Hans
> ---
> src/evdev-tablet.c | 2 +-
> test/tablet.c | 10 +++++++---
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 9a1ac52..84563a8 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 ad6ac45..3999c3d 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);
>
>
More information about the wayland-devel
mailing list