1/*
2 * Copyright © 2016 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "config.h"
25
26#include <errno.h>
27#include <fcntl.h>
28#include <unistd.h>
29#include <sys/stat.h>
30
31#include "litest.h"
32#include "litest-int.h"
33
34static void
35litest_wacom_cintiq_pad_teardown(void)
36{
37	litest_generic_device_teardown();
38}
39
40static struct input_event down[] = {
41	{ .type = -1, .code = -1 },
42};
43
44static struct input_event move[] = {
45	{ .type = -1, .code = -1 },
46};
47
48static struct input_event ring_start[] = {
49	{ .type = EV_ABS, .code = ABS_WHEEL, .value = LITEST_AUTO_ASSIGN },
50	{ .type = EV_ABS, .code = ABS_MISC, .value = 15 },
51	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
52	{ .type = -1, .code = -1 },
53} ;
54
55static struct input_event ring_change[] = {
56	{ .type = EV_ABS, .code = ABS_WHEEL, .value = LITEST_AUTO_ASSIGN },
57	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
58	{ .type = -1, .code = -1 },
59} ;
60
61static struct input_event ring_end[] = {
62	{ .type = EV_ABS, .code = ABS_WHEEL, .value = 0 },
63	{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
64	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
65	{ .type = -1, .code = -1 },
66} ;
67
68static struct litest_device_interface interface = {
69	.touch_down_events = down,
70	.touch_move_events = move,
71	.pad_ring_start_events = ring_start,
72	.pad_ring_change_events = ring_change,
73	.pad_ring_end_events = ring_end,
74};
75
76static struct input_absinfo absinfo[] = {
77	{ ABS_X, 0, 1, 0, 0, 0 },
78	{ ABS_Y, 0, 1, 0, 0, 0 },
79	{ ABS_WHEEL, 0, 71, 0, 0, 0 },
80	{ ABS_THROTTLE, 0, 71, 0, 0, 0 },
81	{ ABS_MISC, 0, 0, 0, 0, 0 },
82	{ .value = -1 },
83};
84
85static struct input_id input_id = {
86	.bustype = 0x3,
87	.vendor = 0x56a,
88	.product = 0xf8,
89	.version = 0x110,
90};
91
92static int events[] = {
93	EV_KEY, KEY_PROG1,
94	EV_KEY, KEY_PROG2,
95	EV_KEY, KEY_PROG3,
96	EV_KEY, BTN_0,
97	EV_KEY, BTN_1,
98	EV_KEY, BTN_2,
99	EV_KEY, BTN_3,
100	EV_KEY, BTN_4,
101	EV_KEY, BTN_5,
102	EV_KEY, BTN_6,
103	EV_KEY, BTN_7,
104	EV_KEY, BTN_8,
105	EV_KEY, BTN_9,
106	EV_KEY, BTN_SOUTH,
107	EV_KEY, BTN_EAST,
108	EV_KEY, BTN_C,
109	EV_KEY, BTN_NORTH,
110	EV_KEY, BTN_WEST,
111	EV_KEY, BTN_Z,
112	EV_KEY, BTN_STYLUS,
113	-1, -1,
114};
115
116TEST_DEVICE("wacom-cintiq-24hdt-pad",
117	.type = LITEST_WACOM_CINTIQ_24HDT_PAD,
118	.features = LITEST_TABLET_PAD | LITEST_RING,
119	.teardown = litest_wacom_cintiq_pad_teardown,
120	.interface = &interface,
121
122	.name = "Wacom Cintiq 24 HD touch Pad",
123	.id = &input_id,
124	.events = events,
125	.absinfo = absinfo,
126	.udev_properties = {
127		{ "ID_INPUT_TABLET_PAD", "1" },
128		{ "LIBINPUT_DEVICE_GROUP", "wacom-24hdt-group" },
129		{ NULL },
130	},
131)
132