Debian Codegraph @

test/litest-device-aiptek-tablet.c

raw
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-int.h"
27 #include "litest.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_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 /* This tablet doesn't report BTN_TOOL_PEN 0 on proximity out but I *think*
42 * it still reports pressure values of zero? Who knows, we'd have to
43 * get our hands on the tablet again. Meanwhile, let's force the
44 * pressure to zero at least so other tests don't have to guess.
45 */
46 { .type = EV_ABS, .code = ABS_PRESSURE, .value = 0 },
47 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
48 { .type = -1, .code = -1 },
49 };
50
51 static struct input_event motion[] = {
52 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
53 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
54 /* Note: this device does not send tilt, despite claiming it has it */
55 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
56 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
57 { .type = -1, .code = -1 },
58 };
59
60 static int
61 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
62 {
63 switch (evcode) {
64 case ABS_PRESSURE:
65 *value = 100;
66 return 0;
67 }
68 return 1;
69 }
70
71 static struct litest_device_interface interface = {
72 .tablet_proximity_in_events = proximity_in,
73 .tablet_proximity_out_events = proximity_out,
74 .tablet_motion_events = motion,
75
76 .get_axis_default = get_axis_default,
77 };
78
79 /* clang-format off */
80 static struct input_absinfo absinfo[] = {
81 { ABS_X, 0, 5999, 0, 0, 26 },
82 { ABS_Y, 0, 4499, 0, 0, 15 },
83 { ABS_WHEEL, 0, 1023, 0, 0, 0 }, /* mute axis */
84 { ABS_PRESSURE, 0, 1023, 0, 0, 0 },
85 { ABS_TILT_X, -128, 127, 0, 0, 0 }, /* mute axis */
86 { ABS_TILT_Y, -128, 127, 0, 0, 0 }, /* mute axis */
87 { .value = -1 },
88 };
89 /* clang-format on */
90
91 static struct input_id input_id = {
92 .bustype = 0x3,
93 .vendor = 0x8ca,
94 .product = 0x10,
95 };
96
97 /* clang-format off */
98 static int events[] = {
99 EV_KEY, KEY_ESC,
100 EV_KEY, KEY_F1,
101 EV_KEY, KEY_F2,
102 EV_KEY, KEY_F3,
103 EV_KEY, KEY_F4,
104 EV_KEY, KEY_F5,
105 EV_KEY, KEY_F6,
106 EV_KEY, KEY_F7,
107 EV_KEY, KEY_F8,
108 EV_KEY, KEY_F9,
109 EV_KEY, KEY_F10,
110 EV_KEY, KEY_F11,
111 EV_KEY, KEY_F12,
112 EV_KEY, KEY_STOP,
113 EV_KEY, KEY_AGAIN,
114 EV_KEY, KEY_PROPS,
115 EV_KEY, KEY_UNDO,
116 EV_KEY, KEY_FRONT,
117 EV_KEY, KEY_COPY,
118 EV_KEY, KEY_OPEN,
119 EV_KEY, KEY_PASTE,
120 EV_KEY, KEY_F13,
121 EV_KEY, KEY_F14,
122 EV_KEY, KEY_F15,
123 EV_KEY, KEY_F16,
124 EV_KEY, KEY_F17,
125 EV_KEY, KEY_F18,
126 EV_KEY, KEY_F19,
127 EV_KEY, KEY_F20,
128 EV_KEY, KEY_F21,
129 EV_KEY, KEY_F22,
130 EV_KEY, KEY_F23,
131 EV_KEY, KEY_F24,
132 EV_KEY, BTN_LEFT,
133 EV_KEY, BTN_RIGHT,
134 EV_KEY, BTN_MIDDLE,
135 EV_KEY, BTN_TOOL_PEN,
136 EV_KEY, BTN_TOOL_RUBBER,
137 EV_KEY, BTN_TOOL_BRUSH,
138 EV_KEY, BTN_TOOL_PENCIL,
139 EV_KEY, BTN_TOOL_AIRBRUSH,
140 EV_KEY, BTN_TOOL_MOUSE,
141 EV_KEY, BTN_TOOL_LENS,
142 EV_KEY, BTN_TOUCH,
143 EV_KEY, BTN_STYLUS,
144 EV_KEY, BTN_STYLUS2,
145 EV_REL, REL_X,
146 EV_REL, REL_Y,
147 EV_REL, REL_WHEEL,
148 EV_MSC, MSC_SERIAL,
149 -1, -1,
150 };
151 /* clang-format on */
152
153 TEST_DEVICE(LITEST_AIPTEK,
154 .features = LITEST_TABLET | LITEST_HOVER | LITEST_FORCED_PROXOUT,
155 .interface = &interface,
156
157 .name = "Aiptek",
158 .id = &input_id,
159 .events = events,
160 .absinfo = absinfo, )