Debian Codegraph @

test/litest-device-atmel-hover.c

raw
1 /*
2 * Copyright © 2015 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 <assert.h>
27
28 #include "libinput-util.h"
29 #include "litest-int.h"
30 #include "litest.h"
31
32 static struct input_event down[] = {
33 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
34 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
35 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
36 { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
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_DISTANCE, .value = LITEST_AUTO_ASSIGN },
41 { .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN },
42 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
43 { .type = -1, .code = -1 },
44 };
45
46 static struct input_event move[] = {
47 { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
48 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
49 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
50 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
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_DISTANCE, .value = LITEST_AUTO_ASSIGN },
54 { .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN },
55 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
56 { .type = -1, .code = -1 },
57 };
58
59 static struct input_event up[] = {
60 { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
61 { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
62 { .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = 1 },
63 { .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = 0 },
64 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
65 { .type = -1, .code = -1 },
66 };
67
68 static int
69 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
70 {
71 switch (evcode) {
72 case ABS_PRESSURE:
73 case ABS_MT_PRESSURE:
74 *value = 30;
75 return 0;
76 }
77 return 1;
78 }
79
80 static struct litest_device_interface interface = {
81 .touch_down_events = down,
82 .touch_move_events = move,
83 .touch_up_events = up,
84
85 .get_axis_default = get_axis_default,
86 };
87
88 static struct input_id input_id = {
89 .bustype = 0x18,
90 .vendor = 0x0,
91 .product = 0x0,
92 };
93
94 /* clang-format off */
95 static int events[] = {
96 EV_KEY, BTN_LEFT,
97 EV_KEY, BTN_TOOL_FINGER,
98 EV_KEY, BTN_TOUCH,
99 EV_KEY, BTN_TOOL_DOUBLETAP,
100 EV_KEY, BTN_TOOL_TRIPLETAP,
101 EV_KEY, BTN_TOOL_QUADTAP,
102 EV_KEY, BTN_TOOL_QUINTTAP,
103 INPUT_PROP_MAX, INPUT_PROP_POINTER,
104 INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
105 -1, -1,
106 };
107 /* clang-format on */
108
109 /* clang-format off */
110 static struct input_absinfo absinfo[] = {
111 { ABS_X, 0, 960, 0, 0, 10 },
112 { ABS_Y, 0, 540, 0, 0, 10 },
113 { ABS_PRESSURE, 0, 255, 0, 0, 0 },
114 { ABS_MT_SLOT, 0, 9, 0, 0, 0 },
115 { ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0, 0 },
116 { ABS_MT_ORIENTATION, 0, 255, 0, 0, 0 },
117 { ABS_MT_POSITION_X, 0, 960, 0, 0, 10 },
118 { ABS_MT_POSITION_Y, 0, 540, 0, 0, 10 },
119 { ABS_MT_TOOL_TYPE, 0, 2, 0, 0, 0 },
120 { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
121 { ABS_MT_PRESSURE, 0, 255, 0, 0, 0 },
122 { ABS_MT_DISTANCE, 0, 1, 0, 0, 0 },
123 { .value = -1 },
124 };
125 /* clang-format on */
126
127 TEST_DEVICE(LITEST_ATMEL_HOVER,
128 .features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_CLICKPAD |
129 LITEST_HOVER,
130 .interface = &interface,
131
132 .name = "Atmel maXTouch Touchpad",
133 .id = &input_id,
134 .events = events,
135 .absinfo = absinfo, )