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