• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
30 #include "litest.h"
31 #include "litest-int.h"
32 
33 static struct input_event down[] = {
34 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
35 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
36 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN  },
37 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
38 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
39 	{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
40 	{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
41 	{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = LITEST_AUTO_ASSIGN },
42 	{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN  },
43 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
44 	{ .type = -1, .code = -1 },
45 };
46 
47 static struct input_event move[] = {
48 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
49 	{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
50 	{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
51 	{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN  },
52 	{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
53 	{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
54 	{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = LITEST_AUTO_ASSIGN },
55 	{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN  },
56 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
57 	{ .type = -1, .code = -1 },
58 };
59 
60 static struct input_event up[] = {
61 	{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
62 	{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
63 	{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = 1 },
64 	{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = 0  },
65 	{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
66 	{ .type = -1, .code = -1 },
67 };
68 
69 static int
get_axis_default(struct litest_device * d,unsigned int evcode,int32_t * value)70 get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
71 {
72 	switch (evcode) {
73 	case ABS_PRESSURE:
74 	case ABS_MT_PRESSURE:
75 		*value = 30;
76 		return 0;
77 	}
78 	return 1;
79 }
80 
81 static struct litest_device_interface interface = {
82 	.touch_down_events = down,
83 	.touch_move_events = move,
84 	.touch_up_events = up,
85 
86 	.get_axis_default = get_axis_default,
87 };
88 
89 static struct input_id input_id = {
90 	.bustype = 0x18,
91 	.vendor = 0x0,
92 	.product = 0x0,
93 };
94 
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 
108 static struct input_absinfo absinfo[] = {
109 	{ ABS_X, 0, 960, 0, 0, 10 },
110 	{ ABS_Y, 0, 540, 0, 0, 10 },
111 	{ ABS_PRESSURE, 0, 255, 0, 0, 0 },
112 	{ ABS_MT_SLOT, 0, 9, 0, 0, 0 },
113 	{ ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0, 0 },
114 	{ ABS_MT_ORIENTATION, 0, 255, 0, 0, 0 },
115 	{ ABS_MT_POSITION_X, 0, 960, 0, 0, 10 },
116 	{ ABS_MT_POSITION_Y, 0, 540, 0, 0, 10 },
117 	{ ABS_MT_TOOL_TYPE, 0, 2, 0, 0, 0 },
118 	{ ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
119 	{ ABS_MT_PRESSURE, 0, 255, 0, 0, 0 },
120 	{ ABS_MT_DISTANCE, 0, 1, 0, 0, 0 },
121 	{ .value = -1 }
122 };
123 
124 TEST_DEVICE("atmel-hover",
125 	.type = LITEST_ATMEL_HOVER,
126 	.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_CLICKPAD | LITEST_HOVER,
127 	.interface = &interface,
128 
129 	.name = "Atmel maXTouch Touchpad",
130 	.id = &input_id,
131 	.events = events,
132 	.absinfo = absinfo,
133 )
134