1/* 2 * Copyright © 2017 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 "litest.h" 27#include "litest-int.h" 28 29static struct input_event proximity_in[] = { 30 /* Note: this device does not send BTN_TOOL_PEN */ 31 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, 32 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, 33 /* Note: this device does not send tilt, despite claiming it has it */ 34 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, 35 { .type = EV_KEY, .code = LITEST_BTN_TOOL_AUTO, .value = LITEST_AUTO_ASSIGN }, 36 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, 37 { .type = -1, .code = -1 }, 38}; 39 40static struct input_event proximity_out[] = { 41 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, 42 { .type = -1, .code = -1 }, 43}; 44 45static struct input_event motion[] = { 46 { .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN }, 47 { .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN }, 48 /* Note: this device does not send tilt, despite claiming it has it */ 49 { .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN }, 50 { .type = EV_SYN, .code = SYN_REPORT, .value = 0 }, 51 { .type = -1, .code = -1 }, 52}; 53 54static int 55get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value) 56{ 57 switch (evcode) { 58 case ABS_PRESSURE: 59 *value = 100; 60 return 0; 61 } 62 return 1; 63} 64 65static struct litest_device_interface interface = { 66 .tablet_proximity_in_events = proximity_in, 67 .tablet_proximity_out_events = proximity_out, 68 .tablet_motion_events = motion, 69 70 .get_axis_default = get_axis_default, 71}; 72 73static struct input_absinfo absinfo[] = { 74 { ABS_X, 0, 5999, 0, 0, 26 }, 75 { ABS_Y, 0, 4499, 0, 0, 15 }, 76 { ABS_WHEEL, 0, 1023, 0, 0, 0 }, /* mute axis */ 77 { ABS_PRESSURE, 0, 1023, 0, 0, 0 }, 78 { ABS_TILT_X, -128, 127, 0, 0, 0 }, /* mute axis */ 79 { ABS_TILT_Y, -128, 127, 0, 0, 0 }, /* mute axis */ 80 { .value = -1 }, 81}; 82 83static struct input_id input_id = { 84 .bustype = 0x3, 85 .vendor = 0x8ca, 86 .product = 0x10, 87}; 88 89static int events[] = { 90 EV_KEY, KEY_ESC, 91 EV_KEY, KEY_F1, 92 EV_KEY, KEY_F2, 93 EV_KEY, KEY_F3, 94 EV_KEY, KEY_F4, 95 EV_KEY, KEY_F5, 96 EV_KEY, KEY_F6, 97 EV_KEY, KEY_F7, 98 EV_KEY, KEY_F8, 99 EV_KEY, KEY_F9, 100 EV_KEY, KEY_F10, 101 EV_KEY, KEY_F11, 102 EV_KEY, KEY_F12, 103 EV_KEY, KEY_STOP, 104 EV_KEY, KEY_AGAIN, 105 EV_KEY, KEY_PROPS, 106 EV_KEY, KEY_UNDO, 107 EV_KEY, KEY_FRONT, 108 EV_KEY, KEY_COPY, 109 EV_KEY, KEY_OPEN, 110 EV_KEY, KEY_PASTE, 111 EV_KEY, KEY_F13, 112 EV_KEY, KEY_F14, 113 EV_KEY, KEY_F15, 114 EV_KEY, KEY_F16, 115 EV_KEY, KEY_F17, 116 EV_KEY, KEY_F18, 117 EV_KEY, KEY_F19, 118 EV_KEY, KEY_F20, 119 EV_KEY, KEY_F21, 120 EV_KEY, KEY_F22, 121 EV_KEY, KEY_F23, 122 EV_KEY, KEY_F24, 123 EV_KEY, BTN_LEFT, 124 EV_KEY, BTN_RIGHT, 125 EV_KEY, BTN_MIDDLE, 126 EV_KEY, BTN_TOOL_PEN, 127 EV_KEY, BTN_TOOL_RUBBER, 128 EV_KEY, BTN_TOOL_BRUSH, 129 EV_KEY, BTN_TOOL_PENCIL, 130 EV_KEY, BTN_TOOL_AIRBRUSH, 131 EV_KEY, BTN_TOOL_MOUSE, 132 EV_KEY, BTN_TOOL_LENS, 133 EV_KEY, BTN_TOUCH, 134 EV_KEY, BTN_STYLUS, 135 EV_KEY, BTN_STYLUS2, 136 EV_REL, REL_X, 137 EV_REL, REL_Y, 138 EV_REL, REL_WHEEL, 139 EV_MSC, MSC_SERIAL, 140 -1, -1, 141}; 142 143TEST_DEVICE("aiptek-tablet", 144 .type = LITEST_AIPTEK, 145 .features = LITEST_TABLET | LITEST_HOVER | LITEST_FORCED_PROXOUT, 146 .interface = &interface, 147 148 .name = "Aiptek", 149 .id = &input_id, 150 .events = events, 151 .absinfo = absinfo, 152) 153