touchpad: normalize the touchpad resolution to 400dpi, not 10 units/mm
[platform/upstream/libinput.git] / test / litest-synaptics.c
1 /*
2  * Copyright © 2013 Red Hat, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that copyright
7  * notice and this permission notice appear in supporting documentation, and
8  * that the name of the copyright holders not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  The copyright holders make no representations
11  * about the suitability of this software for any purpose.  It is provided "as
12  * is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20  * OF THIS SOFTWARE.
21  */
22
23 #if HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include "litest.h"
28 #include "litest-int.h"
29
30 static void
31 litest_synaptics_clickpad_setup(void)
32 {
33         struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_CLICKPAD);
34         litest_set_current_device(d);
35 }
36
37 static struct input_event down[] = {
38         { .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 },
39         { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
40         { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
41         { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
42         { .type = EV_ABS, .code = ABS_PRESSURE, .value = 30  },
43         { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
44         { .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
45         { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
46         { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
47         { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
48         { .type = -1, .code = -1 },
49 };
50
51 static struct input_event move[] = {
52         { .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
53         { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN  },
54         { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
55         { .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
56         { .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
57         { .type = EV_KEY, .code = BTN_TOOL_FINGER, .value = 1 },
58         { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
59         { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
60         { .type = -1, .code = -1 },
61 };
62
63 static struct litest_device_interface interface = {
64         .touch_down_events = down,
65         .touch_move_events = move,
66 };
67
68 static struct input_id input_id = {
69         .bustype = 0x11,
70         .vendor = 0x2,
71         .product = 0x11,
72 };
73
74 static int events[] = {
75         EV_KEY, BTN_LEFT,
76         EV_KEY, BTN_TOOL_FINGER,
77         EV_KEY, BTN_TOOL_QUINTTAP,
78         EV_KEY, BTN_TOUCH,
79         EV_KEY, BTN_TOOL_DOUBLETAP,
80         EV_KEY, BTN_TOOL_TRIPLETAP,
81         EV_KEY, BTN_TOOL_QUADTAP,
82         INPUT_PROP_MAX, INPUT_PROP_POINTER,
83         INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
84         -1, -1,
85 };
86
87 static struct input_absinfo absinfo[] = {
88         { ABS_X, 1472, 5472, 0, 0, 75 },
89         { ABS_Y, 1408, 4448, 0, 0, 129 },
90         { ABS_PRESSURE, 0, 255, 0, 0, 0 },
91         { ABS_TOOL_WIDTH, 0, 15, 0, 0, 0 },
92         { ABS_MT_SLOT, 0, 1, 0, 0, 0 },
93         { ABS_MT_POSITION_X, 1472, 5472, 0, 0, 75 },
94         { ABS_MT_POSITION_Y, 1408, 4448, 0, 0, 129 },
95         { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
96         { ABS_MT_PRESSURE, 0, 255, 0, 0, 0 },
97         { .value = -1 }
98 };
99
100 struct litest_test_device litest_synaptics_clickpad_device = {
101         .type = LITEST_SYNAPTICS_CLICKPAD,
102         .features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
103         .shortname = "synaptics",
104         .setup = litest_synaptics_clickpad_setup,
105         .interface = &interface,
106
107         .name = "SynPS/2 Synaptics TouchPad",
108         .id = &input_id,
109         .events = events,
110         .absinfo = absinfo,
111 };