• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2017 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 	/* Note: this device does not send BTN_TOOL_PEN */
31 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
32 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
33 	/* Note: this device does not send tilt, despite claiming it has it */
34 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
35 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
36 	{ .type = -1, .code = -1 },
37 };
38 
39 static struct input_event proximity_out[] = {
40 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
41 	{ .type = -1, .code = -1 },
42 };
43 
44 static struct input_event motion[] = {
45 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
46 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
47 	/* Note: this device does not send tilt, despite claiming it has it */
48 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
49 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
50 	{ .type = -1, .code = -1 },
51 };
52 
53 static int
get_axis_default(struct litest_device * d,unsigned int evcode,int32_t * value)54 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
55 {
56 	switch (evcode) {
57 	case ABS_PRESSURE:
58 		*value = 100;
59 		return 0;
60 	}
61 	return 1;
62 }
63 
64 static struct litest_device_interface interface = {
65 	.tablet_proximity_in_events = proximity_in,
66 	.tablet_proximity_out_events = proximity_out,
67 	.tablet_motion_events = motion,
68 
69 	.get_axis_default = get_axis_default,
70 };
71 
72 static struct input_absinfo absinfo[] = {
73 	{ ABS_X, 0, 5999, 0, 0, 26 },
74 	{ ABS_Y, 0, 4499, 0, 0, 15 },
75 	{ ABS_WHEEL, 0, 1023, 0, 0, 0 }, /* mute axis */
76 	{ ABS_PRESSURE, 0, 1023, 0, 0, 0 },
77 	{ ABS_TILT_X, -128, 127, 0, 0, 0 }, /* mute axis */
78 	{ ABS_TILT_Y, -128, 127, 0, 0, 0 }, /* mute axis */
79 	{ .value = -1 },
80 };
81 
82 static struct input_id input_id = {
83 	.bustype = 0x3,
84 	.vendor = 0x8ca,
85 	.product = 0x10,
86 };
87 
88 static int events[] = {
89 	EV_KEY, KEY_ESC,
90 	EV_KEY, KEY_F1,
91 	EV_KEY, KEY_F2,
92 	EV_KEY, KEY_F3,
93 	EV_KEY, KEY_F4,
94 	EV_KEY, KEY_F5,
95 	EV_KEY, KEY_F6,
96 	EV_KEY, KEY_F7,
97 	EV_KEY, KEY_F8,
98 	EV_KEY, KEY_F9,
99 	EV_KEY, KEY_F10,
100 	EV_KEY, KEY_F11,
101 	EV_KEY, KEY_F12,
102 	EV_KEY, KEY_STOP,
103 	EV_KEY, KEY_AGAIN,
104 	EV_KEY, KEY_PROPS,
105 	EV_KEY, KEY_UNDO,
106 	EV_KEY, KEY_FRONT,
107 	EV_KEY, KEY_COPY,
108 	EV_KEY, KEY_OPEN,
109 	EV_KEY, KEY_PASTE,
110 	EV_KEY, KEY_F13,
111 	EV_KEY, KEY_F14,
112 	EV_KEY, KEY_F15,
113 	EV_KEY, KEY_F16,
114 	EV_KEY, KEY_F17,
115 	EV_KEY, KEY_F18,
116 	EV_KEY, KEY_F19,
117 	EV_KEY, KEY_F20,
118 	EV_KEY, KEY_F21,
119 	EV_KEY, KEY_F22,
120 	EV_KEY, KEY_F23,
121 	EV_KEY, KEY_F24,
122 	EV_KEY, BTN_LEFT,
123 	EV_KEY, BTN_RIGHT,
124 	EV_KEY, BTN_MIDDLE,
125 	EV_KEY, BTN_TOOL_PEN,
126 	EV_KEY, BTN_TOOL_RUBBER,
127 	EV_KEY, BTN_TOOL_BRUSH,
128 	EV_KEY, BTN_TOOL_PENCIL,
129 	EV_KEY, BTN_TOOL_AIRBRUSH,
130 	EV_KEY, BTN_TOOL_MOUSE,
131 	EV_KEY, BTN_TOOL_LENS,
132 	EV_KEY, BTN_TOUCH,
133 	EV_KEY, BTN_STYLUS,
134 	EV_KEY, BTN_STYLUS2,
135 	EV_REL, REL_X,
136 	EV_REL, REL_Y,
137 	EV_REL, REL_WHEEL,
138 	EV_MSC, MSC_SERIAL,
139 	-1, -1,
140 };
141 
142 TEST_DEVICE("aiptek-tablet",
143 	.type = LITEST_AIPTEK,
144 	.features = LITEST_TABLET | LITEST_HOVER | LITEST_FORCED_PROXOUT,
145 	.interface = &interface,
146 
147 	.name = "Aiptek",
148 	.id = &input_id,
149 	.events = events,
150 	.absinfo = absinfo,
151 )
152