pad: switch the REL_WHEEL direction to match dials with scroll wheels

REL_WHEEL sends -1 for "down" and +1 for "up", so let's make sure we
keep that correct here too.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1021>
This commit is contained in:
Peter Hutterer 2024-06-21 08:39:10 +10:00
parent 436bb5cc56
commit 6fee92c959
2 changed files with 13 additions and 4 deletions

View file

@ -111,7 +111,7 @@ pad_process_relative(struct pad_dispatch *pad,
break;
case REL_WHEEL:
if (!pad->dials.has_hires_dial) {
pad->dials.dial1 = e->value * 120;
pad->dials.dial1 = -1 * e->value * 120;
pad->changed_axes |= PAD_AXIS_DIAL1;
pad_set_status(pad, PAD_AXES_UPDATED);
}
@ -124,7 +124,7 @@ pad_process_relative(struct pad_dispatch *pad,
}
break;
case REL_WHEEL_HI_RES:
pad->dials.dial1 = e->value;
pad->dials.dial1 = -1 * e->value;
pad->changed_axes |= PAD_AXIS_DIAL1;
pad_set_status(pad, PAD_AXES_UPDATED);
break;

View file

@ -526,7 +526,16 @@ START_TEST(pad_dial_low_res)
struct libinput_event_tablet_pad *pev = litest_is_pad_dial_event(ev, 0);
double v120 = libinput_event_tablet_pad_get_dial_delta_v120(pev);
ck_assert_double_eq(v120, 120.0 * direction);
switch (code) {
case REL_WHEEL: /* inverted */
ck_assert_double_eq(v120, -120.0 * direction);
break;
case REL_DIAL:
ck_assert_double_eq(v120, 120.0 * direction);
break;
default:
ck_abort();
}
libinput_event_destroy(ev);
}
}
@ -556,7 +565,7 @@ START_TEST(pad_dial_hi_res)
struct libinput_event_tablet_pad *pev = litest_is_pad_dial_event(ev, 0);
double v120 = libinput_event_tablet_pad_get_dial_delta_v120(pev);
ck_assert_double_eq(v120, increment);
ck_assert_double_eq(v120, -increment); /* REL_WHEEL is inverted */
libinput_event_destroy(ev);
}
}