[PATCH libinput 5/5] test: switch the remaining devices to a description-based device

Hans de Goede hdegoede at redhat.com
Tue Apr 1 02:50:04 PDT 2014


Hi,

On 04/01/2014 05:47 AM, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  test/litest-bcm5974.c               | 147 ++++++++++-------------
>  test/litest-generic-highres-touch.c | 128 ++++++++------------
>  test/litest-keyboard.c              | 231 +++++++++++++++++++++++++-----------
>  test/litest-mouse.c                 |  48 ++++----
>  test/litest-synaptics-st.c          | 131 ++++++++------------
>  test/litest-trackpoint.c            |  39 +++---
>  test/litest-wacom-touch.c           | 127 ++++++++------------
>  7 files changed, 419 insertions(+), 432 deletions(-)
> 

Looks good:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

p.s.

I'm wondering if we should remove support for direct device instantiation,
now all devices use the descriptor based approach ?


> diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c
> index ff822f9..ab944a7 100644
> --- a/test/litest-bcm5974.c
> +++ b/test/litest-bcm5974.c
> @@ -34,97 +34,66 @@ 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 },
> -	};
> +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 },
> +};
>  
> -	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);
> -
> -	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 },
> +};
> +
> +static struct input_id input_id = {
> +	.bustype = 0x3,
> +	.vendor = 0x5ac,
> +	.product = 0x249,
> +};
>  
> -	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 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,
> @@ -132,5 +101,11 @@ struct litest_test_device litest_bcm5974_device = {
>  	.shortname = "bcm5974",
>  	.setup = litest_bcm5974_setup,
>  	.teardown = NULL,
> -	.create = litest_create_bcm5974,
> +	.create = NULL,
> +	.interface = &interface,
> +
> +	.name = "bcm5974",
> +	.id = &input_id,
> +	.events = events,
> +	.absinfo = absinfo,
>  };
> diff --git a/test/litest-generic-highres-touch.c b/test/litest-generic-highres-touch.c
> index 4d21b0d..351d826 100644
> --- a/test/litest-generic-highres-touch.c
> +++ b/test/litest-generic-highres-touch.c
> @@ -34,89 +34,55 @@ 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 },
> -	};
> +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 },
> +};
>  
> -	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);
> -
> -	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 },
> +};
> +
> +static struct input_id input_id = {
> +	.bustype = 0x3,
> +	.vendor = 0xabcd, /* Some random vendor. */
> +	.product = 0x1234, /* Some random product id. */
> +};
>  
> -	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 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,
> @@ -124,5 +90,11 @@ struct litest_test_device litest_generic_highres_touch_device = {
>  	.shortname = "generic-highres-touch",
>  	.setup = litest_generic_highres_touch_setup,
>  	.teardown = NULL,
> -	.create = litest_create_generic_highres_touch,
> +	.create = NULL,
> +	.interface = &interface,
> +
> +	.name = "Generic emulated highres touch device",
> +	.id = &input_id,
> +	.events = events,
> +	.absinfo = absinfo,
>  };
> diff --git a/test/litest-keyboard.c b/test/litest-keyboard.c
> index ab05014..c883698 100644
> --- a/test/litest-keyboard.c
> +++ b/test/litest-keyboard.c
> @@ -34,75 +34,168 @@ 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;
> +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,
>  
> -	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);
> -	}
> -
> -	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,
> @@ -110,5 +203,11 @@ struct litest_test_device litest_keyboard_device = {
>  	.shortname = "default keyboard",
>  	.setup = litest_keyboard_setup,
>  	.teardown = NULL,
> -	.create = litest_create_keyboard,
> +	.create = NULL,
> +	.interface = NULL,
> +
> +	.name = "AT Translated Set 2 keyboard",
> +	.id = &input_id,
> +	.events = events,
> +	.absinfo = NULL,
>  };
> diff --git a/test/litest-mouse.c b/test/litest-mouse.c
> index 2f70767..7c973b5 100644
> --- a/test/litest-mouse.c
> +++ b/test/litest-mouse.c
> @@ -37,33 +37,21 @@ 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;
> +static struct input_id input_id = {
> +	.bustype = 0x3,
> +	.vendor = 0x17ef,
> +	.product = 0x6019,
> +};
>  
> -	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);
> -}
> +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,
> @@ -71,5 +59,11 @@ struct litest_test_device litest_mouse_device = {
>  	.shortname = "mouse",
>  	.setup = litest_mouse_setup,
>  	.teardown = NULL,
> -	.create = litest_create_mouse,
> +	.create = NULL,
> +	.interface = &interface,
> +
> +	.name = "Lenovo Optical USB Mouse",
> +	.id = &input_id,
> +	.absinfo = NULL,
> +	.events = events,
>  };
> diff --git a/test/litest-synaptics-st.c b/test/litest-synaptics-st.c
> index de56c22..ebf8eff 100644
> --- a/test/litest-synaptics-st.c
> +++ b/test/litest-synaptics-st.c
> @@ -34,92 +34,57 @@ 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 },
> -	};
> +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 },
> +};
>  
> -	down[1].value = litest_scale(d, ABS_X, x);
> -	down[2].value = litest_scale(d, ABS_Y, y);
> +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(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);
> -}
> -
> -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 },
> -	};
> -
> -	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 },
> -	};
> -	struct input_id id = {
> -		.bustype = 0x11,
> -		.vendor = 0x2,
> -		.product = 0x7,
> -	};
> +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 },
> +	{ .value = -1 },
> +};
> +
> +static struct input_id input_id = {
> +	.bustype = 0x11,
> +	.vendor = 0x2,
> +	.product = 0x7,
> +};
>  
> -	d->interface = &interface;
> -	d->uinput = litest_create_uinput_abs_device("SynPS/2 Synaptics TouchPad", &id,
> -						    abs,
> -						    EV_KEY, BTN_LEFT,
> -						    EV_KEY, BTN_RIGHT,
> -						    EV_KEY, BTN_TOOL_FINGER,
> -						    EV_KEY, BTN_TOUCH,
> -						    -1, -1);
> -}
> +static int events[] = {
> +	EV_KEY, BTN_LEFT,
> +	EV_KEY, BTN_RIGHT,
> +	EV_KEY, BTN_TOOL_FINGER,
> +	EV_KEY, BTN_TOUCH,
> +	-1, -1,
> +};
>  
>  struct litest_test_device litest_synaptics_touchpad_device = {
>  	.type = LITEST_SYNAPTICS_TOUCHPAD,
> @@ -127,5 +92,11 @@ struct litest_test_device litest_synaptics_touchpad_device = {
>  	.shortname = "synaptics ST",
>  	.setup = litest_synaptics_touchpad_setup,
>  	.teardown = NULL,
> -	.create = litest_create_synaptics_touchpad,
> +	.create = NULL,
> +	.interface = &interface,
> +
> +	.name = "SynPS/2 Synaptics TouchPad",
> +	.id = &input_id,
> +	.events = events,
> +	.absinfo = absinfo,
>  };
> diff --git a/test/litest-trackpoint.c b/test/litest-trackpoint.c
> index 1c0fb0a..a9bff67 100644
> --- a/test/litest-trackpoint.c
> +++ b/test/litest-trackpoint.c
> @@ -37,24 +37,20 @@ static void litest_trackpoint_setup(void)
>  static struct litest_device_interface interface = {
>  };
>  
> -static void
> -litest_create_trackpoint(struct litest_device *d)
> -{
> -	struct input_id id = {
> -		.bustype = 0x11,
> -		.vendor = 0x2,
> -		.product = 0xa,
> -	};
> +static struct input_id input_id = {
> +	.bustype = 0x11,
> +	.vendor = 0x2,
> +	.product = 0xa,
> +};
>  
> -	d->interface = &interface;
> -	d->uinput = litest_create_uinput_device("TPPS/2 IBM TrackPoint", &id,
> -						EV_KEY, BTN_LEFT,
> -						EV_KEY, BTN_RIGHT,
> -						EV_KEY, BTN_MIDDLE,
> -						EV_REL, REL_X,
> -						EV_REL, REL_Y,
> -						-1, -1);
> -}
> +static int events[] = {
> +	EV_KEY, BTN_LEFT,
> +	EV_KEY, BTN_RIGHT,
> +	EV_KEY, BTN_MIDDLE,
> +	EV_REL, REL_X,
> +	EV_REL, REL_Y,
> +	-1, -1,
> +};
>  
>  struct litest_test_device litest_trackpoint_device = {
>  	.type = LITEST_TRACKPOINT,
> @@ -62,5 +58,12 @@ struct litest_test_device litest_trackpoint_device = {
>  	.shortname = "trackpoint",
>  	.setup = litest_trackpoint_setup,
>  	.teardown = NULL,
> -	.create = litest_create_trackpoint,
> +	.create = NULL,
> +	.interface = &interface,
> +
> +	.name = "TPPS/2 IBM TrackPoint",
> +	.id = &input_id,
> +	.absinfo = NULL,
> +	.events = events,
> +
>  };
> diff --git a/test/litest-wacom-touch.c b/test/litest-wacom-touch.c
> index e9119a9..90afc72 100644
> --- a/test/litest-wacom-touch.c
> +++ b/test/litest-wacom-touch.c
> @@ -34,88 +34,55 @@ void litest_wacom_touch_setup(void)
>  	litest_set_current_device(d);
>  }
>  
> -void
> -litest_wacom_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 },
> -	};
> +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 },
> +};
>  
> -	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_wacom_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);
> -
> -	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_wacom_touch_touch_down,
> -	.touch_move = litest_wacom_touch_move,
> +	.touch_down_events = down,
> +	.touch_move_events = move,
>  };
>  
> -void
> -litest_create_wacom_touch(struct litest_device *d)
> -{
> -	struct input_absinfo abs[] = {
> -		{ ABS_X, 0, 2776, 75 },
> -		{ ABS_Y, 0, 1569, 129 },
> -		{ ABS_MT_SLOT, 0, 1, 0 },
> -		{ ABS_MT_POSITION_X, 0, 2776, 0, 0, 10 },
> -		{ ABS_MT_POSITION_Y, 0, 1569, 0, 0, 9 },
> -		{ ABS_MT_TRACKING_ID, 0, 65535, 0 },
> -		{ .value = -1 },
> -	};
> -	struct input_id id = {
> -		.bustype = 0x3,
> -		.vendor = 0x56a,
> -		.product = 0xe6,
> -	};
> +static struct input_absinfo absinfo[] = {
> +	{ ABS_X, 0, 2776, 75 },
> +	{ ABS_Y, 0, 1569, 129 },
> +	{ ABS_MT_SLOT, 0, 1, 0 },
> +	{ ABS_MT_POSITION_X, 0, 2776, 0, 0, 10 },
> +	{ ABS_MT_POSITION_Y, 0, 1569, 0, 0, 9 },
> +	{ ABS_MT_TRACKING_ID, 0, 65535, 0 },
> +	{ .value = -1 },
> +};
> +
> +static struct input_id input_id = {
> +	.bustype = 0x3,
> +	.vendor = 0x56a,
> +	.product = 0xe6,
> +};
>  
> -	d->interface = &interface;
> -	d->uinput = litest_create_uinput_abs_device("Wacom ISDv4 E6 Finger", &id,
> -						    abs,
> -						    EV_KEY, BTN_TOUCH,
> -						    INPUT_PROP_MAX, INPUT_PROP_DIRECT,
> -						    -1, -1);
> -}
> +static int events[] = {
> +	EV_KEY, BTN_TOUCH,
> +	INPUT_PROP_MAX, INPUT_PROP_DIRECT,
> +	-1, -1,
> +};
>  
>  struct litest_test_device litest_wacom_touch_device = {
>  	.type = LITEST_WACOM_TOUCH,
> @@ -123,5 +90,11 @@ struct litest_test_device litest_wacom_touch_device = {
>  	.shortname = "wacom-touch",
>  	.setup = litest_wacom_touch_setup,
>  	.teardown = NULL,
> -	.create = litest_create_wacom_touch,
> +	.create = NULL,
> +	.interface = &interface,
> +
> +	.name = "Wacom ISDv4 E6 Finger",
> +	.id = &input_id,
> +	.events = events,
> +	.absinfo = absinfo,
>  };
> 


More information about the wayland-devel mailing list