2014-01-21 14:17:01 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 Red Hat, Inc.
|
|
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2014-01-21 14:17:01 +10:00
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2014-01-21 14:17:01 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <libinput.h>
|
2014-05-26 22:12:25 +02:00
|
|
|
#include <math.h>
|
2025-07-01 16:30:11 +10:00
|
|
|
#include <stdio.h>
|
2014-01-21 14:17:01 +10:00
|
|
|
#include <unistd.h>
|
2022-06-28 13:02:22 +02:00
|
|
|
#include <valgrind/valgrind.h>
|
2014-01-21 14:17:01 +10:00
|
|
|
|
|
|
|
|
#include "libinput-util.h"
|
|
|
|
|
#include "litest.h"
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
enum cardinal { N, NE, E, SE, S, SW, W, NW };
|
2025-02-13 22:10:02 +01:00
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
static void
|
2019-06-12 14:24:57 +10:00
|
|
|
test_relative_event(struct litest_device *dev, double dx, double dy)
|
2014-01-21 14:17:01 +10:00
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
2015-07-03 08:26:04 +10:00
|
|
|
struct libinput_event *event;
|
2014-05-26 22:12:25 +02:00
|
|
|
double ev_dx, ev_dy;
|
|
|
|
|
double expected_dir;
|
|
|
|
|
double expected_length;
|
|
|
|
|
double actual_dir;
|
|
|
|
|
double actual_length;
|
2019-06-12 14:24:57 +10:00
|
|
|
const char *prop;
|
|
|
|
|
int dpi = 1000;
|
2014-01-21 14:17:01 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, dx);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, dy);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-01-21 14:17:01 +10:00
|
|
|
|
2015-07-03 08:26:04 +10:00
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
ptrev = litest_is_motion_event(event);
|
2014-05-26 22:12:25 +02:00
|
|
|
|
2019-06-12 14:24:57 +10:00
|
|
|
/* low-dpi devices scale up, not down, especially for slow motion.
|
|
|
|
|
* so a 1 unit movement in a 200dpi mouse still sends a 1 pixel
|
|
|
|
|
* movement. Work aorund this here by checking for the MOUSE_DPI
|
|
|
|
|
* property.
|
|
|
|
|
*/
|
2025-07-01 16:30:11 +10:00
|
|
|
_unref_(udev_device) *ud =
|
|
|
|
|
libinput_device_get_udev_device(dev->libinput_device);
|
2019-06-12 14:24:57 +10:00
|
|
|
litest_assert_ptr_notnull(ud);
|
|
|
|
|
prop = udev_device_get_property_value(ud, "MOUSE_DPI");
|
|
|
|
|
if (prop) {
|
|
|
|
|
dpi = parse_mouse_dpi_property(prop);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_ne(dpi, 0);
|
2019-06-12 14:24:57 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
dx *= 1000.0 / dpi;
|
|
|
|
|
dy *= 1000.0 / dpi;
|
2019-06-12 14:24:57 +10:00
|
|
|
}
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
expected_length = sqrt(4 * dx * dx + 4 * dy * dy);
|
2014-05-26 22:12:25 +02:00
|
|
|
expected_dir = atan2(dx, dy);
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
ev_dx = libinput_event_pointer_get_dx(ptrev);
|
|
|
|
|
ev_dy = libinput_event_pointer_get_dy(ptrev);
|
2025-07-01 16:30:11 +10:00
|
|
|
actual_length = sqrt(ev_dx * ev_dx + ev_dy * ev_dy);
|
2014-05-26 22:12:25 +02:00
|
|
|
actual_dir = atan2(ev_dx, ev_dy);
|
|
|
|
|
|
|
|
|
|
/* Check the length of the motion vector (tolerate 1.0 indifference). */
|
2019-06-11 08:24:10 +10:00
|
|
|
litest_assert_double_ge(fabs(expected_length), actual_length);
|
2014-05-26 22:12:25 +02:00
|
|
|
|
|
|
|
|
/* Check the direction of the motion vector (tolerate 2π/4 radians
|
|
|
|
|
* indifference). */
|
2019-06-11 08:24:10 +10:00
|
|
|
litest_assert_double_lt(fabs(expected_dir - actual_dir), M_PI_2);
|
2014-01-21 14:17:01 +10:00
|
|
|
|
2015-07-03 08:26:04 +10:00
|
|
|
libinput_event_destroy(event);
|
2014-05-26 22:12:25 +02:00
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
2014-01-21 14:17:01 +10:00
|
|
|
}
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
static void
|
|
|
|
|
disable_button_scrolling(struct litest_device *device)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *dev = device->libinput_device;
|
2025-07-01 16:30:11 +10:00
|
|
|
enum libinput_config_status status, expected;
|
2015-04-28 16:40:29 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_method(
|
|
|
|
|
dev,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
2015-04-28 16:40:29 +10:00
|
|
|
|
2015-05-04 11:29:49 +10:00
|
|
|
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
|
2015-05-04 11:40:39 +10:00
|
|
|
litest_assert_int_eq(status, expected);
|
2015-04-28 16:40:29 +10:00
|
|
|
}
|
|
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
START_TEST(pointer_motion_relative)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
|
2015-07-03 08:26:04 +10:00
|
|
|
/* send a single event, the first movement
|
|
|
|
|
is always decelerated by 0.3 */
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(dev->libinput);
|
2015-07-03 08:26:04 +10:00
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
test_relative_event(dev, 1, 0);
|
|
|
|
|
test_relative_event(dev, 1, 1);
|
|
|
|
|
test_relative_event(dev, 1, -1);
|
|
|
|
|
test_relative_event(dev, 0, 1);
|
|
|
|
|
|
|
|
|
|
test_relative_event(dev, -1, 0);
|
|
|
|
|
test_relative_event(dev, -1, 1);
|
|
|
|
|
test_relative_event(dev, -1, -1);
|
|
|
|
|
test_relative_event(dev, 0, -1);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-07-03 09:09:16 +10:00
|
|
|
START_TEST(pointer_motion_relative_zero)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* NOTE: this test does virtually nothing. The kernel should not
|
|
|
|
|
* allow 0/0 events to be passed to userspace. If it ever happens,
|
|
|
|
|
* let's hope this test fails if we do the wrong thing.
|
|
|
|
|
*/
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 0);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-07-03 09:09:16 +10:00
|
|
|
}
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* send a single event, the first movement
|
|
|
|
|
is always decelerated by 0.3 */
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-07-03 09:09:16 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(libinput_get_event(li));
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 0);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(dev->libinput);
|
2015-07-03 09:09:16 +10:00
|
|
|
}
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-07-03 08:43:27 +10:00
|
|
|
START_TEST(pointer_motion_relative_min_decel)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
double evx, evy;
|
|
|
|
|
int dx, dy;
|
|
|
|
|
double len;
|
2025-07-01 16:30:11 +10:00
|
|
|
enum cardinal direction =
|
|
|
|
|
litest_test_param_get_i32(test_env->params, "direction");
|
2015-07-03 08:43:27 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
switch (direction) {
|
2025-02-13 22:10:02 +01:00
|
|
|
case N:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = 0;
|
|
|
|
|
dy = 1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case NE:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = 1;
|
|
|
|
|
dy = 1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case E:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = 1;
|
|
|
|
|
dy = 0;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case SE:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = 1;
|
|
|
|
|
dy = -1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case S:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = 0;
|
|
|
|
|
dy = -1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case SW:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = -1;
|
|
|
|
|
dy = -1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case W:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = -1;
|
|
|
|
|
dy = 0;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case NW:
|
2025-07-01 16:30:11 +10:00
|
|
|
dx = -1;
|
|
|
|
|
dy = 1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
litest_abort_msg("Invalid direction %d", direction);
|
|
|
|
|
}
|
2015-07-03 08:43:27 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, dx);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, dy);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-07-03 08:43:27 +10:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
ptrev = litest_is_motion_event(event);
|
|
|
|
|
evx = libinput_event_pointer_get_dx(ptrev);
|
|
|
|
|
evy = libinput_event_pointer_get_dy(ptrev);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert((evx == 0.0) == (dx == 0));
|
|
|
|
|
litest_assert((evy == 0.0) == (dy == 0));
|
2015-07-03 08:43:27 +10:00
|
|
|
|
2015-07-20 11:09:19 +10:00
|
|
|
len = hypot(evx, evy);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_ge(fabs(len), 0.3);
|
2015-07-03 08:43:27 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-10-29 11:58:09 +10:00
|
|
|
static void
|
|
|
|
|
test_absolute_event(struct litest_device *dev, double x, double y)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
double ex, ey;
|
2015-05-04 11:29:49 +10:00
|
|
|
enum libinput_event_type type = LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE;
|
2014-10-29 11:58:09 +10:00
|
|
|
|
|
|
|
|
litest_touch_down(dev, 0, x, y);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-10-29 11:58:09 +10:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
2015-05-04 11:40:39 +10:00
|
|
|
litest_assert_notnull(event);
|
|
|
|
|
litest_assert_int_eq(libinput_event_get_type(event), type);
|
2014-10-29 11:58:09 +10:00
|
|
|
|
|
|
|
|
ptrev = libinput_event_get_pointer_event(event);
|
2019-06-11 08:24:10 +10:00
|
|
|
litest_assert_ptr_notnull(ptrev);
|
2014-10-29 11:58:09 +10:00
|
|
|
|
|
|
|
|
ex = libinput_event_pointer_get_absolute_x_transformed(ptrev, 100);
|
|
|
|
|
ey = libinput_event_pointer_get_absolute_y_transformed(ptrev, 100);
|
2015-05-04 11:40:39 +10:00
|
|
|
litest_assert_int_eq((int)(ex + 0.5), (int)x);
|
|
|
|
|
litest_assert_int_eq((int)(ey + 0.5), (int)y);
|
2014-10-29 11:58:09 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_motion_absolute)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
test_absolute_event(dev, 0, 100);
|
|
|
|
|
test_absolute_event(dev, 100, 0);
|
|
|
|
|
test_absolute_event(dev, 50, 50);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-05-08 14:41:42 +10:00
|
|
|
START_TEST(pointer_absolute_initial_state)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
2025-04-07 13:15:28 +10:00
|
|
|
struct libinput *libinput1;
|
2015-05-08 14:41:42 +10:00
|
|
|
struct libinput_event *ev1, *ev2;
|
|
|
|
|
struct libinput_event_pointer *p1, *p2;
|
2025-02-13 22:10:02 +01:00
|
|
|
int axis = litest_test_param_get_i32(test_env->params, "axis");
|
2015-05-08 14:41:42 +10:00
|
|
|
|
|
|
|
|
libinput1 = dev->libinput;
|
|
|
|
|
litest_touch_down(dev, 0, 40, 60);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
/* device is now on some x/y value */
|
|
|
|
|
litest_drain_events(libinput1);
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *libinput2 = litest_create_context();
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_path_add_device(libinput2, libevdev_uinput_get_devnode(dev->uinput));
|
2015-05-08 14:41:42 +10:00
|
|
|
litest_drain_events(libinput2);
|
|
|
|
|
|
|
|
|
|
if (axis == ABS_X)
|
|
|
|
|
litest_touch_down(dev, 0, 40, 70);
|
|
|
|
|
else
|
|
|
|
|
litest_touch_down(dev, 0, 70, 60);
|
|
|
|
|
litest_touch_up(dev, 0);
|
|
|
|
|
|
|
|
|
|
litest_wait_for_event(libinput1);
|
|
|
|
|
litest_wait_for_event(libinput2);
|
|
|
|
|
|
|
|
|
|
while (libinput_next_event_type(libinput1)) {
|
|
|
|
|
ev1 = libinput_get_event(libinput1);
|
|
|
|
|
ev2 = libinput_get_event(libinput2);
|
|
|
|
|
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(ev1),
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_get_type(ev1),
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_event_get_type(ev2));
|
2015-05-08 14:41:42 +10:00
|
|
|
|
|
|
|
|
p1 = libinput_event_get_pointer_event(ev1);
|
|
|
|
|
p2 = libinput_event_get_pointer_event(ev2);
|
|
|
|
|
|
2024-10-14 15:26:57 +10:00
|
|
|
litest_assert_double_eq(libinput_event_pointer_get_absolute_x(p1),
|
|
|
|
|
libinput_event_pointer_get_absolute_x(p2));
|
|
|
|
|
litest_assert_double_eq(libinput_event_pointer_get_absolute_y(p1),
|
|
|
|
|
libinput_event_pointer_get_absolute_y(p2));
|
2015-05-08 14:41:42 +10:00
|
|
|
|
|
|
|
|
libinput_event_destroy(ev1);
|
|
|
|
|
libinput_event_destroy(ev2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-12-04 11:44:09 +08:00
|
|
|
static void
|
|
|
|
|
test_unaccel_event(struct litest_device *dev, int dx, int dy)
|
|
|
|
|
{
|
2025-07-01 16:30:11 +10:00
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
double ev_dx, ev_dy;
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_event(dev, EV_REL, REL_X, dx);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, dy);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_dispatch(li);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
ptrev = litest_is_motion_event(event);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
ev_dx = libinput_event_pointer_get_dx_unaccelerated(ptrev);
|
|
|
|
|
ev_dy = libinput_event_pointer_get_dy_unaccelerated(ptrev);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_int_eq(dx, ev_dx);
|
|
|
|
|
litest_assert_int_eq(dy, ev_dy);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_event_destroy(event);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_drain_events(dev->libinput);
|
2014-12-04 11:44:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_motion_unaccel)
|
|
|
|
|
{
|
2025-07-01 16:30:11 +10:00
|
|
|
struct litest_device *dev = litest_current_device();
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_drain_events(dev->libinput);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
test_unaccel_event(dev, 10, 0);
|
|
|
|
|
test_unaccel_event(dev, 10, 10);
|
|
|
|
|
test_unaccel_event(dev, 10, -10);
|
|
|
|
|
test_unaccel_event(dev, 0, 10);
|
2014-12-04 11:44:09 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
test_unaccel_event(dev, -10, 0);
|
|
|
|
|
test_unaccel_event(dev, -10, 10);
|
|
|
|
|
test_unaccel_event(dev, -10, -10);
|
|
|
|
|
test_unaccel_event(dev, 0, -10);
|
2014-12-04 11:44:09 +08:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
static void
|
2014-07-03 11:00:54 +10:00
|
|
|
test_button_event(struct litest_device *dev, unsigned int button, int state)
|
2014-01-21 14:17:01 +10:00
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, button, state);
|
2014-01-21 14:17:01 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
button,
|
|
|
|
|
state ? LIBINPUT_BUTTON_STATE_PRESSED
|
|
|
|
|
: LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-01-21 14:17:01 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_button)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
disable_button_scrolling(dev);
|
|
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
test_button_event(dev, BTN_LEFT, 1);
|
|
|
|
|
test_button_event(dev, BTN_LEFT, 0);
|
|
|
|
|
|
|
|
|
|
/* press it twice for good measure */
|
|
|
|
|
test_button_event(dev, BTN_LEFT, 1);
|
|
|
|
|
test_button_event(dev, BTN_LEFT, 0);
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (libinput_device_pointer_has_button(dev->libinput_device, BTN_RIGHT)) {
|
2014-01-21 14:17:01 +10:00
|
|
|
test_button_event(dev, BTN_RIGHT, 1);
|
|
|
|
|
test_button_event(dev, BTN_RIGHT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-16 16:22:36 +02:00
|
|
|
/* Skip middle button test on trackpoints (used for scrolling) */
|
2025-07-01 16:30:11 +10:00
|
|
|
if (libinput_device_pointer_has_button(dev->libinput_device, BTN_MIDDLE)) {
|
2014-01-21 14:17:01 +10:00
|
|
|
test_button_event(dev, BTN_MIDDLE, 1);
|
|
|
|
|
test_button_event(dev, BTN_MIDDLE, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-07-27 16:02:46 +02:00
|
|
|
START_TEST(pointer_button_auto_release)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
enum libinput_event_type type;
|
|
|
|
|
struct libinput_event_pointer *pevent;
|
|
|
|
|
struct {
|
|
|
|
|
int code;
|
|
|
|
|
int released;
|
|
|
|
|
} buttons[] = {
|
2025-07-01 16:30:11 +10:00
|
|
|
{
|
|
|
|
|
.code = BTN_LEFT,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.code = BTN_MIDDLE,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.code = BTN_EXTRA,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.code = BTN_SIDE,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.code = BTN_BACK,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.code = BTN_FORWARD,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.code = BTN_4,
|
|
|
|
|
},
|
2014-07-27 16:02:46 +02:00
|
|
|
};
|
|
|
|
|
int events[2 * (ARRAY_LENGTH(buttons) + 1)];
|
|
|
|
|
unsigned i;
|
|
|
|
|
int button;
|
|
|
|
|
int valid_code;
|
|
|
|
|
|
|
|
|
|
/* Enable all tested buttons on the device */
|
|
|
|
|
for (i = 0; i < 2 * ARRAY_LENGTH(buttons);) {
|
|
|
|
|
button = buttons[i / 2].code;
|
|
|
|
|
events[i++] = EV_KEY;
|
|
|
|
|
events[i++] = button;
|
|
|
|
|
}
|
|
|
|
|
events[i++] = -1;
|
|
|
|
|
events[i++] = -1;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *libinput = litest_create_context();
|
2014-07-27 16:02:46 +02:00
|
|
|
dev = litest_add_device_with_overrides(libinput,
|
|
|
|
|
LITEST_MOUSE,
|
|
|
|
|
"Generic mouse",
|
2025-07-01 16:30:11 +10:00
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
events);
|
2014-07-27 16:02:46 +02:00
|
|
|
|
|
|
|
|
litest_drain_events(libinput);
|
|
|
|
|
|
|
|
|
|
/* Send pressed events, without releasing */
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(buttons); ++i) {
|
|
|
|
|
test_button_event(dev, buttons[i].code, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_drain_events(libinput);
|
|
|
|
|
|
|
|
|
|
/* "Disconnect" device */
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2014-07-27 16:02:46 +02:00
|
|
|
|
|
|
|
|
/* Mark all released buttons until device is removed */
|
|
|
|
|
while (1) {
|
|
|
|
|
event = libinput_get_event(libinput);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(event);
|
2014-07-27 16:02:46 +02:00
|
|
|
type = libinput_event_get_type(event);
|
|
|
|
|
|
|
|
|
|
if (type == LIBINPUT_EVENT_DEVICE_REMOVED) {
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-18 14:44:38 +10:00
|
|
|
litest_assert_event_type(event, LIBINPUT_EVENT_POINTER_BUTTON);
|
2014-07-27 16:02:46 +02:00
|
|
|
pevent = libinput_event_get_pointer_event(event);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_pointer_get_button_state(pevent),
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-07-27 16:02:46 +02:00
|
|
|
button = libinput_event_pointer_get_button(pevent);
|
|
|
|
|
|
|
|
|
|
valid_code = 0;
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(buttons); ++i) {
|
|
|
|
|
if (buttons[i].code == button) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(buttons[i].released, 0);
|
2014-07-27 16:02:46 +02:00
|
|
|
buttons[i].released = 1;
|
|
|
|
|
valid_code = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(valid_code, 1);
|
2014-07-27 16:02:46 +02:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check that all pressed buttons has been released. */
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(buttons); ++i) {
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(buttons[i].released, 1);
|
2014-07-27 16:02:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-01-13 12:18:43 +10:00
|
|
|
START_TEST(pointer_button_has_no_button)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
unsigned int code;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert(
|
|
|
|
|
!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER));
|
2017-01-13 12:18:43 +10:00
|
|
|
|
|
|
|
|
for (code = BTN_LEFT; code < KEY_OK; code++)
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(-1,
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_device_pointer_has_button(device, code));
|
2017-01-13 12:18:43 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-07-18 16:12:27 +10:00
|
|
|
START_TEST(pointer_recover_from_lost_button_count)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libevdev *evdev = dev->evdev;
|
|
|
|
|
|
|
|
|
|
disable_button_scrolling(dev);
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
|
2017-07-18 16:12:27 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-07-18 16:12:27 +10:00
|
|
|
|
|
|
|
|
/* Grab for the release to make libinput lose count */
|
|
|
|
|
libevdev_grab(evdev, LIBEVDEV_GRAB);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 0);
|
2017-07-18 16:12:27 +10:00
|
|
|
libevdev_grab(evdev, LIBEVDEV_UNGRAB);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
|
2017-07-18 16:12:27 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-18 16:12:27 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-10-28 15:08:32 +10:00
|
|
|
static inline double
|
|
|
|
|
wheel_click_count(struct litest_device *dev, int which)
|
|
|
|
|
{
|
|
|
|
|
const char *prop = NULL;
|
|
|
|
|
int count;
|
|
|
|
|
double angle = 0.0;
|
|
|
|
|
|
2025-06-25 15:35:57 +10:00
|
|
|
_unref_(udev_device) *d = libinput_device_get_udev_device(dev->libinput_device);
|
2016-10-28 15:08:32 +10:00
|
|
|
litest_assert_ptr_notnull(d);
|
|
|
|
|
|
|
|
|
|
if (which == REL_HWHEEL)
|
2025-07-01 16:30:11 +10:00
|
|
|
prop = udev_device_get_property_value(
|
|
|
|
|
d,
|
|
|
|
|
"MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL");
|
2016-12-05 14:21:34 +10:00
|
|
|
if (!prop)
|
2016-10-28 15:08:32 +10:00
|
|
|
prop = udev_device_get_property_value(d, "MOUSE_WHEEL_CLICK_COUNT");
|
2025-06-25 15:35:57 +10:00
|
|
|
if (prop) {
|
|
|
|
|
count = parse_mouse_wheel_click_count_property(prop);
|
|
|
|
|
litest_assert_int_ne(count, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
angle = 360.0 / count;
|
2025-06-25 15:35:57 +10:00
|
|
|
}
|
2016-10-28 15:08:32 +10:00
|
|
|
|
|
|
|
|
return angle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline double
|
2016-08-16 14:48:47 +10:00
|
|
|
wheel_click_angle(struct litest_device *dev, int which)
|
2015-11-09 10:18:17 +10:00
|
|
|
{
|
2016-08-16 14:48:47 +10:00
|
|
|
const char *prop = NULL;
|
2015-11-09 10:18:17 +10:00
|
|
|
const int default_angle = 15;
|
2016-10-28 15:08:32 +10:00
|
|
|
double angle;
|
|
|
|
|
|
|
|
|
|
angle = wheel_click_count(dev, which);
|
|
|
|
|
if (angle != 0.0)
|
|
|
|
|
return angle;
|
2015-11-09 10:18:17 +10:00
|
|
|
|
2016-10-28 15:08:32 +10:00
|
|
|
angle = default_angle;
|
2025-06-25 15:35:57 +10:00
|
|
|
_unref_(udev_device) *d = libinput_device_get_udev_device(dev->libinput_device);
|
2015-11-09 10:18:17 +10:00
|
|
|
litest_assert_ptr_notnull(d);
|
|
|
|
|
|
2016-08-16 14:48:47 +10:00
|
|
|
if (which == REL_HWHEEL)
|
2025-07-01 16:30:11 +10:00
|
|
|
prop = udev_device_get_property_value(
|
|
|
|
|
d,
|
|
|
|
|
"MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL");
|
2016-12-05 14:21:34 +10:00
|
|
|
if (!prop)
|
2016-08-16 14:48:47 +10:00
|
|
|
prop = udev_device_get_property_value(d, "MOUSE_WHEEL_CLICK_ANGLE");
|
2025-06-25 15:35:57 +10:00
|
|
|
if (prop) {
|
|
|
|
|
angle = parse_mouse_wheel_click_angle_property(prop);
|
|
|
|
|
if (angle == 0.0)
|
|
|
|
|
angle = default_angle;
|
|
|
|
|
}
|
2015-11-09 10:18:17 +10:00
|
|
|
|
|
|
|
|
return angle;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
static void
|
2018-11-22 10:24:54 +10:00
|
|
|
test_high_and_low_wheel_events_value(struct litest_device *dev,
|
|
|
|
|
int which,
|
|
|
|
|
int v120_amount)
|
2014-01-21 14:17:01 +10:00
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
2014-12-24 11:10:04 +10:00
|
|
|
enum libinput_pointer_axis axis;
|
2016-11-28 11:08:01 +10:00
|
|
|
enum libinput_pointer_axis_source source;
|
2014-01-21 14:17:01 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
double scroll_step, expected, discrete, v120;
|
2015-11-09 10:18:17 +10:00
|
|
|
|
2016-08-16 14:48:47 +10:00
|
|
|
scroll_step = wheel_click_angle(dev, which);
|
2020-05-18 11:47:29 +10:00
|
|
|
source = LIBINPUT_POINTER_AXIS_SOURCE_WHEEL;
|
2025-07-01 16:30:11 +10:00
|
|
|
expected = scroll_step * (v120_amount / 120);
|
|
|
|
|
discrete = v120_amount / 120;
|
2018-11-22 10:24:54 +10:00
|
|
|
v120 = v120_amount;
|
2014-01-21 14:17:01 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (libinput_device_config_scroll_get_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device)) {
|
2014-11-18 12:03:48 +10:00
|
|
|
expected *= -1;
|
2015-01-13 15:15:02 +10:00
|
|
|
discrete *= -1;
|
2018-11-22 10:24:54 +10:00
|
|
|
v120 *= -1;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-18 16:53:05 +10:00
|
|
|
double angle = libinput_device_config_rotation_get_angle(dev->libinput_device);
|
|
|
|
|
if (angle >= 160.0 && angle <= 220.0) {
|
|
|
|
|
expected *= -1;
|
|
|
|
|
discrete *= -1;
|
|
|
|
|
v120 *= -1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
axis = (which == REL_WHEEL || which == REL_WHEEL_HI_RES)
|
|
|
|
|
? LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL
|
|
|
|
|
: LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
|
2018-11-22 10:24:54 +10:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
2022-06-07 09:55:32 +10:00
|
|
|
litest_assert_notnull(event);
|
2018-11-22 10:24:54 +10:00
|
|
|
|
2025-07-14 10:45:25 +10:00
|
|
|
bool have_lores = false, have_hires = false;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
while (event) {
|
2018-11-22 10:24:54 +10:00
|
|
|
ptrev = litest_is_axis_event(event,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
|
|
|
|
|
axis,
|
|
|
|
|
source);
|
|
|
|
|
|
2025-07-14 10:40:26 +10:00
|
|
|
if (litest_is_high_res_axis_event(event)) {
|
2025-07-14 10:45:25 +10:00
|
|
|
have_hires = true;
|
2025-07-14 10:40:26 +10:00
|
|
|
litest_assert_double_eq(
|
|
|
|
|
libinput_event_pointer_get_scroll_value_v120(ptrev,
|
|
|
|
|
axis),
|
|
|
|
|
v120);
|
|
|
|
|
} else {
|
2025-07-14 10:45:25 +10:00
|
|
|
have_lores = true;
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_double_eq(
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_event_pointer_get_axis_value(ptrev, axis),
|
|
|
|
|
expected);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_double_eq(
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_event_pointer_get_axis_value_discrete(ptrev,
|
|
|
|
|
axis),
|
|
|
|
|
discrete);
|
2018-11-22 10:24:54 +10:00
|
|
|
}
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
event = libinput_get_event(li);
|
2015-01-13 15:15:02 +10:00
|
|
|
}
|
2025-07-14 10:45:25 +10:00
|
|
|
|
|
|
|
|
if (have_lores)
|
|
|
|
|
litest_assert_msg(have_hires, "Missing high-res wheels events");
|
2018-11-22 10:24:54 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_wheel_event(struct litest_device *dev, int which, int amount)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
int event_amount = amount;
|
2014-11-18 12:03:48 +10:00
|
|
|
|
2025-07-14 11:00:32 +10:00
|
|
|
switch (which) {
|
|
|
|
|
case REL_WHEEL:
|
|
|
|
|
case REL_HWHEEL:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
litest_assert_msg("Invalid axis for %s", __func__);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-21 14:17:01 +10:00
|
|
|
/* mouse scroll wheels are 'upside down' */
|
|
|
|
|
if (which == REL_WHEEL)
|
2018-11-22 10:24:54 +10:00
|
|
|
event_amount *= -1;
|
|
|
|
|
litest_event(dev, EV_REL, which, event_amount);
|
2014-01-21 14:17:01 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-01-21 14:17:01 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, which, amount * 120);
|
2014-01-21 14:17:01 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_wheel)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
2015-04-08 09:54:31 +10:00
|
|
|
/* make sure we hit at least one of the below two conditions */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL) ||
|
2025-07-01 16:30:11 +10:00
|
|
|
libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL));
|
2014-01-21 14:17:01 +10:00
|
|
|
|
2015-04-08 09:54:31 +10:00
|
|
|
if (libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL)) {
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, -1);
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, 1);
|
|
|
|
|
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, -5);
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, 6);
|
|
|
|
|
}
|
2014-01-21 14:17:01 +10:00
|
|
|
|
|
|
|
|
if (libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL)) {
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, -1);
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, 1);
|
|
|
|
|
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, -5);
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
static void
|
|
|
|
|
test_hi_res_wheel_event(struct litest_device *dev, int which, int v120_amount)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
switch (which) {
|
2018-11-22 10:24:54 +10:00
|
|
|
case REL_WHEEL_HI_RES:
|
|
|
|
|
/* mouse scroll wheels are 'upside down' */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, -1 * v120_amount);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_event(dev, EV_REL, REL_WHEEL, -1 * v120_amount / 120);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
break;
|
|
|
|
|
case REL_HWHEEL_HI_RES:
|
|
|
|
|
litest_event(dev, EV_REL, REL_HWHEEL_HI_RES, v120_amount);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_event(dev, EV_REL, REL_HWHEEL, v120_amount / 120);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-11-22 10:24:54 +10:00
|
|
|
|
|
|
|
|
test_high_and_low_wheel_events_value(dev, which, v120_amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_wheel_hires)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
2025-07-03 13:50:17 +10:00
|
|
|
unsigned int axis = litest_test_param_get_i32(test_env->params, "axis");
|
2018-11-22 10:24:54 +10:00
|
|
|
|
2025-07-03 13:50:17 +10:00
|
|
|
if (!libevdev_has_event_code(dev->evdev, EV_REL, axis))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2018-11-22 10:24:54 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
2025-07-03 13:50:17 +10:00
|
|
|
test_hi_res_wheel_event(dev, axis, -120);
|
|
|
|
|
test_hi_res_wheel_event(dev, axis, 120);
|
2018-11-22 10:24:54 +10:00
|
|
|
|
2025-07-03 13:50:17 +10:00
|
|
|
test_hi_res_wheel_event(dev, axis, -5 * 120);
|
|
|
|
|
test_hi_res_wheel_event(dev, axis, 6 * 120);
|
2018-11-22 10:24:54 +10:00
|
|
|
|
2025-07-21 14:00:14 +10:00
|
|
|
if (dev->which == LITEST_MOUSE_WHEEL_HIRES_DISABLED)
|
|
|
|
|
return LITEST_NOT_APPLICABLE;
|
|
|
|
|
|
2025-07-03 13:50:17 +10:00
|
|
|
test_hi_res_wheel_event(dev, axis, 30);
|
|
|
|
|
test_hi_res_wheel_event(dev, axis, -60);
|
|
|
|
|
test_hi_res_wheel_event(dev, axis, -40);
|
|
|
|
|
test_hi_res_wheel_event(dev, axis, 180);
|
2018-11-22 10:24:54 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2022-06-08 09:25:02 +10:00
|
|
|
START_TEST(pointer_scroll_wheel_hires_send_only_lores)
|
2021-09-24 18:08:01 +02:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2022-06-08 09:25:02 +10:00
|
|
|
unsigned int lores_code, hires_code;
|
|
|
|
|
int direction;
|
2025-07-01 16:30:11 +10:00
|
|
|
enum libinput_pointer_axis axis =
|
|
|
|
|
litest_test_param_get_i32(test_env->params, "axis");
|
2022-06-08 09:25:02 +10:00
|
|
|
|
2025-02-13 22:10:02 +01:00
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
lores_code = REL_WHEEL;
|
|
|
|
|
hires_code = REL_WHEEL_HI_RES;
|
|
|
|
|
direction = -1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
lores_code = REL_HWHEEL;
|
|
|
|
|
hires_code = REL_HWHEEL_HI_RES;
|
|
|
|
|
direction = 1;
|
2025-02-13 22:10:02 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
litest_abort_msg("Invalid test axis '%d'", axis);
|
2022-06-08 09:25:02 +10:00
|
|
|
}
|
2021-09-24 18:08:01 +02:00
|
|
|
|
2025-08-01 12:52:04 +10:00
|
|
|
if (dev->which == LITEST_MOUSE_WHEEL_HIRES_DISABLED)
|
|
|
|
|
return LITEST_NOT_APPLICABLE;
|
|
|
|
|
|
|
|
|
|
if (!libevdev_has_event_code(dev->evdev, EV_REL, lores_code) ||
|
2022-06-08 09:25:02 +10:00
|
|
|
!libevdev_has_event_code(dev->evdev, EV_REL, hires_code))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2021-09-24 18:08:01 +02:00
|
|
|
|
2022-06-08 09:25:02 +10:00
|
|
|
/* Device claims to have HI_RES, but doesn't send events for it. Make
|
|
|
|
|
* sure we handle this correctly.
|
|
|
|
|
*/
|
2021-09-24 18:08:01 +02:00
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
litest_set_log_handler_bug(li);
|
|
|
|
|
|
2022-06-08 09:25:02 +10:00
|
|
|
litest_event(dev, EV_REL, lores_code, 1);
|
2021-09-24 18:08:01 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2022-06-08 09:25:02 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, lores_code, direction * 120);
|
2021-09-24 18:08:01 +02:00
|
|
|
|
2022-06-08 09:25:02 +10:00
|
|
|
litest_event(dev, EV_REL, lores_code, -1);
|
2021-09-24 18:08:01 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2022-06-08 09:25:02 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, lores_code, direction * -120);
|
2021-09-24 18:08:01 +02:00
|
|
|
|
2022-06-08 09:25:02 +10:00
|
|
|
litest_event(dev, EV_REL, lores_code, 2);
|
2021-09-24 18:08:01 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2022-06-08 09:25:02 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, lores_code, direction * 240);
|
2021-09-24 18:08:01 +02:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
litest_restore_log_handler(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2025-07-21 14:00:14 +10:00
|
|
|
START_TEST(pointer_scroll_wheel_hires_disabled)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
int direction;
|
|
|
|
|
unsigned int lores_code, hires_code;
|
|
|
|
|
enum libinput_pointer_axis axis =
|
|
|
|
|
litest_test_param_get_i32(test_env->params, "axis");
|
|
|
|
|
|
|
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
|
|
|
|
lores_code = REL_WHEEL;
|
|
|
|
|
hires_code = REL_WHEEL_HI_RES;
|
|
|
|
|
direction = -1;
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
|
|
|
|
lores_code = REL_HWHEEL;
|
|
|
|
|
hires_code = REL_HWHEEL_HI_RES;
|
|
|
|
|
direction = 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
litest_abort_msg("Invalid test axis '%d'", axis);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_log_group("High-res events on this device should be ignored") {
|
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, hires_code, 60);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_log_group("Only low-res events should be handled") {
|
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, hires_code, 60);
|
|
|
|
|
litest_event(dev, EV_REL, lores_code, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_dispatch(li);
|
|
|
|
|
|
|
|
|
|
litest_drain_events_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
_destroy_(libinput_event) *ev = libinput_get_event(li);
|
|
|
|
|
struct libinput_event_pointer *pev = litest_is_axis_event(
|
|
|
|
|
ev,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
|
|
|
|
|
axis,
|
|
|
|
|
0);
|
|
|
|
|
int v120 =
|
|
|
|
|
libinput_event_pointer_get_scroll_value_v120(pev, axis);
|
|
|
|
|
litest_assert_int_eq(v120, direction * 120);
|
|
|
|
|
}
|
|
|
|
|
litest_drain_events_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2021-09-29 18:32:54 +02:00
|
|
|
START_TEST(pointer_scroll_wheel_inhibit_small_deltas)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2025-07-03 12:01:32 +10:00
|
|
|
uint32_t delta = litest_test_param_get_u32(test_env->params, "hires-delta");
|
2021-09-29 18:32:54 +02:00
|
|
|
|
2025-06-27 18:37:57 +10:00
|
|
|
if (!libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL_HI_RES) ||
|
2021-09-29 18:32:54 +02:00
|
|
|
!libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL_HI_RES))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2021-09-29 18:32:54 +02:00
|
|
|
|
2025-07-21 14:00:14 +10:00
|
|
|
if (dev->which == LITEST_MOUSE_WHEEL_HIRES_DISABLED)
|
|
|
|
|
return LITEST_NOT_APPLICABLE;
|
|
|
|
|
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
2025-07-03 12:01:32 +10:00
|
|
|
/* A single delta (below the hardcoded threshold 60) is ignored */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, delta);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2025-07-03 12:01:32 +10:00
|
|
|
/* Once we get two events in the same direction trigger scroll */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, delta);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-09-29 18:32:54 +02:00
|
|
|
|
2025-07-03 12:01:32 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -2 * delta);
|
|
|
|
|
|
|
|
|
|
/* Once the threshold is reached, every scroll deltas are reported */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, delta);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2025-07-03 12:01:32 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -delta);
|
2021-09-29 18:32:54 +02:00
|
|
|
|
|
|
|
|
/* When the scroll timeout is triggered, ignore small deltas again */
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_wheel_scroll(li);
|
2021-09-29 18:32:54 +02:00
|
|
|
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, -delta);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_event(dev, EV_REL, REL_HWHEEL_HI_RES, delta);
|
2025-04-15 13:23:31 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_dispatch(li);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_wheel_inhibit_small_deltas_reduce_delta)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
if (!libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL_HI_RES) ||
|
|
|
|
|
!libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL_HI_RES))
|
|
|
|
|
return LITEST_NOT_APPLICABLE;
|
|
|
|
|
|
2025-07-21 14:00:14 +10:00
|
|
|
if (dev->which == LITEST_MOUSE_WHEEL_HIRES_DISABLED)
|
|
|
|
|
return LITEST_NOT_APPLICABLE;
|
|
|
|
|
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
2025-07-04 11:03:22 +10:00
|
|
|
/* A single delta (below the hardcoded threshold 30) is ignored */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 29);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-09-29 18:32:54 +02:00
|
|
|
litest_assert_empty_queue(li);
|
2025-07-03 12:01:32 +10:00
|
|
|
|
|
|
|
|
/* A second smaller delta changes the internal threshold */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 5);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_dispatch(li);
|
|
|
|
|
|
2025-07-04 11:03:22 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -34);
|
2025-07-03 12:01:32 +10:00
|
|
|
|
|
|
|
|
litest_timeout_wheel_scroll(li);
|
|
|
|
|
|
|
|
|
|
/* Internal threshold is now 5 so two deltas of 5 trigger */
|
|
|
|
|
litest_log_group("Internal threshold is now 5 so two deltas of 5 trigger") {
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 5);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_dispatch(li);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 5);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_dispatch(li);
|
|
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_timeout_wheel_scroll(li);
|
|
|
|
|
|
|
|
|
|
litest_log_group("Internal threshold is now 5 so one delta of 10 trigger") {
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 10);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_dispatch(li);
|
|
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -10);
|
|
|
|
|
}
|
2021-09-29 18:32:54 +02:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2021-09-30 17:50:26 +02:00
|
|
|
START_TEST(pointer_scroll_wheel_inhibit_dir_change)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2025-07-03 12:01:32 +10:00
|
|
|
uint32_t delta = litest_test_param_get_u32(test_env->params, "hires-delta");
|
2021-09-30 17:50:26 +02:00
|
|
|
|
2025-06-27 18:37:57 +10:00
|
|
|
if (!libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL_HI_RES))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2021-09-30 17:50:26 +02:00
|
|
|
|
2025-07-21 14:00:14 +10:00
|
|
|
if (dev->which == LITEST_MOUSE_WHEEL_HIRES_DISABLED)
|
|
|
|
|
return LITEST_NOT_APPLICABLE;
|
|
|
|
|
|
2021-09-30 17:50:26 +02:00
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
/* Scroll one detent and a bit */
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 120 + delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2025-07-03 12:01:32 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -120 - delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
|
|
|
|
|
/* Scroll below the threshold in the oposite direction should be ignored */
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, -delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-09-30 17:50:26 +02:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* But should be triggered if the scroll continues in the same direction */
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, -2 * delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2025-07-03 12:01:32 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, 3 * delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
|
|
|
|
|
/* Scroll above the threshold in the same dir should be triggered */
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 2 * delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2025-07-03 12:01:32 +10:00
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -2 * delta);
|
2021-09-30 17:50:26 +02:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2025-06-08 01:29:33 -04:00
|
|
|
START_TEST(pointer_scroll_wheel_no_inhibit_small_deltas_when_virtual)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Scroll deltas below the threshold (60) must *not* be ignored */
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL_HI_RES, 15);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_dispatch(li);
|
|
|
|
|
test_high_and_low_wheel_events_value(dev, REL_WHEEL_HI_RES, -15);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2022-06-06 20:24:16 +02:00
|
|
|
START_TEST(pointer_scroll_wheel_lenovo_scrollpoint)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
double v;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
/* Lenovo ScrollPoint has a trackstick instead of a wheel, data sent
|
|
|
|
|
* via REL_WHEEL is close to x/y coordinate space.
|
|
|
|
|
*/
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL, 30);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL, -60);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2022-06-06 20:24:16 +02:00
|
|
|
|
|
|
|
|
/* Hi-res scroll event first */
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
litest_assert(litest_is_high_res_axis_event(event));
|
|
|
|
|
ptrev = litest_is_axis_event(event,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS);
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
v = libinput_event_pointer_get_scroll_value(
|
|
|
|
|
ptrev,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
|
2022-06-06 20:24:16 +02:00
|
|
|
litest_assert_double_eq(v, -30.0);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
/* legacy lo-res scroll event */
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
litest_assert(!litest_is_high_res_axis_event(event));
|
|
|
|
|
ptrev = litest_is_axis_event(event,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS);
|
2025-07-01 16:30:11 +10:00
|
|
|
v = libinput_event_pointer_get_axis_value(
|
|
|
|
|
ptrev,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
|
2022-06-06 20:24:16 +02:00
|
|
|
litest_assert_double_eq(v, -30.0);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
/* Hi-res scroll event first */
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
ptrev = litest_is_axis_event(event,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS);
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
v = libinput_event_pointer_get_scroll_value(
|
|
|
|
|
ptrev,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
|
2022-06-06 20:24:16 +02:00
|
|
|
litest_assert_double_eq(v, 60.0);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
|
|
|
|
|
/* legacy lo-res scroll event */
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
litest_assert(!litest_is_high_res_axis_event(event));
|
|
|
|
|
ptrev = litest_is_axis_event(event,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS);
|
2025-07-01 16:30:11 +10:00
|
|
|
v = libinput_event_pointer_get_axis_value(
|
|
|
|
|
ptrev,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
|
2022-06-06 20:24:16 +02:00
|
|
|
litest_assert_double_eq(v, 60.0);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-11-18 12:03:48 +10:00
|
|
|
START_TEST(pointer_scroll_natural_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_int_ge(
|
|
|
|
|
libinput_device_config_scroll_has_natural_scroll(dev->libinput_device),
|
|
|
|
|
1);
|
|
|
|
|
litest_assert_int_eq(libinput_device_config_scroll_get_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device),
|
|
|
|
|
0);
|
|
|
|
|
litest_assert_int_eq(
|
|
|
|
|
libinput_device_config_scroll_get_default_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device),
|
|
|
|
|
0);
|
2014-11-18 12:03:48 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-06 10:48:13 +10:00
|
|
|
START_TEST(pointer_scroll_natural_defaults_noscroll)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_has_natural_scroll(dev->libinput_device))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-06 10:48:13 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_int_eq(libinput_device_config_scroll_get_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device),
|
|
|
|
|
0);
|
|
|
|
|
litest_assert_int_eq(
|
|
|
|
|
libinput_device_config_scroll_get_default_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device),
|
|
|
|
|
0);
|
2017-02-06 10:48:13 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-11-18 12:03:48 +10:00
|
|
|
START_TEST(pointer_scroll_natural_enable_config)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_int_eq(libinput_device_config_scroll_get_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device),
|
|
|
|
|
1);
|
2014-11-18 12:03:48 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
0);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_int_eq(libinput_device_config_scroll_get_natural_scroll_enabled(
|
|
|
|
|
dev->libinput_device),
|
|
|
|
|
0);
|
2014-11-18 12:03:48 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_natural_wheel)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(device, 1);
|
|
|
|
|
|
2015-04-08 09:54:31 +10:00
|
|
|
/* make sure we hit at least one of the below two conditions */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL) ||
|
2025-07-01 16:30:11 +10:00
|
|
|
libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL));
|
2014-11-18 12:03:48 +10:00
|
|
|
|
2015-04-08 09:54:31 +10:00
|
|
|
if (libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL)) {
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, -1);
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, 1);
|
|
|
|
|
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, -5);
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, 6);
|
|
|
|
|
}
|
2014-11-18 12:03:48 +10:00
|
|
|
|
|
|
|
|
if (libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL)) {
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, -1);
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, 1);
|
|
|
|
|
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, -5);
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-01-13 15:44:33 +10:00
|
|
|
START_TEST(pointer_scroll_has_axis_invalid)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *pev;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
if (!libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-01-13 15:44:33 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_REL, REL_WHEEL, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-01-13 15:44:33 +10:00
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
pev = litest_is_axis_event(event,
|
2018-11-22 10:24:54 +10:00
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
|
2017-01-13 15:44:33 +10:00
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
2017-01-20 12:33:53 +10:00
|
|
|
0);
|
2017-01-13 15:44:33 +10:00
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_has_axis(pev, -1), 0);
|
|
|
|
|
litest_assert_int_eq(libinput_event_pointer_has_axis(pev, 2), 0);
|
|
|
|
|
litest_assert_int_eq(libinput_event_pointer_has_axis(pev, 3), 0);
|
|
|
|
|
litest_assert_int_eq(libinput_event_pointer_has_axis(pev, 0xffff), 0);
|
2017-01-13 15:44:33 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2023-04-18 16:53:05 +10:00
|
|
|
START_TEST(pointer_scroll_with_rotation)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2025-02-06 20:14:57 +01:00
|
|
|
double angle = litest_test_param_get_double(test_env->params, "angle");
|
2023-04-18 16:53:05 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
libinput_device_config_rotation_set_angle(device, angle);
|
|
|
|
|
|
|
|
|
|
/* make sure we hit at least one of the below two conditions */
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL) ||
|
2025-07-01 16:30:11 +10:00
|
|
|
libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL));
|
2023-04-18 16:53:05 +10:00
|
|
|
|
|
|
|
|
if (libevdev_has_event_code(dev->evdev, EV_REL, REL_WHEEL)) {
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, -1);
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, 1);
|
|
|
|
|
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, -5);
|
|
|
|
|
test_wheel_event(dev, REL_WHEEL, 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libevdev_has_event_code(dev->evdev, EV_REL, REL_HWHEEL)) {
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, -1);
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, 1);
|
|
|
|
|
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, -5);
|
|
|
|
|
test_wheel_event(dev, REL_HWHEEL, 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-04-01 22:24:10 +02:00
|
|
|
START_TEST(pointer_seat_button_count)
|
|
|
|
|
{
|
2019-06-15 13:50:33 -07:00
|
|
|
struct litest_device *devices[4];
|
|
|
|
|
const int num_devices = ARRAY_LENGTH(devices);
|
2014-04-01 22:24:10 +02:00
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_pointer *tev;
|
|
|
|
|
int i;
|
2015-02-19 07:22:59 +10:00
|
|
|
int seat_button_count = 0;
|
2014-04-01 22:24:10 +02:00
|
|
|
int expected_seat_button_count = 0;
|
|
|
|
|
char device_name[255];
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *libinput = litest_create_context();
|
2014-04-01 22:24:10 +02:00
|
|
|
for (i = 0; i < num_devices; ++i) {
|
2014-07-04 07:55:51 +10:00
|
|
|
sprintf(device_name, "litest Generic mouse (%d)", i);
|
2014-04-01 22:24:10 +02:00
|
|
|
devices[i] = litest_add_device_with_overrides(libinput,
|
|
|
|
|
LITEST_MOUSE,
|
|
|
|
|
device_name,
|
2025-07-01 16:30:11 +10:00
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
2014-04-01 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_devices; ++i)
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_button_click_debounced(devices[i], libinput, BTN_LEFT, true);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-04-01 22:24:10 +02:00
|
|
|
while ((ev = libinput_get_event(libinput))) {
|
2025-07-01 16:30:11 +10:00
|
|
|
if (libinput_event_get_type(ev) != LIBINPUT_EVENT_POINTER_BUTTON) {
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-04-01 22:24:10 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tev = libinput_event_get_pointer_event(ev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(tev);
|
|
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button(tev),
|
2024-10-11 13:55:56 +10:00
|
|
|
(unsigned int)BTN_LEFT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_pointer_get_button_state(tev),
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
|
|
|
|
++expected_seat_button_count;
|
2025-07-01 16:30:11 +10:00
|
|
|
seat_button_count = libinput_event_pointer_get_seat_button_count(tev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(expected_seat_button_count, seat_button_count);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-04-01 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(seat_button_count, num_devices);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < num_devices; ++i)
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_button_click_debounced(devices[i], libinput, BTN_LEFT, false);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-04-01 22:24:10 +02:00
|
|
|
while ((ev = libinput_get_event(libinput))) {
|
2025-07-01 16:30:11 +10:00
|
|
|
if (libinput_event_get_type(ev) != LIBINPUT_EVENT_POINTER_BUTTON) {
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-04-01 22:24:10 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tev = libinput_event_get_pointer_event(ev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_notnull(tev);
|
|
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_button(tev),
|
2024-10-11 13:55:56 +10:00
|
|
|
(unsigned int)BTN_LEFT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(libinput_event_pointer_get_button_state(tev),
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
|
|
|
|
--expected_seat_button_count;
|
2025-07-01 16:30:11 +10:00
|
|
|
seat_button_count = libinput_event_pointer_get_seat_button_count(tev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(expected_seat_button_count, seat_button_count);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
2014-04-23 11:04:48 +10:00
|
|
|
libinput_event_destroy(ev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(libinput);
|
2014-04-01 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(seat_button_count, 0);
|
2014-04-01 22:24:10 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < num_devices; ++i)
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(devices[i]);
|
2014-04-01 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-08-26 11:41:19 +10:00
|
|
|
START_TEST(pointer_no_calibration)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *d = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
int rc;
|
2025-07-01 16:30:11 +10:00
|
|
|
float calibration[6] = { 0 };
|
2014-08-26 11:41:19 +10:00
|
|
|
|
|
|
|
|
rc = libinput_device_config_calibration_has_matrix(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-08-26 11:41:19 +10:00
|
|
|
rc = libinput_device_config_calibration_get_matrix(d, calibration);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
rc = libinput_device_config_calibration_get_default_matrix(d, calibration);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-08-26 11:41:19 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_calibration_set_matrix(d, calibration);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2014-08-26 11:41:19 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-09-23 12:46:02 +10:00
|
|
|
START_TEST(pointer_left_handed_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *d = dev->libinput_device;
|
|
|
|
|
int rc;
|
|
|
|
|
|
2017-01-10 09:22:16 +10:00
|
|
|
if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE &&
|
|
|
|
|
libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-01-10 09:22:16 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
rc = libinput_device_config_left_handed_is_available(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_ne(rc, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
rc = libinput_device_config_left_handed_get(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
rc = libinput_device_config_left_handed_get_default(d);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(rc, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_left_handed)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *d = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
status = libinput_device_config_left_handed_set(d, 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, 1);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2017-02-17 10:38:09 +10:00
|
|
|
if (libinput_device_pointer_has_button(d, BTN_MIDDLE)) {
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_MIDDLE, 1);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_MIDDLE, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_left_handed_during_click)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *d = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
|
|
|
|
/* Change while button is down, expect correct release event */
|
2015-01-06 21:20:22 -05:00
|
|
|
status = libinput_device_config_left_handed_set(d, 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-09-23 12:46:02 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_left_handed_during_click_multiple_buttons)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *d = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2017-02-17 10:40:34 +10:00
|
|
|
if (!libinput_device_pointer_has_button(d, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-17 10:40:34 +10:00
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
|
2014-09-23 12:46:02 +10:00
|
|
|
litest_drain_events(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2015-01-06 21:20:22 -05:00
|
|
|
status = libinput_device_config_left_handed_set(d, 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
|
|
|
|
/* No left-handed until all buttons were down */
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, 1);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, 0);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 0);
|
2014-09-23 12:46:02 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-09-23 12:46:02 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2023-03-29 10:56:41 +10:00
|
|
|
START_TEST(pointer_left_handed_disable_with_button_down)
|
|
|
|
|
{
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2023-03-29 10:56:41 +10:00
|
|
|
struct litest_device *dev = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
status = libinput_device_config_left_handed_set(dev->libinput_device, 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2023-03-29 10:56:41 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2023-03-29 10:56:41 +10:00
|
|
|
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2023-03-29 10:56:41 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2023-03-29 10:56:41 +10:00
|
|
|
|
|
|
|
|
struct libinput_event *event = libinput_get_event(li);
|
|
|
|
|
litest_assert_event_type(event, LIBINPUT_EVENT_DEVICE_REMOVED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2014-11-06 16:35:13 +01:00
|
|
|
START_TEST(pointer_scroll_button)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
/* Make left button switch to scrolling mode */
|
2014-11-19 12:16:28 +10:00
|
|
|
libinput_device_config_scroll_set_method(dev->libinput_device,
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
|
|
|
|
libinput_device_config_scroll_set_button(dev->libinput_device, BTN_LEFT);
|
2014-11-06 16:35:13 +01:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_button_scroll(dev, BTN_LEFT, 1, 6);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
6);
|
2014-11-06 16:35:13 +01:00
|
|
|
litest_button_scroll(dev, BTN_LEFT, 1, -7);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
-7);
|
2014-11-06 16:35:13 +01:00
|
|
|
litest_button_scroll(dev, BTN_LEFT, 8, 1);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
|
|
|
|
8);
|
2014-11-06 16:35:13 +01:00
|
|
|
litest_button_scroll(dev, BTN_LEFT, -9, 1);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
|
|
|
|
|
-9);
|
2014-11-06 16:35:13 +01:00
|
|
|
|
2017-02-20 13:32:07 +10:00
|
|
|
/* scroll smaller than the threshold should not generate axis events */
|
2014-11-06 16:35:13 +01:00
|
|
|
litest_button_scroll(dev, BTN_LEFT, 1, 1);
|
|
|
|
|
|
2017-02-20 13:32:07 +10:00
|
|
|
litest_button_scroll(dev, BTN_LEFT, 0, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2014-11-06 16:35:13 +01:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* Restore default scroll behavior */
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_device_config_scroll_set_method(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
libinput_device_config_scroll_get_default_method(dev->libinput_device));
|
|
|
|
|
libinput_device_config_scroll_set_button(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
libinput_device_config_scroll_get_default_button(dev->libinput_device));
|
2014-11-06 16:35:13 +01:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-06 11:23:18 +10:00
|
|
|
START_TEST(pointer_scroll_button_noscroll)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
uint32_t methods, button;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
methods = libinput_device_config_scroll_get_method(device);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_int_eq(methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN, 0U);
|
2017-02-06 11:23:18 +10:00
|
|
|
button = libinput_device_config_scroll_get_button(device);
|
2024-10-11 13:55:56 +10:00
|
|
|
litest_assert_int_eq(button, 0U);
|
2017-02-06 11:23:18 +10:00
|
|
|
button = libinput_device_config_scroll_get_default_button(device);
|
2024-10-11 13:55:56 +10:00
|
|
|
litest_assert_int_eq(button, 0U);
|
2017-02-06 11:23:18 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2017-02-06 11:23:18 +10:00
|
|
|
status = libinput_device_config_scroll_set_button(device, BTN_LEFT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2017-02-06 11:23:18 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-04-12 12:03:00 +10:00
|
|
|
START_TEST(pointer_scroll_button_no_event_before_timeout)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
int i;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(device->libinput_device, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-17 10:40:34 +10:00
|
|
|
|
|
|
|
|
litest_disable_middleemu(device);
|
2016-04-12 12:03:00 +10:00
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
|
|
|
|
libinput_device_config_scroll_set_method(device->libinput_device,
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
|
|
|
|
libinput_device_config_scroll_set_button(device->libinput_device, BTN_LEFT);
|
2016-04-12 12:03:00 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_LEFT, true);
|
2016-04-12 12:03:00 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(device, EV_REL, REL_Y, 1);
|
|
|
|
|
litest_event(device, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_LEFT, false);
|
2017-02-20 13:32:07 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2016-04-12 12:03:00 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-04-11 10:06:36 +10:00
|
|
|
START_TEST(pointer_scroll_button_middle_emulation)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
int i;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2016-04-11 10:06:36 +10:00
|
|
|
|
|
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2016-04-11 10:06:36 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2016-04-11 10:06:36 +10:00
|
|
|
status = libinput_device_config_scroll_set_button(device, BTN_MIDDLE);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2016-04-11 10:06:36 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2019-09-25 16:49:08 +10:00
|
|
|
litest_button_click(dev, BTN_LEFT, 1);
|
|
|
|
|
litest_button_click(dev, BTN_RIGHT, 1);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2016-04-11 10:06:36 +10:00
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, -1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2016-04-11 10:06:36 +10:00
|
|
|
|
2019-09-25 16:49:08 +10:00
|
|
|
litest_button_click(dev, BTN_LEFT, 0);
|
|
|
|
|
litest_button_click(dev, BTN_RIGHT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2016-04-11 10:06:36 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
-1);
|
2016-04-11 10:06:36 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* Restore default scroll behavior */
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_device_config_scroll_set_method(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
libinput_device_config_scroll_get_default_method(dev->libinput_device));
|
|
|
|
|
libinput_device_config_scroll_set_button(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
libinput_device_config_scroll_get_default_button(dev->libinput_device));
|
2016-04-11 10:06:36 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-01-30 12:00:47 +10:00
|
|
|
START_TEST(pointer_scroll_button_device_remove_while_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2019-01-30 12:00:47 +10:00
|
|
|
|
|
|
|
|
dev = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
libinput_device_config_scroll_set_method(dev->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_device_config_scroll_set_button(dev->libinput_device, BTN_LEFT);
|
2019-01-30 12:00:47 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-30 12:00:47 +10:00
|
|
|
|
|
|
|
|
/* delete the device while the timer is still active */
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-30 12:00:47 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-03-20 10:56:51 +10:00
|
|
|
static void
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_enable_scroll_button_lock(struct litest_device *dev, unsigned int button)
|
2019-03-20 10:56:51 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_button(device, button);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_button_lock(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-03-20 10:56:51 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_enable_scroll_button_lock(dev, BTN_LEFT);
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
6);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* back to motion */
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
enum libinput_config_scroll_button_lock_state state;
|
|
|
|
|
|
|
|
|
|
state = libinput_device_config_scroll_get_button_lock(dev->libinput_device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_scroll_get_default_button_lock(
|
|
|
|
|
dev->libinput_device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED);
|
2019-03-20 10:56:51 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_config)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
enum libinput_config_scroll_button_lock_state state;
|
|
|
|
|
|
|
|
|
|
state = libinput_device_config_scroll_get_button_lock(dev->libinput_device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_scroll_get_default_button_lock(
|
|
|
|
|
dev->libinput_device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_button_lock(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-03-20 10:56:51 +10:00
|
|
|
state = libinput_device_config_scroll_get_button_lock(dev->libinput_device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_button_lock(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2019-03-20 10:56:51 +10:00
|
|
|
state = libinput_device_config_scroll_get_button_lock(dev->libinput_device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_button_lock(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED + 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2019-03-20 10:56:51 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_enable_while_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
|
|
|
|
|
/* Enable lock while button is down */
|
|
|
|
|
litest_enable_scroll_button_lock(dev, BTN_LEFT);
|
|
|
|
|
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no scrolling yet */
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
|
|
|
|
|
/* but on the next button press we scroll lock */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
6);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* back to motion */
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_enable_while_down_just_lock)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* switch method first, but enable lock when we already have a
|
|
|
|
|
* button down */
|
|
|
|
|
libinput_device_config_scroll_set_method(dev->libinput_device,
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
|
|
|
|
libinput_device_config_scroll_set_button(dev->libinput_device, BTN_LEFT);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
2025-07-01 16:30:11 +10:00
|
|
|
libinput_device_config_scroll_set_button_lock(
|
|
|
|
|
dev->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no scrolling yet */
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
|
|
|
|
|
/* but on the next button press we scroll lock */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
6);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* back to motion */
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_otherbutton)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_enable_scroll_button_lock(dev, BTN_LEFT);
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_assert_empty_queue(li);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
/* other button passes on normally */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_only_axis_events(li, LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
/* other button passes on normally */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
/* stop scroll lock */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_only_axis_events(li, LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
/* other button passes on normally */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_enable_while_otherbutton_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_middlebutton(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Enable lock while button is down */
|
|
|
|
|
litest_enable_scroll_button_lock(dev, BTN_LEFT);
|
|
|
|
|
|
|
|
|
|
/* We only enable once we go to a neutral state so this still counts
|
|
|
|
|
* as normal button event */
|
|
|
|
|
for (int twice = 0; twice < 2; twice++) {
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_LEFT,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* now we should trigger it */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
6);
|
2019-03-20 10:56:51 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* back to motion */
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
enum mb_buttonorder {
|
|
|
|
|
LLRR, /* left down, left up, r down, r up */
|
|
|
|
|
LRLR, /* left down, right down, left up, right up */
|
|
|
|
|
LRRL,
|
|
|
|
|
RRLL,
|
|
|
|
|
RLRL,
|
2025-02-06 20:14:57 +01:00
|
|
|
RLLR
|
2019-03-20 10:56:51 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_middlebutton)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2025-07-01 16:30:11 +10:00
|
|
|
enum mb_buttonorder buttonorder =
|
|
|
|
|
litest_test_param_get_i32(test_env->params, "buttonorder");
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
if (!libinput_device_config_middle_emulation_is_available(dev->libinput_device))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
litest_enable_middleemu(dev);
|
|
|
|
|
|
|
|
|
|
litest_enable_scroll_button_lock(dev, BTN_LEFT);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* We expect scroll lock to work only where left and right are never
|
|
|
|
|
* held down simultaneously. Everywhere else we expect middle button
|
|
|
|
|
* instead.
|
|
|
|
|
*/
|
|
|
|
|
switch (buttonorder) {
|
|
|
|
|
case LLRR:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
break;
|
|
|
|
|
case LRLR:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
break;
|
|
|
|
|
case LRRL:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
break;
|
|
|
|
|
case RRLL:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
break;
|
|
|
|
|
case RLRL:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
break;
|
|
|
|
|
case RLLR:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_middlebutton(li);
|
|
|
|
|
litest_timeout_buttonscroll(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
/* motion events are the same for all of them */
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 6);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
switch (buttonorder) {
|
|
|
|
|
case LLRR:
|
|
|
|
|
case RRLL:
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-03-20 10:56:51 +10:00
|
|
|
|
|
|
|
|
switch (buttonorder) {
|
|
|
|
|
case LLRR:
|
|
|
|
|
case RRLL:
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_RIGHT,
|
2019-03-20 10:56:51 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_RIGHT,
|
2019-03-20 10:56:51 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_scroll(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
6);
|
2019-03-20 10:56:51 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
break;
|
|
|
|
|
case LRLR:
|
|
|
|
|
case LRRL:
|
|
|
|
|
case RLRL:
|
|
|
|
|
case RLLR:
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
2019-03-20 10:56:51 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
2019-03-20 10:56:51 +10:00
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
2019-03-20 10:56:51 +10:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_scroll_button_lock_doubleclick_nomove)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_enable_scroll_button_lock(dev, BTN_LEFT);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* double click without move in between counts as single click */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_LEFT, false);
|
|
|
|
|
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* But a non-scroll button it should work normally */
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, true);
|
|
|
|
|
litest_button_click_debounced(dev, li, BTN_RIGHT, false);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-04-28 16:45:35 +10:00
|
|
|
START_TEST(pointer_scroll_nowheel_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2017-02-20 09:26:05 +10:00
|
|
|
enum libinput_config_scroll_method method, expected;
|
2015-04-28 16:45:35 +10:00
|
|
|
uint32_t button;
|
|
|
|
|
|
2017-02-20 09:26:05 +10:00
|
|
|
/* button scrolling is only enabled if there is a
|
|
|
|
|
middle button present */
|
2022-06-06 20:24:16 +02:00
|
|
|
if (libinput_device_pointer_has_button(device, BTN_MIDDLE) &&
|
|
|
|
|
dev->which != LITEST_LENOVO_SCROLLPOINT)
|
2017-02-20 09:26:05 +10:00
|
|
|
expected = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
|
|
|
|
|
else
|
|
|
|
|
expected = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
|
|
|
|
|
2015-04-28 16:45:35 +10:00
|
|
|
method = libinput_device_config_scroll_get_method(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(method, expected);
|
2015-04-28 16:45:35 +10:00
|
|
|
|
|
|
|
|
method = libinput_device_config_scroll_get_default_method(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(method, expected);
|
2015-04-28 16:45:35 +10:00
|
|
|
|
2017-02-20 09:26:05 +10:00
|
|
|
if (method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
|
|
|
|
|
button = libinput_device_config_scroll_get_button(device);
|
2024-10-11 13:55:56 +10:00
|
|
|
litest_assert_int_eq(button, (unsigned int)BTN_MIDDLE);
|
2017-02-20 09:26:05 +10:00
|
|
|
button = libinput_device_config_scroll_get_default_button(device);
|
2024-10-11 13:55:56 +10:00
|
|
|
litest_assert_int_eq(button, (unsigned int)BTN_MIDDLE);
|
2017-02-20 09:26:05 +10:00
|
|
|
}
|
2015-04-28 16:45:35 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-17 08:39:51 +10:00
|
|
|
START_TEST(pointer_scroll_defaults_logitech_marble)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_scroll_method method;
|
2017-02-27 11:20:14 +10:00
|
|
|
uint32_t button;
|
2017-02-17 08:39:51 +10:00
|
|
|
|
|
|
|
|
method = libinput_device_config_scroll_get_method(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(method, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
2017-02-17 08:39:51 +10:00
|
|
|
method = libinput_device_config_scroll_get_default_method(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(method, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
2017-02-27 11:20:14 +10:00
|
|
|
|
|
|
|
|
button = libinput_device_config_scroll_get_button(device);
|
2024-10-11 13:55:56 +10:00
|
|
|
litest_assert_int_eq(button, (unsigned int)BTN_SIDE);
|
2017-02-17 08:39:51 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-02-03 09:35:19 +10:00
|
|
|
START_TEST(pointer_accel_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
double speed;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_config_accel_is_available(device));
|
|
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_default_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
0.0);
|
|
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device), 0.0);
|
2015-02-03 09:35:19 +10:00
|
|
|
|
|
|
|
|
for (speed = -2.0; speed < -1.0; speed += 0.2) {
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_speed(device, speed);
|
|
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
0.0);
|
2015-02-03 09:35:19 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (speed = -1.0; speed <= 1.0; speed += 0.2) {
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_speed(device, speed);
|
|
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
speed);
|
2015-02-03 09:35:19 +10:00
|
|
|
}
|
|
|
|
|
|
2017-01-05 20:27:18 +10:00
|
|
|
for (speed = 1.2; speed <= 2.0; speed += 0.2) {
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_speed(device, speed);
|
|
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
1.0);
|
2015-02-03 09:35:19 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
Fix an abort if the device speed is NaN
When using libinput with xf86-input-libinput, the device speed is
represented as a float passed via X properties.
If a buggy client gives a broken value, the conversions that occur
can cause the value of speed to be NaN (not a number), aka infinity.
In C, any comparison with NaN always gives false, whatever the value.
So that test in libinput_device_config_accel_set_speed():
(speed < 1.0 || speed > 1.0)
will necessarily return FALSE, defeating the test of range.
However, since since any comparison with NaN is false, the
opposite assert() in accelerator_set_speed():
(speed >= 1.0 && speed <= 1.0)
will be false as well, thus triggering the abort() and the crash of
the entire X server along with it.
The solution is to use the same construct in both routines, so that
it fails gracefully in libinput_device_config_accel_set_speed().
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-05 14:33:31 +01:00
|
|
|
START_TEST(pointer_accel_invalid)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_config_accel_is_available(device));
|
Fix an abort if the device speed is NaN
When using libinput with xf86-input-libinput, the device speed is
represented as a float passed via X properties.
If a buggy client gives a broken value, the conversions that occur
can cause the value of speed to be NaN (not a number), aka infinity.
In C, any comparison with NaN always gives false, whatever the value.
So that test in libinput_device_config_accel_set_speed():
(speed < 1.0 || speed > 1.0)
will necessarily return FALSE, defeating the test of range.
However, since since any comparison with NaN is false, the
opposite assert() in accelerator_set_speed():
(speed >= 1.0 && speed <= 1.0)
will be false as well, thus triggering the abort() and the crash of
the entire X server along with it.
The solution is to use the same construct in both routines, so that
it fails gracefully in libinput_device_config_accel_set_speed().
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-05 14:33:31 +01:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_speed(device, NAN);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_speed(device, INFINITY);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
Fix an abort if the device speed is NaN
When using libinput with xf86-input-libinput, the device speed is
represented as a float passed via X properties.
If a buggy client gives a broken value, the conversions that occur
can cause the value of speed to be NaN (not a number), aka infinity.
In C, any comparison with NaN always gives false, whatever the value.
So that test in libinput_device_config_accel_set_speed():
(speed < 1.0 || speed > 1.0)
will necessarily return FALSE, defeating the test of range.
However, since since any comparison with NaN is false, the
opposite assert() in accelerator_set_speed():
(speed >= 1.0 && speed <= 1.0)
will be false as well, thus triggering the abort() and the crash of
the entire X server along with it.
The solution is to use the same construct in both routines, so that
it fails gracefully in libinput_device_config_accel_set_speed().
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-05 14:33:31 +01:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-02-03 09:37:53 +10:00
|
|
|
START_TEST(pointer_accel_defaults_absolute)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
double speed;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_config_accel_is_available(device));
|
|
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_default_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
0.0);
|
|
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device), 0.0);
|
2015-02-03 09:37:53 +10:00
|
|
|
|
|
|
|
|
for (speed = -2.0; speed <= 2.0; speed += 0.2) {
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_speed(device, speed);
|
2015-02-03 09:37:53 +10:00
|
|
|
if (speed >= -1.0 && speed <= 1.0)
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status,
|
2025-07-01 16:30:11 +10:00
|
|
|
LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2015-02-03 09:37:53 +10:00
|
|
|
else
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
0.0);
|
2015-02-03 09:37:53 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-04-24 14:59:18 +10:00
|
|
|
START_TEST(pointer_accel_defaults_absolute_relative)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_config_accel_is_available(device));
|
|
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_default_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
0.0);
|
|
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device), 0.0);
|
2015-04-24 14:59:18 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-03-19 11:43:49 +10:00
|
|
|
START_TEST(pointer_accel_direction_change)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
struct libinput_event_pointer *pev;
|
|
|
|
|
int i;
|
|
|
|
|
double delta;
|
|
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, -1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
}
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2015-03-19 11:43:49 +10:00
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
do {
|
|
|
|
|
pev = libinput_event_get_pointer_event(event);
|
|
|
|
|
|
|
|
|
|
delta = libinput_event_pointer_get_dx(pev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_le(delta, 0.0);
|
2015-03-19 11:43:49 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
} while (libinput_next_event_type(li) != LIBINPUT_EVENT_NONE);
|
|
|
|
|
|
|
|
|
|
pev = libinput_event_get_pointer_event(event);
|
|
|
|
|
delta = libinput_event_pointer_get_dx(pev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_gt(delta, 0.0);
|
2015-03-19 11:43:49 +10:00
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-08-27 13:13:47 +10:00
|
|
|
START_TEST(pointer_accel_profile_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2018-05-21 12:09:20 +10:00
|
|
|
enum libinput_config_status status;
|
2015-08-27 13:13:47 +10:00
|
|
|
enum libinput_config_accel_profile profile;
|
|
|
|
|
uint32_t profiles;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_config_accel_is_available(device));
|
2015-08-27 13:13:47 +10:00
|
|
|
|
|
|
|
|
profile = libinput_device_config_accel_get_default_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
|
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
|
|
|
|
profiles = libinput_device_config_accel_get_profiles(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
|
|
|
|
litest_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
|
|
|
|
litest_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2018-05-21 12:09:20 +10:00
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
2016-04-08 15:51:28 +08:00
|
|
|
profile = libinput_device_config_accel_get_default_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
2016-04-08 15:51:28 +08:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2018-05-21 12:09:20 +10:00
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_accel_config_reset_to_defaults)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
double default_speed = libinput_device_config_accel_get_default_speed(device);
|
|
|
|
|
|
|
|
|
|
/* There are no settings for these profiles to toggle, so we expect it
|
|
|
|
|
* to simply reset to defaults */
|
|
|
|
|
enum libinput_config_accel_profile profiles[] = {
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ARRAY_FOR_EACH(profiles, profile) {
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_enum_eq(
|
|
|
|
|
libinput_device_config_accel_set_speed(device, 1.0),
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device),
|
|
|
|
|
1.0);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
struct libinput_config_accel *config = libinput_config_accel_create(
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
|
|
|
|
|
litest_assert_enum_eq(
|
|
|
|
|
libinput_device_config_accel_apply(device, config),
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_double_eq(libinput_device_config_accel_get_speed(device),
|
2025-07-01 16:30:11 +10:00
|
|
|
default_speed);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
libinput_config_accel_destroy(config);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_accel_config)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
enum libinput_config_accel_profile profile;
|
2023-01-27 01:23:35 +02:00
|
|
|
enum libinput_config_status valid = LIBINPUT_CONFIG_STATUS_SUCCESS,
|
|
|
|
|
invalid = LIBINPUT_CONFIG_STATUS_INVALID;
|
2023-02-18 21:12:13 +02:00
|
|
|
enum libinput_config_accel_type accel_types[] = {
|
|
|
|
|
LIBINPUT_ACCEL_TYPE_FALLBACK,
|
|
|
|
|
LIBINPUT_ACCEL_TYPE_MOTION,
|
|
|
|
|
LIBINPUT_ACCEL_TYPE_SCROLL,
|
|
|
|
|
};
|
2023-01-27 01:23:35 +02:00
|
|
|
struct custom_config_test {
|
|
|
|
|
double step;
|
|
|
|
|
double points[4];
|
|
|
|
|
enum libinput_config_status expected_status;
|
|
|
|
|
} tests[] = {
|
2025-07-01 16:30:11 +10:00
|
|
|
{ 0.5, { 1.0, 2.0, 2.5, 2.6 }, valid },
|
2023-02-18 21:12:13 +02:00
|
|
|
{ 0.003, { 0.1, 0.3, 0.4, 0.45 }, valid },
|
2025-07-01 16:30:11 +10:00
|
|
|
{ 2.7, { 1.0, 3.0, 4.5, 4.5 }, valid },
|
|
|
|
|
{ 0, { 1.0, 2.0, 2.5, 2.6 }, invalid },
|
|
|
|
|
{ -1, { 1.0, 2.0, 2.5, 2.6 }, invalid },
|
|
|
|
|
{ 1e10, { 1.0, 2.0, 2.5, 2.6 }, invalid },
|
|
|
|
|
{ 1, { 1.0, 2.0, -2.5, 2.6 }, invalid },
|
|
|
|
|
{ 1, { 1.0, 2.0, 1e10, 2.6 }, invalid },
|
2023-01-27 01:23:35 +02:00
|
|
|
};
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_config_accel_is_available(device));
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
|
|
|
|
struct libinput_config_accel *config_custom_default =
|
|
|
|
|
libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
|
|
|
|
struct libinput_config_accel *config_custom_changed =
|
|
|
|
|
libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_ptr_notnull(config_custom_default);
|
|
|
|
|
litest_assert_ptr_notnull(config_custom_changed);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
2023-01-27 01:23:35 +02:00
|
|
|
ARRAY_FOR_EACH(tests, t) {
|
2023-02-18 21:12:13 +02:00
|
|
|
ARRAY_FOR_EACH(accel_types, accel_type) {
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_config_accel_set_points(
|
|
|
|
|
config_custom_changed,
|
|
|
|
|
*accel_type,
|
|
|
|
|
t->step,
|
|
|
|
|
ARRAY_LENGTH(t->points),
|
|
|
|
|
t->points);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(status, t->expected_status);
|
2023-02-18 21:12:13 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_apply(
|
|
|
|
|
device,
|
|
|
|
|
config_custom_changed);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2023-02-18 21:12:13 +02:00
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_enum_eq(profile,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
2023-02-18 21:12:13 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_apply(
|
|
|
|
|
device,
|
|
|
|
|
config_custom_default);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2023-02-18 21:12:13 +02:00
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_enum_eq(profile,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
|
2023-02-18 21:12:13 +02:00
|
|
|
}
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libinput_config_accel_destroy(config_custom_default);
|
|
|
|
|
libinput_config_accel_destroy(config_custom_changed);
|
2015-08-27 13:13:47 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(pointer_accel_profile_invalid)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(libinput_device_config_accel_is_available(device));
|
2015-08-27 13:13:47 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_NONE);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE + 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE |
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM |
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2015-08-27 13:13:47 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-06 11:06:48 +10:00
|
|
|
START_TEST(pointer_accel_profile_noaccel)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
enum libinput_config_accel_profile profile;
|
|
|
|
|
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!libinput_device_config_accel_is_available(device));
|
2017-02-06 11:06:48 +10:00
|
|
|
|
|
|
|
|
profile = libinput_device_config_accel_get_default_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE);
|
2017-02-06 11:06:48 +10:00
|
|
|
|
|
|
|
|
profile = libinput_device_config_accel_get_profile(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE);
|
2017-02-06 11:06:48 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_NONE);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2017-02-06 11:06:48 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE + 1);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2017-02-06 11:06:48 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_accel_set_profile(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE |
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2017-02-06 11:06:48 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-08-27 13:13:47 +10:00
|
|
|
START_TEST(pointer_accel_profile_flat_motion_relative)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
|
|
|
|
|
libinput_device_config_accel_set_profile(device,
|
|
|
|
|
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
test_relative_event(dev, 1, 0);
|
|
|
|
|
test_relative_event(dev, 1, 1);
|
|
|
|
|
test_relative_event(dev, 1, -1);
|
|
|
|
|
test_relative_event(dev, 0, 1);
|
|
|
|
|
|
|
|
|
|
test_relative_event(dev, -1, 0);
|
|
|
|
|
test_relative_event(dev, -1, 1);
|
|
|
|
|
test_relative_event(dev, -1, -1);
|
|
|
|
|
test_relative_event(dev, 0, -1);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-04-14 14:43:53 +10:00
|
|
|
START_TEST(middlebutton)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
const int btn[][4] = {
|
|
|
|
|
{ BTN_LEFT, BTN_RIGHT, BTN_LEFT, BTN_RIGHT },
|
|
|
|
|
{ BTN_LEFT, BTN_RIGHT, BTN_RIGHT, BTN_LEFT },
|
|
|
|
|
{ BTN_RIGHT, BTN_LEFT, BTN_LEFT, BTN_RIGHT },
|
|
|
|
|
{ BTN_RIGHT, BTN_LEFT, BTN_RIGHT, BTN_LEFT },
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
2015-04-14 14:43:53 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(btn); i++) {
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][0], true);
|
|
|
|
|
litest_button_click_debounced(device, li, btn[i][1], true);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][2], false);
|
|
|
|
|
litest_button_click_debounced(device, li, btn[i][3], false);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2016-04-11 12:02:55 +10:00
|
|
|
START_TEST(middlebutton_nostart_while_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
const int btn[][4] = {
|
|
|
|
|
{ BTN_LEFT, BTN_RIGHT, BTN_LEFT, BTN_RIGHT },
|
|
|
|
|
{ BTN_LEFT, BTN_RIGHT, BTN_RIGHT, BTN_LEFT },
|
|
|
|
|
{ BTN_RIGHT, BTN_LEFT, BTN_LEFT, BTN_RIGHT },
|
|
|
|
|
{ BTN_RIGHT, BTN_LEFT, BTN_RIGHT, BTN_LEFT },
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(device->libinput_device, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2016-04-11 12:02:55 +10:00
|
|
|
|
|
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2016-04-11 12:02:55 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2016-04-11 12:02:55 +10:00
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, true);
|
2016-04-11 12:02:55 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(btn); i++) {
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][0], true);
|
2016-04-11 12:02:55 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
btn[i][0],
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][1], true);
|
2016-04-11 12:02:55 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
btn[i][1],
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][2], false);
|
2016-04-11 12:02:55 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
btn[i][2],
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][3], false);
|
2016-04-11 12:02:55 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
btn[i][3],
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, false);
|
2016-04-11 12:02:55 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-04-14 14:43:53 +10:00
|
|
|
START_TEST(middlebutton_timeout)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
unsigned int button;
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
2015-04-14 14:43:53 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
for (button = BTN_LEFT; button <= BTN_RIGHT; button++) {
|
|
|
|
|
litest_drain_events(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, true);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_empty_queue(li);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_middlebutton(li);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, false);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_doubleclick)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
const int btn[][4] = {
|
|
|
|
|
{ BTN_LEFT, BTN_RIGHT, BTN_LEFT, BTN_RIGHT },
|
|
|
|
|
{ BTN_LEFT, BTN_RIGHT, BTN_RIGHT, BTN_LEFT },
|
|
|
|
|
{ BTN_RIGHT, BTN_LEFT, BTN_LEFT, BTN_RIGHT },
|
|
|
|
|
{ BTN_RIGHT, BTN_LEFT, BTN_RIGHT, BTN_LEFT },
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
2015-04-14 14:43:53 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_LENGTH(btn); i++) {
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][0], true);
|
|
|
|
|
litest_button_click_debounced(device, li, btn[i][1], true);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][2], false);
|
|
|
|
|
litest_button_click_debounced(device, li, btn[i][2], true);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, btn[i][3], false);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_middleclick)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
unsigned int button;
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(device->libinput_device, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
/* one button down, then middle -> release buttons */
|
|
|
|
|
for (button = BTN_LEFT; button <= BTN_RIGHT; button++) {
|
|
|
|
|
/* release button before middle */
|
|
|
|
|
litest_drain_events(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, true);
|
|
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, true);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, false);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, false);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* release middle before button */
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, true);
|
|
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, true);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, false);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, false);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_middleclick_during)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *device = litest_current_device();
|
|
|
|
|
struct libinput *li = device->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
unsigned int button;
|
|
|
|
|
|
2015-04-28 16:40:29 +10:00
|
|
|
disable_button_scrolling(device);
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(device->libinput_device, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device->libinput_device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* trigger emulation, then real middle */
|
|
|
|
|
for (button = BTN_LEFT; button <= BTN_RIGHT; button++) {
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_LEFT, true);
|
|
|
|
|
litest_button_click_debounced(device, li, BTN_RIGHT, true);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, true);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* middle still down, release left/right */
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, false);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_empty_queue(li);
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, button, true);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* release both */
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_LEFT, false);
|
|
|
|
|
litest_button_click_debounced(device, li, BTN_RIGHT, false);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-14 08:44:47 +10:00
|
|
|
litest_button_click_debounced(device, li, BTN_MIDDLE, false);
|
2015-04-14 14:43:53 +10:00
|
|
|
litest_assert_button_event(li,
|
|
|
|
|
BTN_MIDDLE,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_default_enabled)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
int available;
|
2017-02-17 10:32:55 +10:00
|
|
|
enum libinput_config_middle_emulation_state state;
|
|
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(dev->libinput_device, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
available = libinput_device_config_middle_emulation_is_available(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(available);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2015-04-21 18:01:26 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_default_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(device, 3);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2015-04-14 14:43:53 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_default_clickpad)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_status status;
|
2015-04-21 18:01:26 +10:00
|
|
|
enum libinput_config_middle_emulation_state state;
|
2015-04-14 14:43:53 +10:00
|
|
|
int available;
|
|
|
|
|
|
|
|
|
|
available = libinput_device_config_middle_emulation_is_available(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(available);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2015-04-21 18:01:26 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_default_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(device, 3);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
|
2015-04-14 14:43:53 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_default_touchpad)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2015-04-21 18:01:26 +10:00
|
|
|
enum libinput_config_middle_emulation_state state;
|
2015-04-14 14:43:53 +10:00
|
|
|
int available;
|
2015-06-15 14:37:49 +10:00
|
|
|
const char *name = libinput_device_get_name(dev->libinput_device);
|
|
|
|
|
|
|
|
|
|
if (streq(name, "litest AlpsPS/2 ALPS GlidePoint") ||
|
|
|
|
|
streq(name, "litest AlpsPS/2 ALPS DualPoint TouchPad"))
|
2025-07-01 16:30:11 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
|
|
|
|
available = libinput_device_config_middle_emulation_is_available(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!available);
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2017-02-17 10:38:09 +10:00
|
|
|
if (libinput_device_pointer_has_button(device, BTN_MIDDLE))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2015-04-14 14:43:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_default_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2015-04-14 14:43:53 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-06-15 14:37:49 +10:00
|
|
|
START_TEST(middlebutton_default_alps)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_middle_emulation_state state;
|
|
|
|
|
int available;
|
|
|
|
|
|
|
|
|
|
available = libinput_device_config_middle_emulation_is_available(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(available);
|
2015-06-15 14:37:49 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_default_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2015-06-15 14:37:49 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-05-19 16:22:14 +10:00
|
|
|
START_TEST(middlebutton_default_disabled)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
enum libinput_config_middle_emulation_state state;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
int available;
|
|
|
|
|
|
|
|
|
|
available = libinput_device_config_middle_emulation_is_available(device);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert(!available);
|
2015-05-19 16:22:14 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
state = libinput_device_config_middle_emulation_get_default_enabled(device);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(state, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2024-09-16 16:49:38 +10:00
|
|
|
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
2015-05-19 16:22:14 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-02-20 13:09:57 +10:00
|
|
|
START_TEST(middlebutton_button_scrolling)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
struct libinput_event_pointer *pev;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2017-02-20 13:09:57 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-20 13:09:57 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
2017-02-20 13:09:57 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_button(device, BTN_LEFT);
|
|
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
/* middle emulation discards */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_middlebutton(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
/* scroll discards */
|
|
|
|
|
litest_assert_empty_queue(li);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_buttonscroll(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
do {
|
|
|
|
|
pev = litest_is_axis_event(ev,
|
2018-11-22 10:24:54 +10:00
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
2017-02-20 13:09:57 +10:00
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_double_gt(litest_event_pointer_get_value(
|
|
|
|
|
pev,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
|
|
|
|
|
0.0);
|
2017-02-20 13:09:57 +10:00
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
ev = libinput_get_event(li);
|
|
|
|
|
} while (ev);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
litest_assert_axis_end_sequence(li,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
/* no button release */
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(middlebutton_button_scrolling_middle)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2017-02-20 13:09:57 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-20 13:09:57 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
status = libinput_device_config_scroll_set_method(
|
|
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
2017-02-20 13:09:57 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
status = libinput_device_config_scroll_set_button(device, BTN_LEFT);
|
|
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* button scrolling should not stop middle emulation */
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-02-20 13:09:57 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-01-30 14:10:28 +10:00
|
|
|
START_TEST(middlebutton_device_remove_while_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
libinput_device_config_scroll_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2019-01-30 14:10:28 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2019-01-30 14:10:28 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-30 14:10:28 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_MIDDLE, LIBINPUT_BUTTON_STATE_PRESSED);
|
2019-01-30 14:10:28 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2019-01-31 09:02:58 +10:00
|
|
|
START_TEST(middlebutton_device_remove_while_one_is_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput_device *device = dev->libinput_device;
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
enum libinput_config_status status;
|
|
|
|
|
|
|
|
|
|
libinput_device_config_scroll_set_method(device,
|
|
|
|
|
LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
|
|
|
|
status = libinput_device_config_middle_emulation_set_enabled(
|
2025-07-01 16:30:11 +10:00
|
|
|
device,
|
|
|
|
|
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
2019-01-31 09:02:58 +10:00
|
|
|
if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2019-01-31 09:02:58 +10:00
|
|
|
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2019-01-31 09:02:58 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2015-07-27 17:51:52 +08:00
|
|
|
START_TEST(pointer_time_usec)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
struct libinput_event_pointer *ptrev;
|
|
|
|
|
struct libinput_event *event;
|
2016-04-08 15:51:26 +08:00
|
|
|
uint64_t time_usec;
|
2015-07-27 17:51:52 +08:00
|
|
|
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_REL, REL_X, 1);
|
|
|
|
|
litest_event(dev, EV_REL, REL_Y, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
litest_wait_for_event(li);
|
|
|
|
|
|
|
|
|
|
event = libinput_get_event(li);
|
|
|
|
|
ptrev = litest_is_motion_event(event);
|
|
|
|
|
|
2016-04-08 15:51:26 +08:00
|
|
|
time_usec = libinput_event_pointer_get_time_usec(ptrev);
|
2024-09-16 16:20:26 +10:00
|
|
|
litest_assert_int_eq(libinput_event_pointer_get_time(ptrev),
|
2025-07-01 16:30:11 +10:00
|
|
|
(uint32_t)(time_usec / 1000));
|
2015-07-27 17:51:52 +08:00
|
|
|
|
|
|
|
|
libinput_event_destroy(event);
|
|
|
|
|
litest_drain_events(dev->libinput);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
START_TEST(debounce_bounce)
|
2017-07-14 13:42:53 +10:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2025-02-06 20:14:57 +01:00
|
|
|
unsigned int button = litest_test_param_get_i32(test_env->params, "button");
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(dev->libinput_device, button))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
2017-11-13 09:33:50 +10:00
|
|
|
disable_button_scrolling(dev);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2021-05-19 10:13:06 +02:00
|
|
|
START_TEST(debounce_bounce_high_delay)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2025-02-06 20:14:57 +01:00
|
|
|
unsigned int button = litest_test_param_get_i32(test_env->params, "button");
|
2021-05-19 10:13:06 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(dev->libinput_device, button))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2021-05-19 10:13:06 +02:00
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
disable_button_scrolling(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Debouncing timeout is 25ms after a button down or up. Make sure we go
|
|
|
|
|
* over 25ms for the total bouncing duration, but stay under 25ms for
|
|
|
|
|
* each single event. */
|
|
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(15);
|
|
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(15);
|
|
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2021-05-19 10:13:06 +02:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(15);
|
|
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(15);
|
|
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
START_TEST(debounce_bounce_check_immediate)
|
2017-07-14 13:42:53 +10:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
2017-11-13 09:33:50 +10:00
|
|
|
disable_button_scrolling(dev);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
/* Press must be sent without delay */
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
/* held down & past timeout, we expect releases to be immediate */
|
|
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
/* Triggers the event sequence that initializes the spurious
|
|
|
|
|
* debouncing behavior */
|
|
|
|
|
static inline void
|
|
|
|
|
debounce_trigger_spurious(struct litest_device *dev, struct libinput *li)
|
|
|
|
|
{
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
|
|
|
|
/* gets filtered now */
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
START_TEST(debounce_spurious)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
2025-02-06 20:14:57 +01:00
|
|
|
unsigned int button = litest_test_param_get_i32(test_env->params, "button");
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
if (!libinput_device_pointer_has_button(dev->libinput_device, button))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-11-13 09:33:50 +10:00
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
disable_button_scrolling(dev);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
debounce_trigger_spurious(dev, li);
|
|
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
/* Not all devices can disable middle button emulation, time out on
|
|
|
|
|
* middle button here to make sure the initial button press event
|
|
|
|
|
* was flushed.
|
|
|
|
|
*/
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_middlebutton(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
/* bouncy bouncy bouncy */
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 1);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, button, 0);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
START_TEST(debounce_spurious_multibounce)
|
2017-07-14 13:42:53 +10:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
debounce_trigger_spurious(dev, li);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
/* Let's assume our button has ventricular fibrilation and sends a
|
|
|
|
|
* lot of clicks. Debouncing is now enabled, ventricular
|
|
|
|
|
* fibrillation should cause one button down for the first press and
|
|
|
|
|
* one release for the last release.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
/* Not all devices can disable middle button emulation, time out on
|
|
|
|
|
* middle button here to make sure the initial button press event
|
|
|
|
|
* was flushed.
|
|
|
|
|
*/
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_middlebutton(li);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2021-05-19 10:13:06 +02:00
|
|
|
START_TEST(debounce_spurious_trigger_high_delay)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
|
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
|
|
|
|
litest_disable_middleemu(dev);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
|
|
|
|
/* Spurious timeout is 12ms after a button down or up. Make sure we go
|
|
|
|
|
* over 12ms for the total bouncing duration, but stay under 12ms for
|
|
|
|
|
* each single event. */
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(5);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(5);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
msleep(5);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
2021-05-19 10:13:06 +02:00
|
|
|
|
|
|
|
|
/* gets filtered now */
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2021-05-19 10:13:06 +02:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2021-05-19 10:13:06 +02:00
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
START_TEST(debounce_spurious_dont_enable_on_otherbutton)
|
2017-07-14 13:42:53 +10:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
2017-11-13 09:33:50 +10:00
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2017-07-14 13:42:53 +10:00
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_disable_middleemu(dev);
|
2017-11-13 09:33:50 +10:00
|
|
|
disable_button_scrolling(dev);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
/* Don't trigger spurious debouncing on otherbutton events */
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
|
|
|
|
/* Expect release to be immediate */
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
START_TEST(debounce_spurious_cancel_debounce_otherbutton)
|
2017-07-14 13:42:53 +10:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
2017-11-13 09:33:50 +10:00
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2017-07-14 13:42:53 +10:00
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_disable_middleemu(dev);
|
2017-11-13 09:33:50 +10:00
|
|
|
disable_button_scrolling(dev);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
debounce_trigger_spurious(dev, li);
|
|
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
|
|
|
|
|
/* spurious debouncing is on but the release should get flushed by
|
|
|
|
|
* the other button */
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-11-13 09:33:50 +10:00
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
START_TEST(debounce_spurious_switch_to_otherbutton)
|
2017-07-14 13:42:53 +10:00
|
|
|
{
|
|
|
|
|
struct litest_device *dev = litest_current_device();
|
2017-11-13 09:33:50 +10:00
|
|
|
struct libinput_device *device = dev->libinput_device;
|
2017-07-14 13:42:53 +10:00
|
|
|
struct libinput *li = dev->libinput;
|
|
|
|
|
|
2017-11-13 09:33:50 +10:00
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
2024-10-12 10:31:42 +10:00
|
|
|
return LITEST_NOT_APPLICABLE;
|
2017-11-13 09:33:50 +10:00
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
litest_drain_events(li);
|
2017-11-13 09:33:50 +10:00
|
|
|
debounce_trigger_spurious(dev, li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2017-11-13 09:33:50 +10:00
|
|
|
/* release is now held back,
|
2017-07-14 13:42:53 +10:00
|
|
|
* other button should flush the release */
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
|
|
|
|
/* bouncing right button triggers debounce */
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_RIGHT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
2025-07-01 16:30:11 +10:00
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_PRESSED);
|
|
|
|
|
litest_assert_button_event(li, BTN_RIGHT, LIBINPUT_BUTTON_STATE_RELEASED);
|
2017-07-14 13:42:53 +10:00
|
|
|
|
|
|
|
|
litest_assert_empty_queue(li);
|
|
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-06-29 13:43:15 +10:00
|
|
|
START_TEST(debounce_remove_device_button_up)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2018-06-29 13:43:15 +10:00
|
|
|
|
|
|
|
|
dev = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 0);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-06-29 13:43:15 +10:00
|
|
|
|
|
|
|
|
/* delete the device while the timer is still active */
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2018-06-29 13:43:15 +10:00
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2018-06-29 13:43:15 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
|
|
START_TEST(debounce_remove_device_button_down)
|
|
|
|
|
{
|
|
|
|
|
struct litest_device *dev;
|
|
|
|
|
|
2025-04-07 13:15:28 +10:00
|
|
|
_litest_context_destroy_ struct libinput *li = litest_create_context();
|
2018-06-29 13:43:15 +10:00
|
|
|
|
|
|
|
|
dev = litest_add_device(li, LITEST_MOUSE);
|
|
|
|
|
litest_drain_events(li);
|
|
|
|
|
|
|
|
|
|
litest_event(dev, EV_KEY, BTN_LEFT, 1);
|
|
|
|
|
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
2024-09-13 15:13:38 +10:00
|
|
|
litest_dispatch(li);
|
2018-06-29 13:43:15 +10:00
|
|
|
|
|
|
|
|
/* delete the device the timer is still active */
|
2025-04-07 15:12:51 +10:00
|
|
|
litest_device_destroy(dev);
|
2018-06-29 13:43:15 +10:00
|
|
|
|
2025-04-01 09:23:10 +10:00
|
|
|
litest_timeout_debounce(li);
|
2018-06-29 13:43:15 +10:00
|
|
|
}
|
|
|
|
|
END_TEST
|
|
|
|
|
|
2018-03-21 12:54:10 +10:00
|
|
|
TEST_COLLECTION(pointer)
|
2015-05-01 11:41:12 +10:00
|
|
|
{
|
2025-07-01 11:30:59 +10:00
|
|
|
/* clang-format off */
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(pointer_motion_relative, LITEST_RELATIVE, LITEST_POINTINGSTICK);
|
|
|
|
|
litest_add_for_device(pointer_motion_relative_zero, LITEST_MOUSE);
|
2025-02-11 14:44:48 +10:00
|
|
|
litest_with_parameters(params,
|
2025-02-13 22:10:02 +01:00
|
|
|
"direction", 'I', 8, litest_named_i32(N), litest_named_i32(NE),
|
|
|
|
|
litest_named_i32(E), litest_named_i32(SE),
|
|
|
|
|
litest_named_i32(S), litest_named_i32(SW),
|
|
|
|
|
litest_named_i32(W), litest_named_i32(NW)) {
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
litest_add_parametrized(pointer_motion_relative_min_decel, LITEST_RELATIVE, LITEST_POINTINGSTICK, params);
|
|
|
|
|
}
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(pointer_motion_absolute, LITEST_ABSOLUTE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_motion_unaccel, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_button, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add_no_device(pointer_button_auto_release);
|
|
|
|
|
litest_add_no_device(pointer_seat_button_count);
|
|
|
|
|
litest_add_for_device(pointer_button_has_no_button, LITEST_KEYBOARD);
|
|
|
|
|
litest_add(pointer_recover_from_lost_button_count, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(pointer_scroll_wheel, LITEST_WHEEL, LITEST_TABLET);
|
2025-07-03 13:50:17 +10:00
|
|
|
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(REL_WHEEL_HI_RES, "vertical"),
|
|
|
|
|
litest_named_i32(REL_HWHEEL_HI_RES, "horizontal")) {
|
|
|
|
|
litest_add_parametrized(pointer_scroll_wheel_hires, LITEST_WHEEL, LITEST_TABLET, params);
|
|
|
|
|
}
|
2025-02-13 22:10:02 +01:00
|
|
|
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, "vertical"),
|
|
|
|
|
litest_named_i32(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, "horizontal")) {
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
litest_add_parametrized(pointer_scroll_wheel_hires_send_only_lores, LITEST_WHEEL, LITEST_TABLET, params);
|
2025-07-21 14:00:14 +10:00
|
|
|
litest_add_parametrized_for_device(pointer_scroll_wheel_hires_disabled, LITEST_MOUSE_WHEEL_HIRES_DISABLED, params);
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
}
|
2025-07-03 12:01:32 +10:00
|
|
|
litest_with_parameters(params, "hires-delta", 'u', 3, 5, 15, 20) {
|
|
|
|
|
litest_add_parametrized(pointer_scroll_wheel_inhibit_small_deltas, LITEST_WHEEL, LITEST_TABLET, params);
|
|
|
|
|
litest_add_parametrized(pointer_scroll_wheel_inhibit_dir_change, LITEST_WHEEL, LITEST_TABLET, params);
|
|
|
|
|
}
|
|
|
|
|
litest_add(pointer_scroll_wheel_inhibit_small_deltas_reduce_delta, LITEST_WHEEL, LITEST_TABLET);
|
2025-06-08 01:29:33 -04:00
|
|
|
litest_add_for_device(pointer_scroll_wheel_no_inhibit_small_deltas_when_virtual, LITEST_MOUSE_VIRTUAL);
|
2022-06-06 20:24:16 +02:00
|
|
|
litest_add_for_device(pointer_scroll_wheel_lenovo_scrollpoint, LITEST_LENOVO_SCROLLPOINT);
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(pointer_scroll_button, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_noscroll, LITEST_ABSOLUTE|LITEST_BUTTON, LITEST_RELATIVE);
|
|
|
|
|
litest_add(pointer_scroll_button_noscroll, LITEST_ANY, LITEST_RELATIVE|LITEST_BUTTON);
|
|
|
|
|
litest_add(pointer_scroll_button_no_event_before_timeout, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_middle_emulation, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
2023-03-29 10:59:45 +10:00
|
|
|
litest_add_no_device(pointer_scroll_button_device_remove_while_down);
|
2021-02-05 14:51:02 +10:00
|
|
|
|
|
|
|
|
litest_add(pointer_scroll_button_lock, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_lock_defaults, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_lock_config, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_lock_enable_while_down, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_lock_enable_while_down_just_lock, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_lock_otherbutton, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_scroll_button_lock_enable_while_otherbutton_down, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
2025-02-06 20:14:57 +01:00
|
|
|
litest_with_parameters(params, "buttonorder", 'I', 6, litest_named_i32(LLRR),
|
|
|
|
|
litest_named_i32(LRLR),
|
|
|
|
|
litest_named_i32(LRRL),
|
|
|
|
|
litest_named_i32(RRLL),
|
|
|
|
|
litest_named_i32(RLRL),
|
|
|
|
|
litest_named_i32(RLLR)) {
|
|
|
|
|
litest_add_parametrized(pointer_scroll_button_lock_middlebutton, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY, params);
|
|
|
|
|
}
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(pointer_scroll_button_lock_doubleclick_nomove, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
|
|
|
|
|
litest_add(pointer_scroll_nowheel_defaults, LITEST_RELATIVE|LITEST_BUTTON, LITEST_WHEEL);
|
|
|
|
|
litest_add_for_device(pointer_scroll_defaults_logitech_marble , LITEST_LOGITECH_TRACKBALL);
|
|
|
|
|
litest_add(pointer_scroll_natural_defaults, LITEST_WHEEL, LITEST_TABLET);
|
|
|
|
|
litest_add(pointer_scroll_natural_defaults_noscroll, LITEST_ANY, LITEST_WHEEL);
|
|
|
|
|
litest_add(pointer_scroll_natural_enable_config, LITEST_WHEEL, LITEST_TABLET);
|
|
|
|
|
litest_add(pointer_scroll_natural_wheel, LITEST_WHEEL, LITEST_TABLET);
|
|
|
|
|
litest_add(pointer_scroll_has_axis_invalid, LITEST_WHEEL, LITEST_TABLET);
|
2025-02-06 20:14:57 +01:00
|
|
|
litest_with_parameters(params, "angle", 'd', 18, 0.0, 20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0,
|
|
|
|
|
180.0, 200.0, 220.0, 240.0, 260.0, 280.0, 300.0, 320.0, 340.0) {
|
|
|
|
|
litest_add_parametrized(pointer_scroll_with_rotation, LITEST_WHEEL, LITEST_TABLET, params);
|
|
|
|
|
}
|
2021-02-05 14:51:02 +10:00
|
|
|
|
|
|
|
|
litest_add(pointer_no_calibration, LITEST_ANY, LITEST_TOUCH|LITEST_SINGLE_TOUCH|LITEST_ABSOLUTE|LITEST_PROTOCOL_A|LITEST_TABLET);
|
2014-08-26 11:41:19 +10:00
|
|
|
|
2014-09-23 12:46:02 +10:00
|
|
|
/* tests touchpads too */
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(pointer_left_handed_defaults, LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_left_handed, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_left_handed_during_click, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_left_handed_during_click_multiple_buttons, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
|
2023-03-29 10:56:41 +10:00
|
|
|
litest_add_no_device(pointer_left_handed_disable_with_button_down);
|
2021-02-05 14:51:02 +10:00
|
|
|
|
|
|
|
|
litest_add(pointer_accel_defaults, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_accel_invalid, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_accel_defaults_absolute, LITEST_ABSOLUTE, LITEST_RELATIVE);
|
|
|
|
|
litest_add(pointer_accel_defaults_absolute_relative, LITEST_ABSOLUTE|LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_accel_direction_change, LITEST_RELATIVE, LITEST_POINTINGSTICK);
|
|
|
|
|
litest_add(pointer_accel_profile_defaults, LITEST_RELATIVE, LITEST_TOUCHPAD);
|
|
|
|
|
litest_add(pointer_accel_profile_defaults, LITEST_TOUCHPAD, LITEST_ANY);
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
litest_add(pointer_accel_config_reset_to_defaults, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_accel_config, LITEST_RELATIVE, LITEST_ANY);
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(pointer_accel_profile_invalid, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
litest_add(pointer_accel_profile_noaccel, LITEST_ANY, LITEST_TOUCHPAD|LITEST_RELATIVE|LITEST_TABLET);
|
|
|
|
|
litest_add(pointer_accel_profile_flat_motion_relative, LITEST_RELATIVE, LITEST_TOUCHPAD);
|
|
|
|
|
|
|
|
|
|
litest_add(middlebutton, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_nostart_while_down, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_timeout, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_doubleclick, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_middleclick, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_middleclick_during, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_default_enabled, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_POINTINGSTICK);
|
|
|
|
|
litest_add(middlebutton_default_clickpad, LITEST_CLICKPAD, LITEST_ANY);
|
|
|
|
|
litest_add(middlebutton_default_touchpad, LITEST_TOUCHPAD, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_default_disabled, LITEST_ANY, LITEST_BUTTON);
|
|
|
|
|
litest_add_for_device(middlebutton_default_alps, LITEST_ALPS_SEMI_MT);
|
|
|
|
|
litest_add(middlebutton_button_scrolling, LITEST_RELATIVE|LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_button_scrolling_middle, LITEST_RELATIVE|LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_device_remove_while_down, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
litest_add(middlebutton_device_remove_while_one_is_down, LITEST_BUTTON, LITEST_CLICKPAD);
|
|
|
|
|
|
2025-02-13 22:10:02 +01:00
|
|
|
litest_with_parameters(params, "axis", 'I', 2, litest_named_i32(ABS_X), litest_named_i32(ABS_Y)) {
|
test: implement support for parametrizing tests
litest supports ranged tests but they are not enough, doubly so with
tests where we want to parametrize across multiple options.
This patch adds support for just that, in clunky C style.
The typical invocation for a test is by giving the test parameter
a name, a number of values and then the values themselves:
struct litest_parameters *params = litest_parameters_new("axis", 's', 2, "ABS_X", "ABS_Y",
"enabled", 'b', '2', true, false,
"number", 'u', '2', 10, 11,
NULL);
litest_add_parametrized(sometest, LITEST_ANY, LITEST_ANY, params);
litest_parameters_unref(params);
Currently supported are u (uint32), i (int32), d (double), b (bool),
c (char) and s (string).
In the test itself, the `test_env->params` variable is available and
retrieval of the parameters works like this:
const char *axis;
uint32_t number;
bool enabled;
litest_test_param_fetch(test_env->params,
"axis", &axis,
"enabled", &enabled,
"number", &number,
NULL);
Note that since this is an effectively internal test-suite only
functionality we don't do type-checking here, it's assumed that if you
write the code to pass parameters into a test you remember the type
of said params when you write the test code.
Because we don't have hashmaps or anything useful other than lists the
implementation is a bit clunky: we copy the parameter into the test
during litest_add_*, permutate it for our test list which gives us yet
another linked list C struct, and finally copy the actual value into
the test and test environment as it's executed. Not pretty, but it
works.
A few tests are switched as simple demonstration. The name of the
test has the parameters with their names and values appended now, e.g.:
"pointer:pointer_scroll_wheel_hires_send_only_lores:ms-surface-cover:axis:ABS_X"
"pointer:pointer_motion_relative_min_decel:mouse-roccat:direction:NW"
Filtering by parameters can be done via globs of their string
representation:
libinput-test-suite --filter-params="axis:ABS_*,enabled:true,number:10*"
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1109>
2024-12-22 00:06:19 +10:00
|
|
|
litest_add_parametrized(pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, params);
|
|
|
|
|
}
|
2021-02-05 14:51:02 +10:00
|
|
|
|
|
|
|
|
litest_add(pointer_time_usec, LITEST_RELATIVE, LITEST_ANY);
|
|
|
|
|
|
2025-02-06 20:14:57 +01:00
|
|
|
litest_with_parameters(params, "button", 'I', 8, litest_named_i32(BTN_LEFT),
|
|
|
|
|
litest_named_i32(BTN_RIGHT),
|
|
|
|
|
litest_named_i32(BTN_MIDDLE),
|
|
|
|
|
litest_named_i32(BTN_SIDE),
|
|
|
|
|
litest_named_i32(BTN_EXTRA),
|
|
|
|
|
litest_named_i32(BTN_FORWARD),
|
|
|
|
|
litest_named_i32(BTN_BACK),
|
|
|
|
|
litest_named_i32(BTN_TASK)) {
|
|
|
|
|
litest_add_parametrized(debounce_bounce, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE, params);
|
|
|
|
|
litest_add_parametrized(debounce_spurious, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE, params);
|
|
|
|
|
/* Timing-sensitive test, valgrind is too slow */
|
|
|
|
|
if (!RUNNING_ON_VALGRIND)
|
|
|
|
|
litest_add_parametrized(debounce_bounce_high_delay, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE, params);
|
|
|
|
|
}
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(debounce_bounce_check_immediate, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
|
|
|
|
|
litest_add(debounce_spurious_multibounce, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
|
2022-06-28 13:02:22 +02:00
|
|
|
if (!RUNNING_ON_VALGRIND)
|
|
|
|
|
litest_add(debounce_spurious_trigger_high_delay, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
|
2021-02-05 14:51:02 +10:00
|
|
|
litest_add(debounce_spurious_dont_enable_on_otherbutton, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
|
|
|
|
|
litest_add(debounce_spurious_cancel_debounce_otherbutton, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
|
|
|
|
|
litest_add(debounce_spurious_switch_to_otherbutton, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
|
|
|
|
|
litest_add_no_device(debounce_remove_device_button_down);
|
|
|
|
|
litest_add_no_device(debounce_remove_device_button_up);
|
2025-07-01 11:30:59 +10:00
|
|
|
/* clang-format off */
|
2014-01-21 14:17:01 +10:00
|
|
|
}
|