mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 05:28:01 +02:00
test: Add a basic mouse test device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4ec24b2037
commit
404a0ea14e
4 changed files with 80 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ liblitest_la_SOURCES = \
|
||||||
litest-int.h \
|
litest-int.h \
|
||||||
litest-bcm5974.c \
|
litest-bcm5974.c \
|
||||||
litest-keyboard.c \
|
litest-keyboard.c \
|
||||||
|
litest-mouse.c \
|
||||||
litest-synaptics.c \
|
litest-synaptics.c \
|
||||||
litest-trackpoint.c \
|
litest-trackpoint.c \
|
||||||
litest.c
|
litest.c
|
||||||
|
|
|
||||||
75
test/litest-mouse.c
Normal file
75
test/litest-mouse.c
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2013 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that copyright
|
||||||
|
* notice and this permission notice appear in supporting documentation, and
|
||||||
|
* that the name of the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "litest.h"
|
||||||
|
#include "litest-int.h"
|
||||||
|
#include "libinput-util.h"
|
||||||
|
|
||||||
|
static void litest_mouse_setup(void)
|
||||||
|
{
|
||||||
|
struct litest_device *d = litest_create_device(LITEST_MOUSE);
|
||||||
|
litest_set_current_device(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct litest_device_interface interface = {
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
litest_create_mouse(struct litest_device *d)
|
||||||
|
{
|
||||||
|
struct libevdev *dev;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
d->interface = &interface;
|
||||||
|
dev = libevdev_new();
|
||||||
|
ck_assert(dev != NULL);
|
||||||
|
|
||||||
|
libevdev_set_name(dev, "Lenovo Optical USB Mouse");
|
||||||
|
libevdev_set_id_bustype(dev, 0x3);
|
||||||
|
libevdev_set_id_vendor(dev, 0x17ef);
|
||||||
|
libevdev_set_id_product(dev, 0x6019);
|
||||||
|
libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
|
||||||
|
libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT, NULL);
|
||||||
|
libevdev_enable_event_code(dev, EV_KEY, BTN_MIDDLE, NULL);
|
||||||
|
libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
|
||||||
|
libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);
|
||||||
|
libevdev_enable_event_code(dev, EV_REL, REL_WHEEL, NULL);
|
||||||
|
|
||||||
|
rc = libevdev_uinput_create_from_device(dev,
|
||||||
|
LIBEVDEV_UINPUT_OPEN_MANAGED,
|
||||||
|
&d->uinput);
|
||||||
|
ck_assert_int_eq(rc, 0);
|
||||||
|
libevdev_free(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct litest_test_device litest_mouse_device = {
|
||||||
|
.type = LITEST_MOUSE,
|
||||||
|
.features = LITEST_POINTER | LITEST_BUTTON | LITEST_WHEEL,
|
||||||
|
.shortname = "mouse",
|
||||||
|
.setup = litest_mouse_setup,
|
||||||
|
.teardown = litest_generic_device_teardown,
|
||||||
|
.create = litest_create_mouse,
|
||||||
|
};
|
||||||
|
|
@ -79,12 +79,14 @@ extern struct litest_test_device litest_keyboard_device;
|
||||||
extern struct litest_test_device litest_synaptics_clickpad_device;
|
extern struct litest_test_device litest_synaptics_clickpad_device;
|
||||||
extern struct litest_test_device litest_trackpoint_device;
|
extern struct litest_test_device litest_trackpoint_device;
|
||||||
extern struct litest_test_device litest_bcm5974_device;
|
extern struct litest_test_device litest_bcm5974_device;
|
||||||
|
extern struct litest_test_device litest_mouse_device;
|
||||||
|
|
||||||
struct litest_test_device* devices[] = {
|
struct litest_test_device* devices[] = {
|
||||||
&litest_synaptics_clickpad_device,
|
&litest_synaptics_clickpad_device,
|
||||||
&litest_keyboard_device,
|
&litest_keyboard_device,
|
||||||
&litest_trackpoint_device,
|
&litest_trackpoint_device,
|
||||||
&litest_bcm5974_device,
|
&litest_bcm5974_device,
|
||||||
|
&litest_mouse_device,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ enum litest_device_type {
|
||||||
LITEST_BCM5974,
|
LITEST_BCM5974,
|
||||||
LITEST_KEYBOARD,
|
LITEST_KEYBOARD,
|
||||||
LITEST_TRACKPOINT,
|
LITEST_TRACKPOINT,
|
||||||
|
LITEST_MOUSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum litest_device_feature {
|
enum litest_device_feature {
|
||||||
|
|
@ -49,6 +50,7 @@ enum litest_device_feature {
|
||||||
LITEST_BUTTON = 1 << 2,
|
LITEST_BUTTON = 1 << 2,
|
||||||
LITEST_KEYS = 1 << 3,
|
LITEST_KEYS = 1 << 3,
|
||||||
LITEST_POINTER = 1 << 4,
|
LITEST_POINTER = 1 << 4,
|
||||||
|
LITEST_WHEEL = 1 << 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct litest_device {
|
struct litest_device {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue