Debian Codegraph @

test/litest-device-vmware-virtual-usb-mouse.c

raw
1 /*
2 * Copyright © 2014 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 "litest-int.h"
29 #include "litest.h"
30
31 static bool
32 touch_down(struct litest_device *d, unsigned int slot, double x, double y)
33 {
34 assert(slot == 0);
35
36 litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x));
37 litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y));
38 litest_event(d, EV_SYN, SYN_REPORT, 0);
39
40 return true; /* we handled the event */
41 }
42
43 static bool
44 touch_move(struct litest_device *d, unsigned int slot, double x, double y)
45 {
46 assert(slot == 0);
47
48 litest_event(d, EV_ABS, ABS_X, litest_scale(d, ABS_X, x));
49 litest_event(d, EV_ABS, ABS_Y, litest_scale(d, ABS_Y, y));
50 litest_event(d, EV_SYN, SYN_REPORT, 0);
51
52 return true; /* we handled the event */
53 }
54
55 static bool
56 touch_up(struct litest_device *d, unsigned int slot)
57 {
58 assert(slot == 0);
59 litest_event(d, EV_SYN, SYN_REPORT, 0);
60
61 return true; /* we handled the event */
62 }
63
64 static struct litest_device_interface interface = {
65 .touch_down = touch_down,
66 .touch_move = touch_move,
67 .touch_up = touch_up,
68 };
69
70 /* clang-format off */
71 static struct input_absinfo absinfo[] = {
72 { ABS_X, 0, 32767, 0, 0, 0 },
73 { ABS_Y, 0, 32767, 0, 0, 0 },
74 { .value = -1 },
75 };
76 /* clang-format on */
77
78 static struct input_id input_id = {
79 .bustype = 0x03,
80 .vendor = 0xe0f,
81 .product = 0x03,
82 };
83
84 /* clang-format off */
85 static int events[] = {
86 EV_KEY, BTN_LEFT,
87 EV_KEY, BTN_RIGHT,
88 EV_KEY, BTN_MIDDLE,
89 EV_KEY, BTN_SIDE,
90 EV_KEY, BTN_EXTRA,
91 EV_KEY, BTN_FORWARD,
92 EV_KEY, BTN_BACK,
93 EV_KEY, BTN_TASK,
94 EV_KEY, 280,
95 EV_KEY, 281,
96 EV_KEY, 282,
97 EV_KEY, 283,
98 EV_KEY, 284,
99 EV_KEY, 285,
100 EV_KEY, 286,
101 EV_KEY, 287,
102 EV_REL, REL_WHEEL,
103 EV_REL, REL_HWHEEL,
104 -1, -1,
105 };
106 /* clang-format on */
107
108 TEST_DEVICE(LITEST_VMWARE_VIRTMOUSE,
109 .features = LITEST_WHEEL | LITEST_BUTTON | LITEST_ABSOLUTE |
110 LITEST_NO_DEBOUNCE,
111 .interface = &interface,
112
113 .name = "VMware VMware Virtual USB Mouse",
114 .id = &input_id,
115 .events = events,
116 .absinfo = absinfo, )