Debian Codegraph @

test/litest-device-dell-canvas-totem.c

raw
1 /*
2 * Copyright © 2018 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 /* We don't expect anything but slot 0 to be used, ever */
30 #define TOTEM_SLOT 0
31
32 static struct input_event down[] = {
33 { .type = EV_ABS, .code = ABS_MT_SLOT, .value = TOTEM_SLOT },
34 { .type = EV_ABS,
35 .code = ABS_MT_TOOL_TYPE,
36 .value = MT_TOOL_DIAL }, /* fixed value in device */
37 { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
38 { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
39 { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
40 { .type = EV_ABS, .code = ABS_MT_ORIENTATION, .value = LITEST_AUTO_ASSIGN },
41 { .type = EV_ABS,
42 .code = ABS_MT_TOUCH_MAJOR,
43 .value = 718 }, /* fixed value in device */
44 { .type = EV_ABS, .code = ABS_MT_TOUCH_MINOR, .value = 718 },
45 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
46 { .type = -1, .code = -1 },
47 };
48
49 static struct input_event move[] = {
50 { .type = EV_ABS, .code = ABS_MT_SLOT, .value = TOTEM_SLOT },
51 { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
52 { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
53 { .type = EV_ABS, .code = ABS_MT_ORIENTATION, .value = LITEST_AUTO_ASSIGN },
54 { .type = EV_ABS,
55 .code = ABS_MT_TOUCH_MAJOR,
56 .value = 718 }, /* fixed value in device */
57 { .type = EV_ABS, .code = ABS_MT_TOUCH_MINOR, .value = 718 },
58 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
59 { .type = -1, .code = -1 },
60 };
61
62 static struct input_event up[] = {
63 { .type = EV_ABS, .code = ABS_MT_SLOT, .value = TOTEM_SLOT },
64 { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
65 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
66 { .type = -1, .code = -1 },
67 };
68
69 static int
70 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
71 {
72 switch (evcode) {
73 case ABS_MT_ORIENTATION:
74 *value = 0;
75 return 0;
76 }
77 return 1;
78 }
79
80 static struct litest_device_interface interface = {
81 .tablet_proximity_in_events = down,
82 .tablet_proximity_out_events = up,
83 .tablet_motion_events = move,
84
85 .get_axis_default = get_axis_default,
86 };
87
88 /* clang-format off */
89 static struct input_absinfo absinfo[] = {
90 { ABS_MT_SLOT, 0, 4, 0, 0, 0 },
91 { ABS_MT_TOUCH_MAJOR, 0, 32767, 0, 0, 10 },
92 { ABS_MT_TOUCH_MINOR, 0, 32767, 0, 0, 10 },
93 { ABS_MT_ORIENTATION, -89, 89, 0, 0, 0 },
94 { ABS_MT_POSITION_X, 0, 32767, 0, 0, 55 },
95 { ABS_MT_POSITION_Y, 0, 32767, 0, 0, 98 },
96 /* The real device has a min/max of 10/10 but uinput didn't allow
97 * this */
98 { ABS_MT_TOOL_TYPE, 9, 10, 0, 0, 0 },
99 { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
100 { .value = -1 },
101 };
102 /* clang-format on */
103
104 static struct input_id input_id = {
105 .bustype = 0x3,
106 .vendor = 0x2575,
107 .product = 0x0204,
108 .version = 0x111,
109 };
110
111 /* clang-format off */
112 static int events[] = {
113 EV_KEY, BTN_0,
114 EV_MSC, MSC_TIMESTAMP,
115 INPUT_PROP_MAX, INPUT_PROP_DIRECT,
116 -1, -1,
117 };
118 /* clang-format on */
119
120 TEST_DEVICE(LITEST_DELL_CANVAS_TOTEM,
121 .features = LITEST_TOTEM | LITEST_TABLET,
122 .interface = &interface,
123
124 .name = "Advanced Silicon S.A. CoolTouch® System System Multi Axis",
125 .id = &input_id,
126 .events = events,
127 .absinfo = absinfo,
128 .udev_properties = {
129 { "LIBINPUT_DEVICE_GROUP", "dell-canvas-totem-group" },
130 { NULL },
131 }, )