Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/xorg/isdv4.h
$ cat -n /usr/include/xorg/isdv4.h 1 /* 2 * Copyright 2010 by Red Hat, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 20 #ifndef ISDV4_H 21 #define ISDV4_H 22 23 #include
24 #include
25 #include
26 27 #define ISDV4_QUERY "*" /* ISDV4 query command */ 28 #define ISDV4_RESET "&" /* ISDV4 touch panel reset command */ 29 #define ISDV4_TOUCH_QUERY "%" /* ISDV4 touch query command */ 30 #define ISDV4_STOP "0" /* ISDV4 stop command */ 31 #define ISDV4_SAMPLING "1" /* ISDV4 sampling command */ 32 33 /* packet length for individual models */ 34 #define ISDV4_PKGLEN_TOUCH93 5 35 #define ISDV4_PKGLEN_TOUCH9A 7 36 #define ISDV4_PKGLEN_TPCPEN 9 37 #define ISDV4_PKGLEN_TPCCTL 11 38 #define ISDV4_PKGLEN_TOUCH2FG 13 39 40 #define HEADER_BIT 0x80 41 #define CONTROL_BIT 0x40 42 #define DATA_ID_MASK 0x3F 43 #define TOUCH_CONTROL_BIT 0x10 44 45 /* Only for touch devices: use serial ID as index to get packet length for device */ 46 int ISDV4PacketLengths[] = { 47 /* 0x00 => */ ISDV4_PKGLEN_TOUCH93, 48 /* 0x01 => */ ISDV4_PKGLEN_TOUCH9A, 49 /* 0x02 => */ ISDV4_PKGLEN_TOUCH93, 50 /* 0x03 => */ ISDV4_PKGLEN_TOUCH9A, 51 /* 0x04 => */ ISDV4_PKGLEN_TOUCH9A, 52 /* 0x05 => */ ISDV4_PKGLEN_TOUCH2FG 53 }; 54 55 /* ISDV4 protocol parsing structs. */ 56 57 /* Query reply data */ 58 typedef struct { 59 unsigned char data_id; /* always 00H */ 60 uint16_t x_max; 61 uint16_t y_max; 62 uint16_t pressure_max; 63 uint8_t tilt_x_max; 64 uint8_t tilt_y_max; 65 uint16_t version; 66 } ISDV4QueryReply; 67 68 /* Touch Query reply data */ 69 typedef struct { 70 uint8_t data_id; /* always 01H */ 71 uint8_t panel_resolution; 72 uint8_t sensor_id; 73 uint16_t x_max; 74 uint16_t y_max; 75 uint8_t capacity_resolution; 76 uint16_t version; 77 } ISDV4TouchQueryReply; 78 79 /* Touch Data format. Note that capacity and finger2 are only set for some 80 * devices (0 on all others) */ 81 typedef struct { 82 uint8_t status; /* touch down/up */ 83 uint16_t x; 84 uint16_t y; 85 uint16_t capacity; 86 struct { 87 uint8_t status; /* touch down/up */ 88 uint16_t x; 89 uint16_t y; 90 } finger2; 91 } ISDV4TouchData; 92 93 /* Coordinate data format */ 94 typedef struct { 95 uint8_t proximity; /* in proximity? */ 96 uint8_t tip; /* tip/eraser pressed? */ 97 uint8_t side; /* side switch pressed? */ 98 uint8_t eraser; /* eraser pressed? */ 99 uint16_t x; 100 uint16_t y; 101 uint16_t pressure; 102 uint8_t tilt_x; 103 uint8_t tilt_y; 104 } ISDV4CoordinateData; 105 106 static inline int isdv4ParseQuery(const unsigned char *buffer, const size_t len, 107 ISDV4QueryReply *reply) 108 { 109 int header, control; 110 111 if (!reply || len < ISDV4_PKGLEN_TPCCTL) 112 return 0; 113 114 header = !!(buffer[0] & HEADER_BIT); 115 control = !!(buffer[0] & CONTROL_BIT); 116 117 if (!header || !control) 118 return -1; 119 120 reply->data_id = buffer[0] & DATA_ID_MASK; 121 122 /* FIXME: big endian? */ 123 reply->x_max = (buffer[1] << 9) | (buffer[2] << 2) | ((buffer[6] >> 5) & 0x3); 124 reply->y_max = (buffer[3] << 9) | (buffer[4] << 2) | ((buffer[6] >> 3) & 0x3); 125 reply->pressure_max = (buffer[6] & 0x7) << 7 | buffer[5]; 126 reply->tilt_y_max = buffer[7]; 127 reply->tilt_x_max = buffer[8]; 128 reply->version = buffer[9] << 7 | buffer[10]; 129 130 return ISDV4_PKGLEN_TPCCTL; 131 } 132 133 static inline int isdv4ParseTouchQuery(const unsigned char *buffer, const size_t len, 134 ISDV4TouchQueryReply *reply) 135 { 136 int header, control; 137 138 if (!reply || len < ISDV4_PKGLEN_TPCCTL) 139 return 0; 140 141 header = !!(buffer[0] & HEADER_BIT); 142 control = !!(buffer[0] & CONTROL_BIT); 143 144 if (!header || !control) 145 return -1; 146 147 reply->data_id = buffer[0] & DATA_ID_MASK; 148 reply->sensor_id = buffer[2] & 0x7; 149 reply->panel_resolution = buffer[1]; 150 /* FIXME: big endian? */ 151 reply->x_max = (buffer[3] << 9) | (buffer[4] << 2) | ((buffer[2] >> 5) & 0x3); 152 reply->y_max = (buffer[5] << 9) | (buffer[6] << 2) | ((buffer[2] >> 3) & 0x3); 153 reply->capacity_resolution = buffer[7]; 154 reply->version = buffer[9] << 7 | buffer[10]; 155 156 return ISDV4_PKGLEN_TPCCTL; 157 } 158 159 /* pktlen defines what touch type we parse */ 160 static inline int isdv4ParseTouchData(const unsigned char *buffer, const size_t buff_len, 161 const size_t pktlen, ISDV4TouchData *touchdata) 162 { 163 int header, touch; 164 165 if (!touchdata || buff_len < pktlen) 166 return 0; 167 168 header = !!(buffer[0] & HEADER_BIT); 169 touch = !!(buffer[0] & TOUCH_CONTROL_BIT); 170 171 if (header != 1 || touch != 1) 172 return -1; 173 174 memset(touchdata, 0, sizeof(*touchdata)); 175 176 touchdata->status = buffer[0] & 0x1; 177 /* FIXME: big endian */ 178 touchdata->x = buffer[1] << 7 | buffer[2]; 179 touchdata->y = buffer[3] << 7 | buffer[4]; 180 if (pktlen == ISDV4_PKGLEN_TOUCH9A) 181 touchdata->capacity = buffer[5] << 7 | buffer[6]; 182 183 if (pktlen == ISDV4_PKGLEN_TOUCH2FG) 184 { 185 touchdata->finger2.x = buffer[7] << 7 | buffer[8]; 186 touchdata->finger2.y = buffer[9] << 7 | buffer[10]; 187 touchdata->finger2.status = !!(buffer[0] & 0x2); 188 /* FIXME: is there a fg2 capacity? */ 189 } 190 191 return pktlen; 192 } 193 194 static inline int isdv4ParseCoordinateData(const unsigned char *buffer, const size_t len, 195 ISDV4CoordinateData *coord) 196 { 197 int header, control; 198 199 if (!coord || len < ISDV4_PKGLEN_TPCPEN) 200 return 0; 201 202 header = !!(buffer[0] & HEADER_BIT); 203 control = !!(buffer[0] & TOUCH_CONTROL_BIT); 204 205 if (header != 1 || control != 0) 206 return -1; 207 208 coord->proximity = (buffer[0] >> 5) & 0x1; 209 coord->tip = buffer[0] & 0x1; 210 coord->side = (buffer[0] >> 1) & 0x1; 211 coord->eraser = (buffer[0] >> 2) & 0x1; 212 /* FIXME: big endian */ 213 coord->x = (buffer[1] << 9) | (buffer[2] << 2) | ((buffer[6] >> 5) & 0x3); 214 coord->y = (buffer[3] << 9) | (buffer[4] << 2) | ((buffer[6] >> 3) & 0x3); 215 216 coord->pressure = ((buffer[6] & 0x7) << 7) | buffer[5]; 217 coord->tilt_x = buffer[7]; 218 coord->tilt_y = buffer[8]; 219 220 return ISDV4_PKGLEN_TPCPEN; 221 } 222 223 #endif /* ISDV4_H */ 224 225 /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™