diff options
-rw-r--r-- | test/litest.c | 34 | ||||
-rw-r--r-- | test/touchpad.c | 22 |
2 files changed, 38 insertions, 18 deletions
diff --git a/test/litest.c b/test/litest.c index 35b85517..52679df4 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1255,7 +1255,8 @@ litest_event(struct litest_device *d, unsigned int type, } static bool -axis_replacement_value(struct axis_replacement *axes, +axis_replacement_value(struct litest_device *d, + struct axis_replacement *axes, int32_t evcode, int32_t *value) { @@ -1266,7 +1267,7 @@ axis_replacement_value(struct axis_replacement *axes, while (axis->evcode != -1) { if (axis->evcode == evcode) { - *value = axis->value; + *value = litest_scale(d, evcode, axis->value); return true; } axis++; @@ -1307,7 +1308,7 @@ litest_auto_assign_value(struct litest_device *d, value = touching ? 0 : 1; break; default: - if (!axis_replacement_value(axes, ev->code, &value) && + if (!axis_replacement_value(d, axes, ev->code, &value) && d->interface->get_axis_default) d->interface->get_axis_default(d, ev->code, &value); break; @@ -1671,17 +1672,36 @@ litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press) litest_button_click(d, key, is_press); } +static int +litest_scale_axis(const struct litest_device *d, + unsigned int axis, + double val) +{ + const struct input_absinfo *abs; + + litest_assert_double_ge(val, 0.0); + litest_assert_double_le(val, 100.0); + + abs = libevdev_get_abs_info(d->evdev, axis); + litest_assert_notnull(abs); + + return (abs->maximum - abs->minimum) * val/100.0 + abs->minimum; +} + 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); - litest_assert_int_le(axis, (unsigned int)ABS_Y); - min = d->interface->min[axis]; - max = d->interface->max[axis]; - return (max - min) * val/100.0 + min; + if (axis <= ABS_Y) { + min = d->interface->min[axis]; + max = d->interface->max[axis]; + return (max - min) * val/100.0 + min; + } else { + return litest_scale_axis(d, axis, val); + } } void diff --git a/test/touchpad.c b/test/touchpad.c index 7bc99e98..dab2781e 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -2983,7 +2983,7 @@ START_TEST(touchpad_thumb_begin_no_motion) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3007,7 +3007,7 @@ START_TEST(touchpad_thumb_update_no_motion) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3033,7 +3033,7 @@ START_TEST(touchpad_thumb_moving) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3062,7 +3062,7 @@ START_TEST(touchpad_thumb_clickfinger) struct libinput_event *event; struct libinput_event_pointer *ptrev; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3119,7 +3119,7 @@ START_TEST(touchpad_thumb_btnarea) struct libinput_event *event; struct libinput_event_pointer *ptrev; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3155,7 +3155,7 @@ START_TEST(touchpad_thumb_edgescroll) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3186,7 +3186,7 @@ START_TEST(touchpad_thumb_tap_begin) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3219,7 +3219,7 @@ START_TEST(touchpad_thumb_tap_touch) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3252,7 +3252,7 @@ START_TEST(touchpad_thumb_tap_hold) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3286,7 +3286,7 @@ START_TEST(touchpad_thumb_tap_hold_2ndfg) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; @@ -3337,7 +3337,7 @@ START_TEST(touchpad_thumb_tap_hold_2ndfg_tap) struct libinput_event *event; struct libinput_event_pointer *ptrev; struct axis_replacement axes[] = { - { ABS_MT_PRESSURE, 190 }, + { ABS_MT_PRESSURE, 75 }, { -1, 0 } }; |