touchpad: normalize the touchpad resolution to 400dpi, not 10 units/mm
[platform/upstream/libinput.git] / test / litest-int.h
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 #include <limits.h>
27
28 #ifndef LITEST_INT_H
29 #define LITEST_INT_H
30 #include "litest.h"
31
32 /* Use as designater for litest to change the value */
33 #define LITEST_AUTO_ASSIGN INT_MIN
34
35 struct litest_test_device {
36        enum litest_device_type type;
37        enum litest_device_feature features;
38        const char *shortname;
39        void (*setup)(void); /* test fixture, used by check */
40        void (*teardown)(void); /* test fixture, used by check */
41        /**
42         * If create is non-NULL it will be called to initialize the device.
43         * For such devices, no overrides are possible. If create is NULL,
44         * the information in name, id, events, absinfo is used to
45         * create the device instead.
46         */
47        void (*create)(struct litest_device *d);
48
49        /**
50         * The device name. Only used when create is NULL.
51         */
52        const char *name;
53        /**
54         * The device id. Only used when create is NULL.
55         */
56        const struct input_id *id;
57        /**
58         * List of event type/code tuples, terminated with -1, e.g.
59         * EV_REL, REL_X, EV_KEY, BTN_LEFT, -1
60         * Special tuple is INPUT_PROP_MAX, <actual property> to set.
61         *
62         * Any EV_ABS codes in this list will be initialized with a default
63         * axis range.
64         */
65        int *events;
66        /**
67         * List of abs codes to enable, with absinfo.value determining the
68         * code to set. List must be terminated with absinfo.value -1
69         */
70        struct input_absinfo *absinfo;
71        struct litest_device_interface *interface;
72 };
73
74 struct litest_device_interface {
75         void (*touch_down)(struct litest_device *d, unsigned int slot, int x, int y);
76         void (*touch_move)(struct litest_device *d, unsigned int slot, int x, int y);
77         void (*touch_up)(struct litest_device *d, unsigned int slot);
78
79         /**
80          * Set of of events to execute on touch down, terminated by a .type
81          * and .code value of -1. If the event value is LITEST_AUTO_ASSIGN,
82          * it will be automatically assigned by the framework (valid for x,
83          * y, tracking id and slot).
84          *
85          * These events are only used if touch_down is NULL.
86          */
87         struct input_event *touch_down_events;
88         struct input_event *touch_move_events;
89         struct input_event *touch_up_events;
90
91         int min[2];
92         int max[2];
93 };
94
95 void litest_set_current_device(struct litest_device *device);
96 int litest_scale(const struct litest_device *d, unsigned int axis, int val);
97 void litest_generic_device_teardown(void);
98
99 #endif