Commit c5c503c9 authored by Peter Hutterer's avatar Peter Hutterer

test: switch the remaining devices to a description-based device

Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
parent a9a24c33
......@@ -34,102 +34,76 @@ static void litest_bcm5974_setup(void)
litest_set_current_device(d);
}
static void
litest_bcm5974_touch_down(struct litest_device *d,
unsigned int slot,
int x, int y)
{
static int tracking_id;
struct input_event *ev;
struct input_event down[] = {
{ .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_ABS, .code = ABS_X, .value = x },
{ .type = EV_ABS, .code = ABS_Y, .value = y },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = 30 },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = ++tracking_id },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = x },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = y },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
down[2].value = litest_scale(d, ABS_X, x);
down[3].value = litest_scale(d, ABS_Y, y);
down[7].value = litest_scale(d, ABS_X, x);
down[8].value = litest_scale(d, ABS_Y, y);
ARRAY_FOR_EACH(down, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
void
litest_bcm5974_move(struct litest_device *d, unsigned int slot, int x, int y)
{
struct input_event *ev;
struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot },
{ .type = EV_ABS, .code = ABS_X, .value = x },
{ .type = EV_ABS, .code = ABS_Y, .value = y },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = x },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = y },
{ .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
move[1].value = litest_scale(d, ABS_X, x);
move[2].value = litest_scale(d, ABS_Y, y);
move[3].value = litest_scale(d, ABS_X, x);
move[4].value = litest_scale(d, ABS_Y, y);
struct input_event down[] = {
{ .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = 30 },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
ARRAY_FOR_EACH(move, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct litest_device_interface interface = {
.touch_down = litest_bcm5974_touch_down,
.touch_move = litest_bcm5974_move,
.touch_down_events = down,
.touch_move_events = move,
};
void
litest_create_bcm5974(struct litest_device *d)
{
struct input_absinfo abs[] = {
{ ABS_X, 1472, 5472, 75 },
{ ABS_Y, 1408, 4448, 129 },
{ ABS_PRESSURE, 0, 255, 0 },
{ ABS_TOOL_WIDTH, 0, 15, 0 },
{ ABS_MT_SLOT, 0, 1, 0 },
{ ABS_MT_POSITION_X, 1472, 5472, 75 },
{ ABS_MT_POSITION_Y, 1408, 4448, 129 },
{ ABS_MT_TRACKING_ID, 0, 65535, 0 },
{ ABS_MT_PRESSURE, 0, 255, 0 },
{ .value = -1 },
};
struct input_id id = {
.bustype = 0x3,
.vendor = 0x5ac,
.product = 0x249,
};
static struct input_absinfo absinfo[] = {
{ ABS_X, 1472, 5472, 75 },
{ ABS_Y, 1408, 4448, 129 },
{ ABS_PRESSURE, 0, 255, 0 },
{ ABS_TOOL_WIDTH, 0, 15, 0 },
{ ABS_MT_SLOT, 0, 1, 0 },
{ ABS_MT_POSITION_X, 1472, 5472, 75 },
{ ABS_MT_POSITION_Y, 1408, 4448, 129 },
{ ABS_MT_TRACKING_ID, 0, 65535, 0 },
{ ABS_MT_PRESSURE, 0, 255, 0 },
{ .value = -1 },
};
d->interface = &interface;
d->uinput = litest_create_uinput_abs_device("bcm5974", &id,
abs,
EV_KEY, BTN_LEFT,
EV_KEY, BTN_TOOL_FINGER,
EV_KEY, BTN_TOOL_QUINTTAP,
EV_KEY, BTN_TOUCH,
EV_KEY, BTN_TOOL_DOUBLETAP,
EV_KEY, BTN_TOOL_TRIPLETAP,
EV_KEY, BTN_TOOL_QUADTAP,
-1, -1);
}
static struct input_id input_id = {
.bustype = 0x3,
.vendor = 0x5ac,
.product = 0x249,
};
static int events[] = {
EV_KEY, BTN_LEFT,
EV_KEY, BTN_TOOL_FINGER,
EV_KEY, BTN_TOOL_QUINTTAP,
EV_KEY, BTN_TOUCH,
EV_KEY, BTN_TOOL_DOUBLETAP,
EV_KEY, BTN_TOOL_TRIPLETAP,
EV_KEY, BTN_TOOL_QUADTAP,
-1, -1
};
struct litest_test_device litest_bcm5974_device = {
.type = LITEST_BCM5974,
.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
.shortname = "bcm5974",
.setup = litest_bcm5974_setup,
.create = litest_create_bcm5974,
.interface = &interface,
.name = "bcm5974",
.id = &input_id,
.events = events,
.absinfo = absinfo,
};
......@@ -34,94 +34,65 @@ void litest_generic_highres_touch_setup(void)
litest_set_current_device(d);
}
void
litest_generic_highres_touch_touch_down(struct litest_device *d,
unsigned int slot,
int x, int y)
{
static int tracking_id;
struct input_event *ev;
struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = x },
{ .type = EV_ABS, .code = ABS_Y, .value = y },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = ++tracking_id },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = x },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = y },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
down[0].value = litest_scale(d, ABS_X, x);
down[1].value = litest_scale(d, ABS_Y, y);
down[4].value = litest_scale(d, ABS_X, x);
down[5].value = litest_scale(d, ABS_Y, y);
ARRAY_FOR_EACH(down, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
void
litest_generic_highres_touch_move(struct litest_device *d,
unsigned int slot,
int x, int y)
{
struct input_event *ev;
struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = slot },
{ .type = EV_ABS, .code = ABS_X, .value = x },
{ .type = EV_ABS, .code = ABS_Y, .value = y },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = x },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = y },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
move[1].value = litest_scale(d, ABS_X, x);
move[2].value = litest_scale(d, ABS_Y, y);
move[3].value = litest_scale(d, ABS_X, x);
move[4].value = litest_scale(d, ABS_Y, y);
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
ARRAY_FOR_EACH(move, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct litest_device_interface interface = {
.touch_down = litest_generic_highres_touch_touch_down,
.touch_move = litest_generic_highres_touch_move,
.touch_down_events = down,
.touch_move_events = move,
};
void
litest_create_generic_highres_touch(struct litest_device *d)
{
struct input_absinfo abs[] = {
{ ABS_X, 0, 32767, 75 },
{ ABS_Y, 0, 32767, 129 },
{ ABS_MT_SLOT, 0, 1, 0 },
{ ABS_MT_POSITION_X, 0, 32767, 0, 0, 10 },
{ ABS_MT_POSITION_Y, 0, 32767, 0, 0, 9 },
{ ABS_MT_TRACKING_ID, 0, 65535, 0 },
{ .value = -1 },
};
struct input_id id = {
.bustype = 0x3,
.vendor = 0xabcd, /* Some random vendor. */
.product = 0x1234, /* Some random product id. */
};
static struct input_absinfo absinfo[] = {
{ ABS_X, 0, 32767, 75 },
{ ABS_Y, 0, 32767, 129 },
{ ABS_MT_SLOT, 0, 1, 0 },
{ ABS_MT_POSITION_X, 0, 32767, 0, 0, 10 },
{ ABS_MT_POSITION_Y, 0, 32767, 0, 0, 9 },
{ ABS_MT_TRACKING_ID, 0, 65535, 0 },
{ .value = -1 },
};
d->interface = &interface;
d->uinput = litest_create_uinput_abs_device("Generic emulated highres touch device",
&id,
abs,
EV_KEY, BTN_TOUCH,
INPUT_PROP_MAX, INPUT_PROP_DIRECT,
-1, -1);
}
static struct input_id input_id = {
.bustype = 0x3,
.vendor = 0xabcd, /* Some random vendor. */
.product = 0x1234, /* Some random product id. */
};
static int events[] = {
EV_KEY, BTN_TOUCH,
INPUT_PROP_MAX, INPUT_PROP_DIRECT,
-1, -1,
};
struct litest_test_device litest_generic_highres_touch_device = {
.type = LITEST_GENERIC_HIGHRES_TOUCH,
.features = LITEST_TOUCH,
.shortname = "generic-highres-touch",
.setup = litest_generic_highres_touch_setup,
.create = litest_create_generic_highres_touch,
.interface = &interface,
.name = "Generic emulated highres touch device",
.id = &input_id,
.events = events,
.absinfo = absinfo,
};
......@@ -34,80 +34,178 @@ static void litest_keyboard_setup(void)
litest_set_current_device(d);
}
static struct litest_device_interface interface = {
static struct input_id input_id = {
.bustype = 0x11,
.vendor = 0x1,
.product = 0x1,
};
static void
litest_create_keyboard(struct litest_device *d)
{
struct libevdev *dev;
int rc;
const int keys[] = {
KEY_MENU,
KEY_CALC,
KEY_SETUP,
KEY_SLEEP,
KEY_WAKEUP,
KEY_SCREENLOCK,
KEY_DIRECTION,
KEY_CYCLEWINDOWS,
KEY_MAIL,
KEY_BOOKMARKS,
KEY_COMPUTER,
KEY_BACK,
KEY_FORWARD,
KEY_NEXTSONG,
KEY_PLAYPAUSE,
KEY_PREVIOUSSONG,
KEY_STOPCD,
KEY_HOMEPAGE,
KEY_REFRESH,
KEY_F14,
KEY_F15,
KEY_SEARCH,
KEY_MEDIA,
KEY_FN,
};
int k;
const int *key;
int delay = 500, period = 30;
d->interface = &interface;
dev = libevdev_new();
ck_assert(dev != NULL);
libevdev_set_name(dev, "AT Translated Set 2 keyboard");
libevdev_set_id_bustype(dev, 0x11);
libevdev_set_id_vendor(dev, 0x1);
libevdev_set_id_product(dev, 0x1);
for (k = KEY_ESC; k <= KEY_STOP; k++) {
if (k == KEY_SCALE)
continue;
libevdev_enable_event_code(dev, EV_KEY, k, NULL);
}
static int events[] = {
EV_KEY, KEY_ESC,
EV_KEY, KEY_1,
EV_KEY, KEY_2,
EV_KEY, KEY_3,
EV_KEY, KEY_4,
EV_KEY, KEY_5,
EV_KEY, KEY_6,
EV_KEY, KEY_7,
EV_KEY, KEY_8,
EV_KEY, KEY_9,
EV_KEY, KEY_0,
EV_KEY, KEY_MINUS,
EV_KEY, KEY_EQUAL,
EV_KEY, KEY_BACKSPACE,
EV_KEY, KEY_TAB,
EV_KEY, KEY_Q,
EV_KEY, KEY_W,
EV_KEY, KEY_E,
EV_KEY, KEY_R,
EV_KEY, KEY_T,
EV_KEY, KEY_Y,
EV_KEY, KEY_U,
EV_KEY, KEY_I,
EV_KEY, KEY_O,
EV_KEY, KEY_P,
EV_KEY, KEY_LEFTBRACE,
EV_KEY, KEY_RIGHTBRACE,
EV_KEY, KEY_ENTER,
EV_KEY, KEY_LEFTCTRL,
EV_KEY, KEY_A,
EV_KEY, KEY_S,
EV_KEY, KEY_D,
EV_KEY, KEY_F,
EV_KEY, KEY_G,
EV_KEY, KEY_H,
EV_KEY, KEY_J,
EV_KEY, KEY_K,
EV_KEY, KEY_L,
EV_KEY, KEY_SEMICOLON,
EV_KEY, KEY_APOSTROPHE,
EV_KEY, KEY_GRAVE,
EV_KEY, KEY_LEFTSHIFT,
EV_KEY, KEY_BACKSLASH,
EV_KEY, KEY_Z,
EV_KEY, KEY_X,
EV_KEY, KEY_C,
EV_KEY, KEY_V,
EV_KEY, KEY_B,
EV_KEY, KEY_N,
EV_KEY, KEY_M,
EV_KEY, KEY_COMMA,
EV_KEY, KEY_DOT,
EV_KEY, KEY_SLASH,
EV_KEY, KEY_RIGHTSHIFT,
EV_KEY, KEY_KPASTERISK,
EV_KEY, KEY_LEFTALT,
EV_KEY, KEY_SPACE,
EV_KEY, KEY_CAPSLOCK,
EV_KEY, KEY_F1,
EV_KEY, KEY_F2,
EV_KEY, KEY_F3,
EV_KEY, KEY_F4,
EV_KEY, KEY_F5,
EV_KEY, KEY_F6,
EV_KEY, KEY_F7,
EV_KEY, KEY_F8,
EV_KEY, KEY_F9,
EV_KEY, KEY_F10,
EV_KEY, KEY_NUMLOCK,
EV_KEY, KEY_SCROLLLOCK,
EV_KEY, KEY_KP7,
EV_KEY, KEY_KP8,
EV_KEY, KEY_KP9,
EV_KEY, KEY_KPMINUS,
EV_KEY, KEY_KP4,
EV_KEY, KEY_KP5,
EV_KEY, KEY_KP6,
EV_KEY, KEY_KPPLUS,
EV_KEY, KEY_KP1,
EV_KEY, KEY_KP2,
EV_KEY, KEY_KP3,
EV_KEY, KEY_KP0,
EV_KEY, KEY_KPDOT,
EV_KEY, KEY_ZENKAKUHANKAKU,
EV_KEY, KEY_102ND,
EV_KEY, KEY_F11,
EV_KEY, KEY_F12,
EV_KEY, KEY_RO,
EV_KEY, KEY_KATAKANA,
EV_KEY, KEY_HIRAGANA,
EV_KEY, KEY_HENKAN,
EV_KEY, KEY_KATAKANAHIRAGANA,
EV_KEY, KEY_MUHENKAN,
EV_KEY, KEY_KPJPCOMMA,
EV_KEY, KEY_KPENTER,
EV_KEY, KEY_RIGHTCTRL,
EV_KEY, KEY_KPSLASH,
EV_KEY, KEY_SYSRQ,
EV_KEY, KEY_RIGHTALT,
EV_KEY, KEY_LINEFEED,
EV_KEY, KEY_HOME,
EV_KEY, KEY_UP,
EV_KEY, KEY_PAGEUP,
EV_KEY, KEY_LEFT,
EV_KEY, KEY_RIGHT,
EV_KEY, KEY_END,
EV_KEY, KEY_DOWN,
EV_KEY, KEY_PAGEDOWN,
EV_KEY, KEY_INSERT,
EV_KEY, KEY_DELETE,
EV_KEY, KEY_MACRO,
EV_KEY, KEY_MUTE,
EV_KEY, KEY_VOLUMEDOWN,
EV_KEY, KEY_VOLUMEUP,
EV_KEY, KEY_POWER,
EV_KEY, KEY_KPEQUAL,
EV_KEY, KEY_KPPLUSMINUS,
EV_KEY, KEY_PAUSE,
/* EV_KEY, KEY_SCALE, */
EV_KEY, KEY_KPCOMMA,
EV_KEY, KEY_HANGEUL,
EV_KEY, KEY_HANJA,
EV_KEY, KEY_YEN,
EV_KEY, KEY_LEFTMETA,
EV_KEY, KEY_RIGHTMETA,
EV_KEY, KEY_COMPOSE,
EV_KEY, KEY_STOP,
ARRAY_FOR_EACH(keys, key)
libevdev_enable_event_code(dev, EV_KEY, *key, NULL);
libevdev_enable_event_code(dev, EV_LED, LED_NUML, NULL);
libevdev_enable_event_code(dev, EV_LED, LED_CAPSL, NULL);
libevdev_enable_event_code(dev, EV_LED, LED_SCROLLL, NULL);
libevdev_enable_event_code(dev, EV_MSC, MSC_SCAN, NULL);
libevdev_enable_event_code(dev, EV_REP, REP_PERIOD, &period);
libevdev_enable_event_code(dev, EV_REP, REP_DELAY, &delay);
EV_KEY, KEY_MENU,
EV_KEY, KEY_CALC,
EV_KEY, KEY_SETUP,
EV_KEY, KEY_SLEEP,
EV_KEY, KEY_WAKEUP,
EV_KEY, KEY_SCREENLOCK,
EV_KEY, KEY_DIRECTION,
EV_KEY, KEY_CYCLEWINDOWS,
EV_KEY, KEY_MAIL,
EV_KEY, KEY_BOOKMARKS,
EV_KEY, KEY_COMPUTER,
EV_KEY, KEY_BACK,
EV_KEY, KEY_FORWARD,
EV_KEY, KEY_NEXTSONG,
EV_KEY, KEY_PLAYPAUSE,
EV_KEY, KEY_PREVIOUSSONG,
EV_KEY, KEY_STOPCD,
EV_KEY, KEY_HOMEPAGE,
EV_KEY, KEY_REFRESH,
EV_KEY, KEY_F14,
EV_KEY, KEY_F15,
EV_KEY, KEY_SEARCH,
EV_KEY, KEY_MEDIA,
EV_KEY, KEY_FN,
-1, -1,
};
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_keyboard_device = {
.type = LITEST_KEYBOARD,
.features = LITEST_KEYS,
.shortname = "default keyboard",
.setup = litest_keyboard_setup,
.create = litest_create_keyboard,
.interface = NULL,
.name = "AT Translated Set 2 keyboard",
.id = &input_id,
.events = events,
.absinfo = NULL,
};
......@@ -37,38 +37,31 @@ static void litest_mouse_setup(void)
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);
static struct input_id input_id = {
.bustype = 0x3,
.vendor = 0x17ef,
.product = 0x6019,
};
rc = libevdev_uinput_create_from_device(dev,
LIBEVDEV_UINPUT_OPEN_MANAGED,
&d->uinput);
ck_assert_int_eq(rc, 0);
libevdev_free(dev);
}
static int events[] = {
EV_KEY, BTN_LEFT,
EV_KEY, BTN_RIGHT,
EV_KEY, BTN_MIDDLE,
EV_REL, REL_X,
EV_REL, REL_Y,
EV_REL, REL_WHEEL,
-1 , -1,
};
struct litest_test_device litest_mouse_device = {
.type = LITEST_MOUSE,
.features = LITEST_POINTER | LITEST_BUTTON | LITEST_WHEEL,
.shortname = "mouse",
.setup = litest_mouse_setup,
.create = litest_create_mouse,
.interface = &interface,
.name = "Lenovo Optical USB Mouse",
.id = &input_id,
.absinfo = NULL,
.events = events,
};
......@@ -34,97 +34,67 @@ void litest_synaptics_touchpad_setup(void)
litest_set_current_device(d);
}
void
litest_synaptics_touchpad_touch_down(struct litest_device *d,
unsigned int slot,
int x, int y)
{
struct input_event *ev;
struct input_event down[] = {
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_ABS, .code = ABS_X, .value = x },
{ .type = EV_ABS, .code = ABS_Y, .value = y },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = 30 },
{ .type = EV_ABS, .code = ABS_TOOL_WIDTH, .value = 7 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
down[1].value = litest_scale(d, ABS_X, x);
down[2].value = litest_scale(d, ABS_Y, y);
ARRAY_FOR_EACH(down, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
void
litest_synaptics_touchpad_move(struct litest_device *d,
unsigned int slot,
int x, int y)
{
struct input_event *ev;
struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_X, .value = x },
{ .type = EV_ABS, .code = ABS_Y, .value = y },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
move[0].value = litest_scale(d, ABS_X, x);
move[1].value = litest_scale(d, ABS_Y, y);
ARRAY_FOR_EACH(move, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
static struct input_event down[] = {
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = 30 },
{ .type = EV_ABS, .code = ABS_TOOL_WIDTH, .value = 7 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
void
litest_synaptics_touchpad_up(struct litest_device *d, unsigned int slot)
{
struct input_event *ev;
struct input_event up[] = {
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
};
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
ARRAY_FOR_EACH(up, ev)
litest_event(d, ev->type, ev->code, ev->value);
}
struct input_event up[] = {
{ .type = EV_KEY, .code = BTN_TOUCH, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct litest_device_interface interface = {
.touch_down = litest_synaptics_touchpad_touch_down,
.touch_move = litest_synaptics_touchpad_move,
.touch_up = litest_synaptics_touchpad_up,
.touch_down_events = down,
.touch_move_events = move,
.touch_up_events = up,
};
void
litest_create_synaptics_touchpad(struct litest_device *d)
{
struct input_absinfo abs[] = {
{ ABS_X, 1472, 5472, 75 },
{ ABS_Y, 1408, 4448, 129 },
{ ABS_PRESSURE, 0, 255, 0 },
{ ABS_TOOL_WIDTH, 0, 15, 0 },
{ .value = -1 },
};