touchpad: normalize the touchpad resolution to 400dpi, not 10 units/mm
[platform/upstream/libinput.git] / test / litest-synaptics-st.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_touchpad_setup(void)
32 {
33         struct litest_device *d = litest_create_device(LITEST_SYNAPTICS_TOUCHPAD);
34         litest_set_current_device(d);
35 }
36
37 static struct input_event down[] = {
38         { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
39         { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
40         { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
41         { .type = EV_ABS, .code = ABS_PRESSURE, .value = 30  },
42         { .type = EV_ABS, .code = ABS_TOOL_WIDTH, .value = 7  },
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_X, .value = LITEST_AUTO_ASSIGN },
49         { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
50         { .type = EV_KEY, .code = BTN_TOUCH, .value = 1 },
51         { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
52         { .type = -1, .code = -1 },
53 };
54
55 struct input_event up[] = {
56         { .type = EV_KEY, .code = BTN_TOUCH, .value = 0 },
57         { .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
58         { .type = -1, .code = -1 },
59 };
60
61 static struct litest_device_interface interface = {
62         .touch_down_events = down,
63         .touch_move_events = move,
64         .touch_up_events = up,
65 };
66
67 static struct input_absinfo absinfo[] = {
68         { ABS_X, 1472, 5472, 0, 0, 75 },
69         { ABS_Y, 1408, 4448, 0, 0, 129 },
70         { ABS_PRESSURE, 0, 255, 0, 0, 0 },
71         { ABS_TOOL_WIDTH, 0, 15, 0, 0, 0 },
72         { .value = -1 },
73 };
74
75 static struct input_id input_id = {
76         .bustype = 0x11,
77         .vendor = 0x2,
78         .product = 0x7,
79 };
80
81 static int events[] = {
82         EV_KEY, BTN_LEFT,
83         EV_KEY, BTN_RIGHT,
84         EV_KEY, BTN_TOOL_FINGER,
85         EV_KEY, BTN_TOUCH,
86         -1, -1,
87 };
88
89 struct litest_test_device litest_synaptics_touchpad_device = {
90         .type = LITEST_SYNAPTICS_TOUCHPAD,
91         .features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH,
92         .shortname = "synaptics ST",
93         .setup = litest_synaptics_touchpad_setup,
94         .interface = &interface,
95
96         .name = "SynPS/2 Synaptics TouchPad",
97         .id = &input_id,
98         .events = events,
99         .absinfo = absinfo,
100 };