mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 19:40:05 +01:00
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>
This commit is contained in:
parent
5152d94cd2
commit
25a9f394fc
2 changed files with 8 additions and 4 deletions
|
|
@ -201,7 +201,7 @@ normalize_dist_slider(const struct input_absinfo *absinfo)
|
||||||
double range = absinfo->maximum - absinfo->minimum;
|
double range = absinfo->maximum - absinfo->minimum;
|
||||||
double value = (absinfo->value - absinfo->minimum) / range;
|
double value = (absinfo->value - absinfo->minimum) / range;
|
||||||
|
|
||||||
return value;
|
return value * 2 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double
|
static inline double
|
||||||
|
|
|
||||||
|
|
@ -2532,7 +2532,7 @@ START_TEST(airbrush_tool)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST(airbrush_wheel)
|
START_TEST(airbrush_slider)
|
||||||
{
|
{
|
||||||
struct litest_device *dev = litest_current_device();
|
struct litest_device *dev = litest_current_device();
|
||||||
struct libinput *li = dev->libinput;
|
struct libinput *li = dev->libinput;
|
||||||
|
|
@ -2541,6 +2541,7 @@ START_TEST(airbrush_wheel)
|
||||||
const struct input_absinfo *abs;
|
const struct input_absinfo *abs;
|
||||||
double val;
|
double val;
|
||||||
double scale;
|
double scale;
|
||||||
|
double expected;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
if (!libevdev_has_event_code(dev->evdev,
|
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));
|
ck_assert(libinput_event_tablet_tool_slider_has_changed(tev));
|
||||||
val = libinput_event_tablet_tool_get_slider_position(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);
|
libinput_event_destroy(event);
|
||||||
litest_assert_empty_queue(li);
|
litest_assert_empty_queue(li);
|
||||||
}
|
}
|
||||||
|
|
@ -3657,7 +3661,7 @@ litest_setup_tests(void)
|
||||||
litest_add("tablet:mouse", mouse_rotation, LITEST_TABLET, LITEST_ANY);
|
litest_add("tablet:mouse", mouse_rotation, LITEST_TABLET, LITEST_ANY);
|
||||||
litest_add("tablet:mouse", mouse_wheel, LITEST_TABLET, LITEST_WHEEL);
|
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_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_tool, LITEST_TABLET, LITEST_ANY);
|
||||||
litest_add("tablet:artpen", artpen_rotation, LITEST_TABLET, LITEST_ANY);
|
litest_add("tablet:artpen", artpen_rotation, LITEST_TABLET, LITEST_ANY);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue