1 /* 2 * Copyright © 2013 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 #include <limits.h> 26 27 #ifndef LITEST_INT_H 28 #define LITEST_INT_H 29 #include "litest.h" 30 31 /* Use as designater for litest to change the value */ 32 #define LITEST_AUTO_ASSIGN INT_MIN 33 34 struct litest_test_device { 35 struct list node; /* global test device list */ 36 37 enum litest_device_type type; 38 int64_t features; 39 const char *shortname; 40 void (*setup)(void); /* test fixture, used by check */ 41 void (*teardown)(void); /* test fixture, used by check */ 42 /** 43 * If create is non-NULL it will be called to initialize the device. 44 * For such devices, no overrides are possible. If create is NULL, 45 * the information in name, id, events, absinfo is used to 46 * create the device instead. 47 * 48 * @return true if the device needs to be created by litest, false if 49 * the device creates itself 50 */ 51 bool (*create)(struct litest_device *d); 52 53 /** 54 * The device name. Only used when create is NULL. 55 */ 56 const char *name; 57 /** 58 * The device id. Only used when create is NULL. 59 */ 60 const struct input_id *id; 61 /** 62 * List of event type/code tuples, terminated with -1, e.g. 63 * EV_REL, REL_X, EV_KEY, BTN_LEFT, -1 64 * Special tuple is INPUT_PROP_MAX, <actual property> to set. 65 * 66 * Any EV_ABS codes in this list will be initialized with a default 67 * axis range. 68 */ 69 int *events; 70 /** 71 * List of abs codes to enable, with absinfo.value determining the 72 * code to set. List must be terminated with absinfo.value -1 73 */ 74 struct input_absinfo *absinfo; 75 struct litest_device_interface *interface; 76 77 const char *udev_rule; 78 const char *quirk_file; 79 80 const struct key_value_str udev_properties[32]; 81 }; 82 83 struct litest_device_interface { 84 bool (*touch_down)(struct litest_device *d, unsigned int slot, double x, double y); 85 bool (*touch_move)(struct litest_device *d, unsigned int slot, double x, double y); 86 bool (*touch_up)(struct litest_device *d, unsigned int slot); 87 88 /** 89 * Default value for the given EV_ABS axis. 90 * @return 0 on success, nonzero otherwise 91 */ 92 int (*get_axis_default)(struct litest_device *d, unsigned int code, int32_t *value); 93 94 /** 95 * Set of of events to execute on touch down, terminated by a .type 96 * and .code value of -1. If the event value is LITEST_AUTO_ASSIGN, 97 * it will be automatically assigned by the framework (valid for x, 98 * y, tracking id and slot). 99 * 100 * These events are only used if touch_down is NULL. 101 */ 102 struct input_event *touch_down_events; 103 struct input_event *touch_move_events; 104 struct input_event *touch_up_events; 105 106 /** 107 * Tablet events, LITEST_AUTO_ASSIGN is allowed on event values for 108 * ABS_X, ABS_Y, ABS_DISTANCE and ABS_PRESSURE. 109 */ 110 struct input_event *tablet_proximity_in_events; 111 struct input_event *tablet_proximity_out_events; 112 struct input_event *tablet_motion_events; 113 114 /** 115 * Pad events, LITEST_AUTO_ASSIGN is allowed on event values 116 * for ABS_WHEEL 117 */ 118 struct input_event *pad_ring_start_events; 119 struct input_event *pad_ring_change_events; 120 struct input_event *pad_ring_end_events; 121 122 /** 123 * Pad events, LITEST_AUTO_ASSIGN is allowed on event values 124 * for ABS_RX 125 */ 126 struct input_event *pad_strip_start_events; 127 struct input_event *pad_strip_change_events; 128 struct input_event *pad_strip_end_events; 129 130 int min[2]; /* x/y axis minimum */ 131 int max[2]; /* x/y axis maximum */ 132 }; 133 134 struct path { 135 struct list link; 136 char *path; 137 int fd; 138 }; 139 140 struct litest_context { 141 struct list paths; 142 }; 143 144 void litest_set_current_device(struct litest_device *device); 145 int litest_scale(const struct litest_device *d, unsigned int axis, double val); 146 void litest_generic_device_teardown(void); 147 148 #endif 149