Debian Codegraph @

test/litest-device-ploopy-pavonis-stylus.c

raw
1
2 /*
3 * Copyright © 2025 Red Hat, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 /* Device from https://gitlab.freedesktop.org/libinput/libinput/-/issues/1152 */
26
27 #include "config.h"
28
29 #include "litest-int.h"
30 #include "litest.h"
31
32 /*
33 * Copyright © 2014 Red Hat, Inc.
34 *
35 * Permission is hereby granted, free of charge, to any person obtaining a
36 * copy of this software and associated documentation files (the "Software"),
37 * to deal in the Software without restriction, including without limitation
38 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
39 * and/or sell copies of the Software, and to permit persons to whom the
40 * Software is furnished to do so, subject to the following conditions:
41 *
42 * The above copyright notice and this permission notice (including the next
43 * paragraph) shall be included in all copies or substantial portions of the
44 * Software.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
49 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
51 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
52 * DEALINGS IN THE SOFTWARE.
53 */
54
55 #include "config.h"
56
57 #include "litest-int.h"
58 #include "litest.h"
59
60 static struct input_event proximity_in[] = {
61 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
62 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
63 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
64 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
65 { .type = -1, .code = -1 },
66 };
67
68 static struct input_event proximity_out[] = {
69 { .type = EV_ABS, .code = ABS_X, .value = 0 },
70 { .type = EV_ABS, .code = ABS_Y, .value = 0 },
71 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
72 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
73 { .type = -1, .code = -1 },
74 };
75
76 static struct input_event motion[] = {
77 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
78 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
79 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
80 { .type = -1, .code = -1 },
81 };
82
83 static int
84 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
85 {
86 abort();
87 return 1;
88 }
89
90 static struct litest_device_interface interface = {
91 .tablet_proximity_in_events = proximity_in,
92 .tablet_proximity_out_events = proximity_out,
93 .tablet_motion_events = motion,
94
95 .get_axis_default = get_axis_default,
96 };
97
98 /* clang-format off */
99 static struct input_absinfo absinfo[] = {
100 { ABS_X, 0, 15600, 0, 0, 100 },
101 { ABS_Y, 0, 9900, 0, 0, 100 },
102 { .value = -1 },
103 };
104 /* clang-format on */
105
106 static struct input_id input_id = {
107 .bustype = 0x3,
108 .vendor = 0xfeed,
109 .product = 0x0000,
110 };
111
112 /* clang-format off */
113 static int events[] = {
114 EV_KEY, BTN_TOOL_PEN,
115 EV_KEY, BTN_TOUCH,
116 EV_KEY, BTN_STYLUS,
117 EV_MSC, MSC_SCAN,
118 INPUT_PROP_MAX, INPUT_PROP_DIRECT,
119 -1, -1,
120 };
121 /* clang-format on */
122
123 TEST_DEVICE(LITEST_PLOOPY_PAVONIS_STYLUS,
124 .features = LITEST_TABLET,
125 .interface = &interface,
126
127 .name = "Ploopy Corporation Ploopy Pavonis Trackpad Stylus",
128 .id = &input_id,
129 .events = events,
130 .absinfo = absinfo, )