• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2019 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.h"
27 #include "litest-int.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_Z, .value = LITEST_AUTO_ASSIGN },
33 	{ .type = EV_ABS, .code = ABS_WHEEL, .value = 0 },
34 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
35 	{ .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
36 	{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
37 	{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
38 	{ .type = EV_ABS, .code = ABS_MISC, .value = 2083 },
39 	{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
40 	{ .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 1 },
41 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
42 	{ .type = -1, .code = -1 },
43 };
44 
45 static struct input_event proximity_out[] = {
46 	{ .type = EV_ABS, .code = ABS_X, .value = 0 },
47 	{ .type = EV_ABS, .code = ABS_Y, .value = 0 },
48 	{ .type = EV_ABS, .code = ABS_Z, .value = 0 },
49 	{ .type = EV_ABS, .code = ABS_WHEEL, .value = 0 },
50 	{ .type = EV_ABS, .code = ABS_DISTANCE, .value = 0 },
51 	{ .type = EV_ABS, .code = ABS_TILT_X, .value = 0 },
52 	{ .type = EV_ABS, .code = ABS_TILT_Y, .value = 0 },
53 	{ .type = EV_ABS, .code = ABS_MISC, .value = 0 },
54 	{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
55 	{ .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = 0 },
56 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
57 	{ .type = -1, .code = -1 },
58 };
59 
60 static struct input_event motion[] = {
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_ABS, .code = ABS_Z, .value = 0 },
64 	{ .type = EV_ABS, .code = ABS_WHEEL, .value = 0 },
65 	{ .type = EV_ABS, .code = ABS_DISTANCE, .value = LITEST_AUTO_ASSIGN },
66 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
67 	{ .type = EV_ABS, .code = ABS_TILT_X, .value = LITEST_AUTO_ASSIGN },
68 	{ .type = EV_ABS, .code = ABS_TILT_Y, .value = LITEST_AUTO_ASSIGN },
69 	{ .type = EV_MSC, .code = MSC_SERIAL, .value = 297797542 },
70 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
71 	{ .type = -1, .code = -1 },
72 };
73 
74 static int
get_axis_default(struct litest_device * d,unsigned int evcode,int32_t * value)75 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
76 {
77 	switch (evcode) {
78 	case ABS_Z:
79 	case ABS_TILT_X:
80 	case ABS_TILT_Y:
81 		*value = 0;
82 		return 0;
83 	case ABS_PRESSURE:
84 		*value = 100;
85 		return 0;
86 	case ABS_DISTANCE:
87 		*value = 0;
88 		return 0;
89 	}
90 	return 1;
91 }
92 
93 static struct litest_device_interface interface = {
94 	.tablet_proximity_in_events = proximity_in,
95 	.tablet_proximity_out_events = proximity_out,
96 	.tablet_motion_events = motion,
97 
98 	.get_axis_default = get_axis_default,
99 };
100 
101 static struct input_absinfo absinfo[] = {
102 	{ ABS_X, 0, 69920, 0, 0, 200 },
103 	{ ABS_Y, 0, 39980, 0, 0, 200 },
104 	{ ABS_Z, -900, 899, 0, 0, 287 },
105 	{ ABS_WHEEL, 0, 2047, 0, 0, 0 },
106 	{ ABS_PRESSURE, 0, 8191, 0, 0, 0 },
107 	{ ABS_DISTANCE, 0, 63, 1, 0, 0 },
108 	{ ABS_TILT_X, -64, 63, 1, 0, 57 },
109 	{ ABS_TILT_Y, -64, 63, 1, 0, 57 },
110 	{ ABS_MISC, 0, 0, 0, 0, 0 },
111 	{ .value = -1 },
112 };
113 
114 static struct input_id input_id = {
115 	.bustype = 0x3,
116 	.vendor = 0x56a,
117 	.product = 0x350,
118 	.version = 0xb,
119 };
120 
121 static int events[] = {
122 	EV_KEY, BTN_TOOL_PEN,
123 	EV_KEY, BTN_TOOL_RUBBER,
124 	EV_KEY, BTN_TOOL_BRUSH,
125 	EV_KEY, BTN_TOOL_PENCIL,
126 	EV_KEY, BTN_TOOL_AIRBRUSH,
127 	EV_KEY, BTN_TOUCH,
128 	EV_KEY, BTN_STYLUS,
129 	EV_KEY, BTN_STYLUS2,
130 	EV_KEY, BTN_STYLUS3,
131 	EV_MSC, MSC_SERIAL,
132 	INPUT_PROP_MAX, INPUT_PROP_DIRECT,
133 	-1, -1,
134 };
135 
136 TEST_DEVICE("wacom-cintiq-pro16-pen",
137 	.type = LITEST_WACOM_CINTIQ_PRO16_PEN,
138 	.features = LITEST_TABLET | LITEST_DISTANCE | LITEST_TOOL_SERIAL | LITEST_TILT | LITEST_DIRECT | LITEST_HOVER,
139 	.interface = &interface,
140 
141 	.name = "Wacom Cintiq Pro 16 Pen",
142 	.id = &input_id,
143 	.events = events,
144 	.absinfo = absinfo,
145 	.udev_properties = {
146 		{ "LIBINPUT_DEVICE_GROUP", "wacom-pro16-group" },
147 		{ NULL },
148 	},
149 )
150