1 /*
2 * Copyright © 2014 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 "litest.h"
27 #include "litest-int.h"
28
29 static struct input_event proximity_in[] = {
30 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
31 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
32 { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
33 { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
34 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
35 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
36 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
37 { .type = -1, .code = -1 },
38 };
39
40 static struct input_event proximity_out[] = {
41 { .type = EV_ABS, .code = ABS_X, .value = 0 },
42 { .type = EV_ABS, .code = ABS_Y, .value = 0 },
43 { .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
44 { .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
45 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
46 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
47 { .type = -1, .code = -1 },
48 };
49
50 static struct input_event motion[] = {
51 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
52 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
53 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
54 { .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
55 { .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
56 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
57 { .type = -1, .code = -1 },
58 };
59
60 static int
get_axis_default(struct litest_device * d,unsigned int evcode,int32_t * value)61 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
62 {
63 switch (evcode) {
64 case ABS_TILT_X:
65 case ABS_TILT_Y:
66 *value = 0;
67 return 0;
68 case ABS_PRESSURE:
69 *value = 100;
70 return 0;
71 }
72 return 1;
73 }
74
75 static struct litest_device_interface interface = {
76 .tablet_proximity_in_events = proximity_in,
77 .tablet_proximity_out_events = proximity_out,
78 .tablet_motion_events = motion,
79
80 .get_axis_default = get_axis_default,
81 };
82
83 static struct input_absinfo absinfo[] = {
84 { ABS_X, 0, 32000, 0, 0, 0 },
85 { ABS_Y, 0, 32000, 0, 0, 0 },
86 { ABS_PRESSURE, 0, 2047, 0, 0, 0 },
87 { ABS_TILT_X, -127, 127, 0, 0, 0 },
88 { ABS_TILT_Y, -127, 127, 0, 0, 0 },
89 { .value = -1 },
90 };
91
92 static struct input_id input_id = {
93 .bustype = 0x3,
94 .vendor = 0x172f,
95 .product = 0x509,
96 };
97
98 static int events[] = {
99 EV_KEY, KEY_ESC,
100 EV_KEY, KEY_1,
101 EV_KEY, KEY_2,
102 EV_KEY, KEY_3,
103 EV_KEY, KEY_4,
104 EV_KEY, KEY_5,
105 EV_KEY, KEY_6,
106 EV_KEY, KEY_7,
107 EV_KEY, KEY_8,
108 EV_KEY, KEY_9,
109 EV_KEY, KEY_0,
110 EV_KEY, KEY_MINUS,
111 EV_KEY, KEY_EQUAL,
112 EV_KEY, KEY_BACKSPACE,
113 EV_KEY, KEY_TAB,
114 EV_KEY, KEY_Q,
115 EV_KEY, KEY_W,
116 EV_KEY, KEY_E,
117 EV_KEY, KEY_R,
118 EV_KEY, KEY_T,
119 EV_KEY, KEY_Y,
120 EV_KEY, KEY_U,
121 EV_KEY, KEY_I,
122 EV_KEY, KEY_O,
123 EV_KEY, KEY_P,
124 EV_KEY, KEY_LEFTBRACE,
125 EV_KEY, KEY_RIGHTBRACE,
126 EV_KEY, KEY_ENTER,
127 EV_KEY, KEY_LEFTCTRL,
128 EV_KEY, KEY_A,
129 EV_KEY, KEY_S,
130 EV_KEY, KEY_D,
131 EV_KEY, KEY_F,
132 EV_KEY, KEY_G,
133 EV_KEY, KEY_H,
134 EV_KEY, KEY_J,
135 EV_KEY, KEY_K,
136 EV_KEY, KEY_L,
137 EV_KEY, KEY_SEMICOLON,
138 EV_KEY, KEY_APOSTROPHE,
139 EV_KEY, KEY_GRAVE,
140 EV_KEY, KEY_LEFTSHIFT,
141 EV_KEY, KEY_BACKSLASH,
142 EV_KEY, KEY_Z,
143 EV_KEY, KEY_X,
144 EV_KEY, KEY_C,
145 EV_KEY, KEY_V,
146 EV_KEY, KEY_B,
147 EV_KEY, KEY_N,
148 EV_KEY, KEY_M,
149 EV_KEY, KEY_COMMA,
150 EV_KEY, KEY_DOT,
151 EV_KEY, KEY_SLASH,
152 EV_KEY, KEY_RIGHTSHIFT,
153 EV_KEY, KEY_KPASTERISK,
154 EV_KEY, KEY_LEFTALT,
155 EV_KEY, KEY_SPACE,
156 EV_KEY, KEY_CAPSLOCK,
157 EV_KEY, KEY_F1,
158 EV_KEY, KEY_F2,
159 EV_KEY, KEY_F3,
160 EV_KEY, KEY_F4,
161 EV_KEY, KEY_F5,
162 EV_KEY, KEY_F6,
163 EV_KEY, KEY_F7,
164 EV_KEY, KEY_F8,
165 EV_KEY, KEY_F9,
166 EV_KEY, KEY_F10,
167 EV_KEY, KEY_NUMLOCK,
168 EV_KEY, KEY_SCROLLLOCK,
169 EV_KEY, KEY_KP7,
170 EV_KEY, KEY_KP8,
171 EV_KEY, KEY_KP9,
172 EV_KEY, KEY_KPMINUS,
173 EV_KEY, KEY_KP4,
174 EV_KEY, KEY_KP5,
175 EV_KEY, KEY_KP6,
176 EV_KEY, KEY_KPPLUS,
177 EV_KEY, KEY_KP1,
178 EV_KEY, KEY_KP2,
179 EV_KEY, KEY_KP3,
180 EV_KEY, KEY_KP0,
181 EV_KEY, KEY_KPDOT,
182 EV_KEY, KEY_102ND,
183 EV_KEY, KEY_F11,
184 EV_KEY, KEY_F12,
185 EV_KEY, KEY_KPENTER,
186 EV_KEY, KEY_RIGHTCTRL,
187 EV_KEY, KEY_KPSLASH,
188 EV_KEY, KEY_SYSRQ,
189 EV_KEY, KEY_RIGHTALT,
190 EV_KEY, KEY_HOME,
191 EV_KEY, KEY_UP,
192 EV_KEY, KEY_PAGEUP,
193 EV_KEY, KEY_LEFT,
194 EV_KEY, KEY_RIGHT,
195 EV_KEY, KEY_END,
196 EV_KEY, KEY_DOWN,
197 EV_KEY, KEY_PAGEDOWN,
198 EV_KEY, KEY_INSERT,
199 EV_KEY, KEY_DELETE,
200 EV_KEY, KEY_MUTE,
201 EV_KEY, KEY_VOLUMEDOWN,
202 EV_KEY, KEY_VOLUMEUP,
203 EV_KEY, KEY_PAUSE,
204 EV_KEY, KEY_LEFTMETA,
205 EV_KEY, KEY_RIGHTMETA,
206 EV_KEY, KEY_COMPOSE,
207 EV_KEY, BTN_0,
208 EV_KEY, BTN_LEFT,
209 EV_KEY, BTN_RIGHT,
210 EV_KEY, BTN_MIDDLE,
211 EV_KEY, BTN_SIDE,
212 EV_KEY, BTN_EXTRA,
213 EV_KEY, BTN_TOOL_PEN,
214 EV_KEY, BTN_TOOL_RUBBER,
215 EV_KEY, BTN_TOUCH,
216 EV_KEY, BTN_STYLUS,
217 EV_REL, REL_HWHEEL,
218 EV_REL, REL_WHEEL,
219 EV_MSC, MSC_SERIAL,
220 -1, -1,
221 };
222
223 static const char quirk_file[] =
224 "[litest Waltop Tablet]\n"
225 "MatchName=litest WALTOP Batteryless Tablet*\n"
226 "AttrSizeHint=200x200\n";
227
228 TEST_DEVICE("waltop-tablet",
229 .type = LITEST_WALTOP,
230 .features = LITEST_TABLET | LITEST_WHEEL | LITEST_TILT | LITEST_HOVER,
231 .interface = &interface,
232
233 .name = " WALTOP Batteryless Tablet ", /* sic */
234 .id = &input_id,
235 .events = events,
236 .absinfo = absinfo,
237 .quirk_file = quirk_file,
238 )
239