• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 down[] = {
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_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
33 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
34 	{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
35 	{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
36 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
37 	{ .type = -1, .code = -1 },
38 };
39 
40 static struct input_event move[] = {
41 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
42 	{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
43 	{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
44 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
45 	{ .type = -1, .code = -1 },
46 };
47 
48 /* We define down/move so that we can emulate fake touches on this device,
49    to make sure nothing crashes. */
50 static struct litest_device_interface interface = {
51 	.touch_down_events = down,
52 	.touch_move_events = move,
53 };
54 
55 static struct input_absinfo absinfo[] = {
56 	{ ABS_X, 0, 1022, 0, 0, 12 },
57 	{ ABS_Y, 0, 487, 0, 0, 12 },
58 	{ ABS_VOLUME, 0, 1023, 0, 0, 0 },
59 	{ ABS_MISC, 0, 255, 0, 0, 0 },
60 	{ 41, 0, 255, 0, 0, 0 },
61 	{ 42, -127, 127, 0, 0, 0 },
62 	{ 43, -127, 127, 0, 0, 0 },
63 	{ 44, -127, 127, 0, 0, 0 },
64 	{ 45, -127, 127, 0, 0, 0 },
65 	{ 46, -127, 127, 0, 0, 0 },
66 	{ 47, -127, 127, 0, 0, 0 },
67 	/* ABS_MT range overlap starts here */
68 	{ 48, -127, 127, 0, 0, 0 }, /* ABS_MT_SLOT */
69 	{ 49, -127, 127, 0, 0, 0 },
70 	{ 50, -127, 127, 0, 0, 0 },
71 	{ 51, -127, 127, 0, 0, 0 },
72 	{ 52, -127, 127, 0, 0, 0 },
73 	{ 53, -127, 127, 0, 0, 0 },
74 	{ 54, -127, 127, 0, 0, 0 },
75 	{ 55, -127, 127, 0, 0, 0 },
76 	{ 56, -127, 127, 0, 0, 0 },
77 	{ 57, -127, 127, 0, 0, 0 },
78 	{ 58, -127, 127, 0, 0, 0 },
79 	{ 59, -127, 127, 0, 0, 0 },
80 	{ 60, -127, 127, 0, 0, 0 },
81 	{ 61, -127, 127, 0, 0, 0 }, /* ABS_MT_TOOL_Y */
82 	{ 62, -127, 127, 0, 0, 0 },
83 	{ .value = -1 },
84 };
85 
86 static struct input_id input_id = {
87 	.bustype = 0x3,
88 	.vendor = 0x45e,
89 	.product = 0x7dc,
90 };
91 
92 static int events[] = {
93 	EV_REL, REL_X,
94 	EV_REL, REL_Y,
95 	EV_REL, REL_HWHEEL,
96 	EV_REL, REL_DIAL,
97 	EV_REL, REL_WHEEL,
98 	EV_KEY, KEY_ESC,
99 	EV_KEY, KEY_1,
100 	EV_KEY, KEY_2,
101 	EV_KEY, KEY_3,
102 	EV_KEY, KEY_4,
103 	EV_KEY, KEY_5,
104 	EV_KEY, KEY_6,
105 	EV_KEY, KEY_7,
106 	EV_KEY, KEY_8,
107 	EV_KEY, KEY_9,
108 	EV_KEY, KEY_0,
109 	EV_KEY, KEY_MINUS,
110 	EV_KEY, KEY_EQUAL,
111 	EV_KEY, KEY_BACKSPACE,
112 	EV_KEY, KEY_TAB,
113 	EV_KEY, KEY_Q,
114 	EV_KEY, KEY_W,
115 	EV_KEY, KEY_E,
116 	EV_KEY, KEY_R,
117 	EV_KEY, KEY_T,
118 	EV_KEY, KEY_Y,
119 	EV_KEY, KEY_U,
120 	EV_KEY, KEY_I,
121 	EV_KEY, KEY_O,
122 	EV_KEY, KEY_P,
123 	EV_KEY, KEY_LEFTBRACE,
124 	EV_KEY, KEY_RIGHTBRACE,
125 	EV_KEY, KEY_ENTER,
126 	EV_KEY, KEY_LEFTCTRL,
127 	EV_KEY, KEY_A,
128 	EV_KEY, KEY_S,
129 	EV_KEY, KEY_D,
130 	EV_KEY, KEY_F,
131 	EV_KEY, KEY_G,
132 	EV_KEY, KEY_H,
133 	EV_KEY, KEY_J,
134 	EV_KEY, KEY_K,
135 	EV_KEY, KEY_L,
136 	EV_KEY, KEY_SEMICOLON,
137 	EV_KEY, KEY_APOSTROPHE,
138 	EV_KEY, KEY_GRAVE,
139 	EV_KEY, KEY_LEFTSHIFT,
140 	EV_KEY, KEY_BACKSLASH,
141 	EV_KEY, KEY_Z,
142 	EV_KEY, KEY_X,
143 	EV_KEY, KEY_C,
144 	EV_KEY, KEY_V,
145 	EV_KEY, KEY_B,
146 	EV_KEY, KEY_N,
147 	EV_KEY, KEY_M,
148 	EV_KEY, KEY_COMMA,
149 	EV_KEY, KEY_DOT,
150 	EV_KEY, KEY_SLASH,
151 	EV_KEY, KEY_RIGHTSHIFT,
152 	EV_KEY, KEY_KPASTERISK,
153 	EV_KEY, KEY_LEFTALT,
154 	EV_KEY, KEY_SPACE,
155 	EV_KEY, KEY_CAPSLOCK,
156 	EV_KEY, KEY_F1,
157 	EV_KEY, KEY_F2,
158 	EV_KEY, KEY_F3,
159 	EV_KEY, KEY_F4,
160 	EV_KEY, KEY_F5,
161 	EV_KEY, KEY_F6,
162 	EV_KEY, KEY_F7,
163 	EV_KEY, KEY_F8,
164 	EV_KEY, KEY_F9,
165 	EV_KEY, KEY_F10,
166 	EV_KEY, KEY_NUMLOCK,
167 	EV_KEY, KEY_SCROLLLOCK,
168 	EV_KEY, KEY_KP7,
169 	EV_KEY, KEY_KP8,
170 	EV_KEY, KEY_KP9,
171 	EV_KEY, KEY_KPMINUS,
172 	EV_KEY, KEY_KP4,
173 	EV_KEY, KEY_KP5,
174 	EV_KEY, KEY_KP6,
175 	EV_KEY, KEY_KPPLUS,
176 	EV_KEY, KEY_KP1,
177 	EV_KEY, KEY_KP2,
178 	EV_KEY, KEY_KP3,
179 	EV_KEY, KEY_KP0,
180 	EV_KEY, KEY_KPDOT,
181 	EV_KEY, KEY_102ND,
182 	EV_KEY, KEY_F11,
183 	EV_KEY, KEY_F12,
184 	EV_KEY, KEY_RO,
185 	EV_KEY, KEY_HENKAN,
186 	EV_KEY, KEY_KATAKANAHIRAGANA,
187 	EV_KEY, KEY_MUHENKAN,
188 	EV_KEY, KEY_KPJPCOMMA,
189 	EV_KEY, KEY_KPENTER,
190 	EV_KEY, KEY_RIGHTCTRL,
191 	EV_KEY, KEY_KPSLASH,
192 	EV_KEY, KEY_SYSRQ,
193 	EV_KEY, KEY_RIGHTALT,
194 	EV_KEY, KEY_HOME,
195 	EV_KEY, KEY_UP,
196 	EV_KEY, KEY_PAGEUP,
197 	EV_KEY, KEY_LEFT,
198 	EV_KEY, KEY_RIGHT,
199 	EV_KEY, KEY_END,
200 	EV_KEY, KEY_DOWN,
201 	EV_KEY, KEY_PAGEDOWN,
202 	EV_KEY, KEY_INSERT,
203 	EV_KEY, KEY_DELETE,
204 	EV_KEY, KEY_MUTE,
205 	EV_KEY, KEY_VOLUMEDOWN,
206 	EV_KEY, KEY_VOLUMEUP,
207 	EV_KEY, KEY_POWER,
208 	EV_KEY, KEY_KPEQUAL,
209 	EV_KEY, KEY_PAUSE,
210 	EV_KEY, KEY_KPCOMMA,
211 	EV_KEY, KEY_HANGEUL,
212 	EV_KEY, KEY_HANJA,
213 	EV_KEY, KEY_YEN,
214 	EV_KEY, KEY_LEFTMETA,
215 	EV_KEY, KEY_RIGHTMETA,
216 	EV_KEY, KEY_COMPOSE,
217 	EV_KEY, KEY_STOP,
218 	EV_KEY, KEY_AGAIN,
219 	EV_KEY, KEY_PROPS,
220 	EV_KEY, KEY_UNDO,
221 	EV_KEY, KEY_FRONT,
222 	EV_KEY, KEY_COPY,
223 	EV_KEY, KEY_OPEN,
224 	EV_KEY, KEY_PASTE,
225 	EV_KEY, KEY_FIND,
226 	EV_KEY, KEY_CUT,
227 	EV_KEY, KEY_HELP,
228 	EV_KEY, KEY_MENU,
229 	EV_KEY, KEY_CALC,
230 	EV_KEY, KEY_SLEEP,
231 	EV_KEY, KEY_FILE,
232 	EV_KEY, KEY_WWW,
233 	EV_KEY, KEY_COFFEE,
234 	EV_KEY, KEY_MAIL,
235 	EV_KEY, KEY_BOOKMARKS,
236 	EV_KEY, KEY_BACK,
237 	EV_KEY, KEY_FORWARD,
238 	EV_KEY, KEY_EJECTCD,
239 	EV_KEY, KEY_NEXTSONG,
240 	EV_KEY, KEY_PLAYPAUSE,
241 	EV_KEY, KEY_PREVIOUSSONG,
242 	EV_KEY, KEY_STOPCD,
243 	EV_KEY, KEY_RECORD,
244 	EV_KEY, KEY_REWIND,
245 	EV_KEY, KEY_PHONE,
246 	EV_KEY, KEY_CONFIG,
247 	EV_KEY, KEY_HOMEPAGE,
248 	EV_KEY, KEY_REFRESH,
249 	EV_KEY, KEY_EXIT,
250 	EV_KEY, KEY_EDIT,
251 	EV_KEY, KEY_SCROLLUP,
252 	EV_KEY, KEY_SCROLLDOWN,
253 	EV_KEY, KEY_NEW,
254 	EV_KEY, KEY_REDO,
255 	EV_KEY, KEY_F13,
256 	EV_KEY, KEY_F14,
257 	EV_KEY, KEY_F15,
258 	EV_KEY, KEY_F16,
259 	EV_KEY, KEY_F17,
260 	EV_KEY, KEY_F18,
261 	EV_KEY, KEY_F19,
262 	EV_KEY, KEY_F20,
263 	EV_KEY, KEY_F21,
264 	EV_KEY, KEY_F22,
265 	EV_KEY, KEY_F23,
266 	EV_KEY, KEY_F24,
267 	EV_KEY, KEY_CLOSE,
268 	EV_KEY, KEY_PLAY,
269 	EV_KEY, KEY_FASTFORWARD,
270 	EV_KEY, KEY_BASSBOOST,
271 	EV_KEY, KEY_PRINT,
272 	EV_KEY, KEY_CAMERA,
273 	EV_KEY, KEY_CHAT,
274 	EV_KEY, KEY_SEARCH,
275 	EV_KEY, KEY_FINANCE,
276 	EV_KEY, KEY_CANCEL,
277 	EV_KEY, KEY_BRIGHTNESSDOWN,
278 	EV_KEY, KEY_BRIGHTNESSUP,
279 	EV_KEY, KEY_KBDILLUMTOGGLE,
280 	EV_KEY, KEY_SEND,
281 	EV_KEY, KEY_REPLY,
282 	EV_KEY, KEY_FORWARDMAIL,
283 	EV_KEY, KEY_SAVE,
284 	EV_KEY, KEY_DOCUMENTS,
285 	EV_KEY, KEY_UNKNOWN,
286 	EV_KEY, KEY_VIDEO_NEXT,
287 	EV_KEY, KEY_BRIGHTNESS_ZERO,
288 	EV_KEY, BTN_0,
289 	EV_KEY, BTN_LEFT,
290 	EV_KEY, BTN_RIGHT,
291 	EV_KEY, BTN_MIDDLE,
292 	EV_KEY, BTN_SIDE,
293 	EV_KEY, BTN_EXTRA,
294 	EV_KEY, KEY_SELECT,
295 	EV_KEY, KEY_GOTO,
296 	EV_KEY, KEY_INFO,
297 	EV_KEY, KEY_PROGRAM,
298 	EV_KEY, KEY_PVR,
299 	EV_KEY, KEY_SUBTITLE,
300 	EV_KEY, KEY_ZOOM,
301 	EV_KEY, KEY_KEYBOARD,
302 	EV_KEY, KEY_PC,
303 	EV_KEY, KEY_TV,
304 	EV_KEY, KEY_TV2,
305 	EV_KEY, KEY_VCR,
306 	EV_KEY, KEY_VCR2,
307 	EV_KEY, KEY_SAT,
308 	EV_KEY, KEY_CD,
309 	EV_KEY, KEY_TAPE,
310 	EV_KEY, KEY_TUNER,
311 	EV_KEY, KEY_PLAYER,
312 	EV_KEY, KEY_DVD,
313 	EV_KEY, KEY_AUDIO,
314 	EV_KEY, KEY_VIDEO,
315 	EV_KEY, KEY_MEMO,
316 	EV_KEY, KEY_CALENDAR,
317 	EV_KEY, KEY_RED,
318 	EV_KEY, KEY_GREEN,
319 	EV_KEY, KEY_YELLOW,
320 	EV_KEY, KEY_BLUE,
321 	EV_KEY, KEY_CHANNELUP,
322 	EV_KEY, KEY_CHANNELDOWN,
323 	EV_KEY, KEY_LAST,
324 	EV_KEY, KEY_NEXT,
325 	EV_KEY, KEY_RESTART,
326 	EV_KEY, KEY_SLOW,
327 	EV_KEY, KEY_SHUFFLE,
328 	EV_KEY, KEY_PREVIOUS,
329 	EV_KEY, KEY_VIDEOPHONE,
330 	EV_KEY, KEY_GAMES,
331 	EV_KEY, KEY_ZOOMIN,
332 	EV_KEY, KEY_ZOOMOUT,
333 	EV_KEY, KEY_ZOOMRESET,
334 	EV_KEY, KEY_WORDPROCESSOR,
335 	EV_KEY, KEY_EDITOR,
336 	EV_KEY, KEY_SPREADSHEET,
337 	EV_KEY, KEY_GRAPHICSEDITOR,
338 	EV_KEY, KEY_PRESENTATION,
339 	EV_KEY, KEY_DATABASE,
340 	EV_KEY, KEY_NEWS,
341 	EV_KEY, KEY_VOICEMAIL,
342 	EV_KEY, KEY_ADDRESSBOOK,
343 	EV_KEY, KEY_MESSENGER,
344 	EV_KEY, KEY_DISPLAYTOGGLE,
345 	EV_KEY, KEY_SPELLCHECK,
346 	EV_KEY, KEY_LOGOFF,
347 	EV_KEY, KEY_MEDIA_REPEAT,
348 	EV_KEY, KEY_IMAGES,
349 	EV_KEY, 576,
350 	EV_KEY, 577,
351 	EV_KEY, 578,
352 	EV_KEY, 579,
353 	EV_KEY, 580,
354 	EV_KEY, 581,
355 	EV_KEY, 582,
356 	EV_KEY, 592,
357 	EV_KEY, 593,
358 	EV_KEY, 608,
359 	EV_KEY, 609,
360 	EV_KEY, 610,
361 	EV_KEY, 611,
362 	EV_KEY, 612,
363 	EV_KEY, 613,
364 	EV_LED, LED_NUML,
365 	EV_LED, LED_CAPSL,
366 	EV_LED, LED_SCROLLL,
367 	-1, -1,
368 };
369 
370 TEST_DEVICE("ms-surface-cover",
371 	.type = LITEST_MS_SURFACE_COVER,
372 	.features = LITEST_KEYS | LITEST_ABSOLUTE | LITEST_RELATIVE | LITEST_FAKE_MT | LITEST_BUTTON | LITEST_WHEEL,
373 	.interface = &interface,
374 
375 	.name = "Microsoft Surface Type Cover",
376 	.id = &input_id,
377 	.events = events,
378 	.absinfo = absinfo,
379 )
380