Debian Codegraph @

test/litest-device-wacom-hid4800-pen.c

raw
1 /*
2 * Copyright © 2016 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 { .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_PRESSURE, .value = LITEST_AUTO_ASSIGN },
33 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
34 { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
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_ABS, .code = ABS_X, .value = 0 },
41 { .type = EV_ABS, .code = ABS_Y, .value = 0 },
42 { .type = EV_ABS, .code = ABS_PRESSURE, .value = 0 },
43 { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
44 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
45 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
46 { .type = -1, .code = -1 },
47 };
48
49 static struct input_event motion[] = {
50 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
51 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
52 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
53 { .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
54 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
55 { .type = -1, .code = -1 },
56 };
57
58 static int
59 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
60 {
61 switch (evcode) {
62 case ABS_PRESSURE:
63 *value = 100;
64 return 0;
65 }
66 return 1;
67 }
68
69 static struct litest_device_interface interface = {
70 .tablet_proximity_in_events = proximity_in,
71 .tablet_proximity_out_events = proximity_out,
72 .tablet_motion_events = motion,
73
74 .get_axis_default = get_axis_default,
75 };
76
77 /* clang-format off */
78 static struct input_absinfo absinfo[] = {
79 { ABS_X, 0, 21696, 4, 0, 100 },
80 { ABS_Y, 0, 13560, 4, 0, 100 },
81 { ABS_PRESSURE, 0, 2047, 0, 0, 0 },
82 { .value = -1 },
83 };
84 /* clang-format on */
85
86 static struct input_id input_id = {
87 .bustype = 0x18,
88 .vendor = 0x56a,
89 .product = 0x4800,
90 .version = 0x100,
91 };
92
93 /* clang-format off */
94 static int events[] = {
95 EV_KEY, BTN_TOOL_PEN,
96 EV_KEY, BTN_TOOL_RUBBER,
97 EV_KEY, BTN_TOUCH,
98 EV_KEY, BTN_STYLUS,
99 EV_KEY, BTN_STYLUS2,
100 EV_MSC, MSC_SERIAL,
101 INPUT_PROP_MAX, INPUT_PROP_DIRECT,
102 -1, -1,
103 };
104 /* clang-format on */
105
106 TEST_DEVICE(LITEST_WACOM_HID4800_PEN,
107 .features = LITEST_TABLET | LITEST_HOVER,
108 .interface = &interface,
109
110 .name = "Wacom HID 4800 Pen",
111 .id = &input_id,
112 .events = events,
113 .absinfo = absinfo, )