Mercurial > sdl-ios-xcode
comparison src/video/fbcon/SDL_fbelo.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
43 static int ELO_MAX_X = 3670; | 43 static int ELO_MAX_X = 3670; |
44 static int ELO_MIN_Y = 500; | 44 static int ELO_MIN_Y = 500; |
45 static int ELO_MAX_Y = 3540; | 45 static int ELO_MAX_Y = 3540; |
46 | 46 |
47 #define ELO_SNAP_SIZE 6 | 47 #define ELO_SNAP_SIZE 6 |
48 #define ELO_TOUCH_BYTE 'T' | 48 #define ELO_TOUCH_BYTE 'T' |
49 #define ELO_ID 'I' | 49 #define ELO_ID 'I' |
50 #define ELO_MODE 'M' | 50 #define ELO_MODE 'M' |
51 #define ELO_PARAMETER 'P' | 51 #define ELO_PARAMETER 'P' |
52 #define ELO_REPORT 'B' | 52 #define ELO_REPORT 'B' |
53 #define ELO_ACK 'A' | 53 #define ELO_ACK 'A' |
54 | 54 |
55 #define ELO_INIT_CHECKSUM 0xAA | 55 #define ELO_INIT_CHECKSUM 0xAA |
56 | 56 |
57 #define ELO_BTN_PRESS 0x01 | 57 #define ELO_BTN_PRESS 0x01 |
58 #define ELO_STREAM 0x02 | 58 #define ELO_STREAM 0x02 |
59 #define ELO_BTN_RELEASE 0x04 | 59 #define ELO_BTN_RELEASE 0x04 |
60 | 60 |
61 #define ELO_TOUCH_MODE 0x01 | 61 #define ELO_TOUCH_MODE 0x01 |
62 #define ELO_STREAM_MODE 0x02 | 62 #define ELO_STREAM_MODE 0x02 |
76 #define ELO_UNTOUCH_DELAY 5 | 76 #define ELO_UNTOUCH_DELAY 5 |
77 #define ELO_REPORT_DELAY 1 | 77 #define ELO_REPORT_DELAY 1 |
78 | 78 |
79 /* eloParsePacket | 79 /* eloParsePacket |
80 */ | 80 */ |
81 int eloParsePacket(unsigned char* mousebuf, int* dx, int* dy, int* button_state) { | 81 int |
82 static int elo_button = 0; | 82 eloParsePacket (unsigned char *mousebuf, int *dx, int *dy, int *button_state) |
83 static int last_x = 0; | 83 { |
84 static int last_y = 0; | 84 static int elo_button = 0; |
85 int x,y; | 85 static int last_x = 0; |
86 | 86 static int last_y = 0; |
87 /* Check if we have a touch packet */ | 87 int x, y; |
88 if (mousebuf[1] != ELO_TOUCH_BYTE) { | 88 |
89 return 0; | 89 /* Check if we have a touch packet */ |
90 } | 90 if (mousebuf[1] != ELO_TOUCH_BYTE) { |
91 | 91 return 0; |
92 x = ((mousebuf[4] << 8) | mousebuf[3]); | 92 } |
93 y = ((mousebuf[6] << 8) | mousebuf[5]); | 93 |
94 | 94 x = ((mousebuf[4] << 8) | mousebuf[3]); |
95 if((SDL_abs(x - last_x) > ELO_SNAP_SIZE) || (SDL_abs(y - last_y) > ELO_SNAP_SIZE)) { | 95 y = ((mousebuf[6] << 8) | mousebuf[5]); |
96 *dx = ((mousebuf[4] << 8) | mousebuf[3]); | 96 |
97 *dy = ((mousebuf[6] << 8) | mousebuf[5]); | 97 if ((SDL_abs (x - last_x) > ELO_SNAP_SIZE) |
98 } | 98 || (SDL_abs (y - last_y) > ELO_SNAP_SIZE)) { |
99 else { | 99 *dx = ((mousebuf[4] << 8) | mousebuf[3]); |
100 *dx = last_x; | 100 *dy = ((mousebuf[6] << 8) | mousebuf[5]); |
101 *dy = last_y; | 101 } else { |
102 } | 102 *dx = last_x; |
103 | 103 *dy = last_y; |
104 last_x = *dx; | 104 } |
105 last_y = *dy; | 105 |
106 | 106 last_x = *dx; |
107 if ( (mousebuf[2] & 0x07) == ELO_BTN_PRESS ) { | 107 last_y = *dy; |
108 elo_button = 1; | 108 |
109 } | 109 if ((mousebuf[2] & 0x07) == ELO_BTN_PRESS) { |
110 if ( (mousebuf[2] & 0x07) == ELO_BTN_RELEASE ) { | 110 elo_button = 1; |
111 elo_button = 0; | 111 } |
112 } | 112 if ((mousebuf[2] & 0x07) == ELO_BTN_RELEASE) { |
113 | 113 elo_button = 0; |
114 *button_state = elo_button; | 114 } |
115 return 1; | 115 |
116 *button_state = elo_button; | |
117 return 1; | |
116 } | 118 } |
117 | 119 |
118 /* Convert the raw coordinates from the ELO controller | 120 /* Convert the raw coordinates from the ELO controller |
119 to a screen position. | 121 to a screen position. |
120 */ | 122 */ |
121 void eloConvertXY(_THIS, int *dx, int *dy) { | 123 void |
122 int input_x = *dx; | 124 eloConvertXY (_THIS, int *dx, int *dy) |
123 int input_y = *dy; | 125 { |
124 int width = ELO_MAX_X - ELO_MIN_X; | 126 int input_x = *dx; |
125 int height = ELO_MAX_Y - ELO_MIN_Y; | 127 int input_y = *dy; |
126 | 128 int width = ELO_MAX_X - ELO_MIN_X; |
127 *dx = ((int)cache_vinfo.xres - ((int)cache_vinfo.xres * (input_x - ELO_MIN_X)) / width); | 129 int height = ELO_MAX_Y - ELO_MIN_Y; |
128 *dy = (cache_vinfo.yres * (input_y - ELO_MIN_Y)) / height; | 130 |
131 *dx = | |
132 ((int) cache_vinfo.xres - | |
133 ((int) cache_vinfo.xres * (input_x - ELO_MIN_X)) / width); | |
134 *dy = (cache_vinfo.yres * (input_y - ELO_MIN_Y)) / height; | |
129 } | 135 } |
130 | 136 |
131 | 137 |
132 /* eloGetPacket | 138 /* eloGetPacket |
133 */ | 139 */ |
134 int eloGetPacket(unsigned char* buffer, int* buffer_p, int* checksum, int fd) { | 140 int |
135 int num_bytes; | 141 eloGetPacket (unsigned char *buffer, int *buffer_p, int *checksum, int fd) |
136 int ok; | 142 { |
137 | 143 int num_bytes; |
138 if(fd == 0) { | 144 int ok; |
139 num_bytes = ELO_PACKET_SIZE; | 145 |
140 } | 146 if (fd == 0) { |
141 else { | 147 num_bytes = ELO_PACKET_SIZE; |
142 num_bytes = read(fd, | 148 } else { |
143 (char *) (buffer + *buffer_p), | 149 num_bytes = read (fd, |
144 ELO_PACKET_SIZE - *buffer_p); | 150 (char *) (buffer + *buffer_p), |
145 } | 151 ELO_PACKET_SIZE - *buffer_p); |
146 | 152 } |
147 if (num_bytes < 0) { | 153 |
148 #ifdef DEBUG_MOUSE | 154 if (num_bytes < 0) { |
149 fprintf(stderr, "System error while reading from Elographics touchscreen.\n"); | 155 #ifdef DEBUG_MOUSE |
150 #endif | 156 fprintf (stderr, |
151 return 0; | 157 "System error while reading from Elographics touchscreen.\n"); |
152 } | 158 #endif |
153 | 159 return 0; |
154 while (num_bytes) { | 160 } |
155 if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) { | 161 |
156 SDL_memcpy(&buffer[0], &buffer[1], num_bytes-1); | 162 while (num_bytes) { |
157 } | 163 if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) { |
158 else { | 164 SDL_memcpy (&buffer[0], &buffer[1], num_bytes - 1); |
159 if (*buffer_p < ELO_PACKET_SIZE-1) { | 165 } else { |
160 *checksum = *checksum + buffer[*buffer_p]; | 166 if (*buffer_p < ELO_PACKET_SIZE - 1) { |
161 *checksum = *checksum % 256; | 167 *checksum = *checksum + buffer[*buffer_p]; |
162 } | 168 *checksum = *checksum % 256; |
163 (*buffer_p)++; | 169 } |
164 } | 170 (*buffer_p)++; |
165 num_bytes--; | 171 } |
166 } | 172 num_bytes--; |
167 | 173 } |
168 if (*buffer_p == ELO_PACKET_SIZE) { | 174 |
169 ok = (*checksum == buffer[ELO_PACKET_SIZE-1]); | 175 if (*buffer_p == ELO_PACKET_SIZE) { |
170 *checksum = ELO_INIT_CHECKSUM; | 176 ok = (*checksum == buffer[ELO_PACKET_SIZE - 1]); |
171 *buffer_p = 0; | 177 *checksum = ELO_INIT_CHECKSUM; |
172 | 178 *buffer_p = 0; |
173 if (!ok) { | 179 |
174 return 0; | 180 if (!ok) { |
175 } | 181 return 0; |
176 | 182 } |
177 return 1; | 183 |
178 } | 184 return 1; |
179 else { | 185 } else { |
180 return 0; | 186 return 0; |
181 } | 187 } |
182 } | 188 } |
183 | 189 |
184 /* eloSendPacket | 190 /* eloSendPacket |
185 */ | 191 */ |
186 | 192 |
187 int eloSendPacket(unsigned char* packet, int fd) | 193 int |
188 { | 194 eloSendPacket (unsigned char *packet, int fd) |
189 int i, result; | 195 { |
190 int sum = ELO_INIT_CHECKSUM; | 196 int i, result; |
191 | 197 int sum = ELO_INIT_CHECKSUM; |
192 packet[0] = ELO_START_BYTE; | 198 |
193 for (i = 0; i < ELO_PACKET_SIZE-1; i++) { | 199 packet[0] = ELO_START_BYTE; |
194 sum += packet[i]; | 200 for (i = 0; i < ELO_PACKET_SIZE - 1; i++) { |
195 sum &= 0xFF; | 201 sum += packet[i]; |
196 } | 202 sum &= 0xFF; |
197 packet[ELO_PACKET_SIZE-1] = sum; | 203 } |
198 | 204 packet[ELO_PACKET_SIZE - 1] = sum; |
199 result = write(fd, packet, ELO_PACKET_SIZE); | 205 |
200 | 206 result = write (fd, packet, ELO_PACKET_SIZE); |
201 if (result != ELO_PACKET_SIZE) { | 207 |
202 #ifdef DEBUG_MOUSE | 208 if (result != ELO_PACKET_SIZE) { |
203 printf("System error while sending to Elographics touchscreen.\n"); | 209 #ifdef DEBUG_MOUSE |
204 #endif | 210 printf ("System error while sending to Elographics touchscreen.\n"); |
205 return 0; | 211 #endif |
206 } | 212 return 0; |
207 else { | 213 } else { |
208 return 1; | 214 return 1; |
209 } | 215 } |
210 } | 216 } |
211 | 217 |
212 | 218 |
213 /* eloWaitForInput | 219 /* eloWaitForInput |
214 */ | 220 */ |
215 int eloWaitForInput(int fd, int timeout) | 221 int |
216 { | 222 eloWaitForInput (int fd, int timeout) |
217 fd_set readfds; | 223 { |
218 struct timeval to; | 224 fd_set readfds; |
219 int r; | 225 struct timeval to; |
220 | 226 int r; |
221 FD_ZERO(&readfds); | 227 |
222 FD_SET(fd, &readfds); | 228 FD_ZERO (&readfds); |
223 to.tv_sec = 0; | 229 FD_SET (fd, &readfds); |
224 to.tv_usec = timeout; | 230 to.tv_sec = 0; |
225 | 231 to.tv_usec = timeout; |
226 r = select(FD_SETSIZE, &readfds, NULL, NULL, &to); | 232 |
227 return r; | 233 r = select (FD_SETSIZE, &readfds, NULL, NULL, &to); |
234 return r; | |
228 } | 235 } |
229 | 236 |
230 /* eloWaitReply | 237 /* eloWaitReply |
231 */ | 238 */ |
232 int eloWaitReply(unsigned char type, unsigned char *reply, int fd) { | 239 int |
233 int ok; | 240 eloWaitReply (unsigned char type, unsigned char *reply, int fd) |
234 int i, result; | 241 { |
235 int reply_p = 0; | 242 int ok; |
236 int sum = ELO_INIT_CHECKSUM; | 243 int i, result; |
237 | 244 int reply_p = 0; |
238 i = ELO_MAX_TRIALS; | 245 int sum = ELO_INIT_CHECKSUM; |
239 do { | 246 |
240 ok = 0; | 247 i = ELO_MAX_TRIALS; |
241 | 248 do { |
242 result = eloWaitForInput(fd, ELO_MAX_WAIT); | 249 ok = 0; |
243 | 250 |
244 if (result > 0) { | 251 result = eloWaitForInput (fd, ELO_MAX_WAIT); |
245 ok = eloGetPacket(reply, &reply_p, &sum, fd); | 252 |
246 | 253 if (result > 0) { |
247 if (ok && reply[1] != type && type != ELO_PARAMETER) { | 254 ok = eloGetPacket (reply, &reply_p, &sum, fd); |
248 #ifdef DEBUG_MOUSE | 255 |
249 fprintf(stderr, "Wrong reply received\n"); | 256 if (ok && reply[1] != type && type != ELO_PARAMETER) { |
250 #endif | 257 #ifdef DEBUG_MOUSE |
251 ok = 0; | 258 fprintf (stderr, "Wrong reply received\n"); |
252 } | 259 #endif |
253 } | 260 ok = 0; |
254 else { | 261 } |
255 #ifdef DEBUG_MOUSE | 262 } else { |
256 fprintf(stderr, "No input!\n"); | 263 #ifdef DEBUG_MOUSE |
257 #endif | 264 fprintf (stderr, "No input!\n"); |
258 } | 265 #endif |
259 | 266 } |
260 if (result == 0) { | 267 |
261 i--; | 268 if (result == 0) { |
262 } | 269 i--; |
263 } while(!ok && (i>0)); | 270 } |
264 | 271 } |
265 return ok; | 272 while (!ok && (i > 0)); |
273 | |
274 return ok; | |
266 } | 275 } |
267 | 276 |
268 | 277 |
269 /* eloWaitAck | 278 /* eloWaitAck |
270 */ | 279 */ |
271 | 280 |
272 int eloWaitAck(int fd) { | 281 int |
273 unsigned char packet[ELO_PACKET_SIZE]; | 282 eloWaitAck (int fd) |
274 int i, nb_errors; | 283 { |
275 | 284 unsigned char packet[ELO_PACKET_SIZE]; |
276 if (eloWaitReply(ELO_ACK, packet, fd)) { | 285 int i, nb_errors; |
277 for (i = 0, nb_errors = 0; i < 4; i++) { | 286 |
278 if (packet[2 + i] != '0') { | 287 if (eloWaitReply (ELO_ACK, packet, fd)) { |
279 nb_errors++; | 288 for (i = 0, nb_errors = 0; i < 4; i++) { |
280 } | 289 if (packet[2 + i] != '0') { |
281 } | 290 nb_errors++; |
282 | 291 } |
283 if (nb_errors != 0) { | 292 } |
284 #ifdef DEBUG_MOUSE | 293 |
285 fprintf(stderr, "Elographics acknowledge packet reports %d errors\n", nb_errors); | 294 if (nb_errors != 0) { |
286 #endif | 295 #ifdef DEBUG_MOUSE |
287 } | 296 fprintf (stderr, |
288 return 1; | 297 "Elographics acknowledge packet reports %d errors\n", |
289 } | 298 nb_errors); |
290 else { | 299 #endif |
291 return 0; | 300 } |
292 } | 301 return 1; |
302 } else { | |
303 return 0; | |
304 } | |
293 } | 305 } |
294 | 306 |
295 | 307 |
296 /* eloSendQuery -- | 308 /* eloSendQuery -- |
297 */ | 309 */ |
298 int eloSendQuery(unsigned char *request, unsigned char* reply, int fd) { | 310 int |
299 int ok; | 311 eloSendQuery (unsigned char *request, unsigned char *reply, int fd) |
300 | 312 { |
301 if (eloSendPacket(request, fd)) { | 313 int ok; |
302 ok = eloWaitReply(toupper(request[1]), reply, fd); | 314 |
303 if (ok) { | 315 if (eloSendPacket (request, fd)) { |
304 ok = eloWaitAck(fd); | 316 ok = eloWaitReply (toupper (request[1]), reply, fd); |
305 } | 317 if (ok) { |
306 return ok; | 318 ok = eloWaitAck (fd); |
307 } | 319 } |
308 else { | 320 return ok; |
309 return 0; | 321 } else { |
310 } | 322 return 0; |
323 } | |
311 } | 324 } |
312 | 325 |
313 | 326 |
314 /* eloSendControl | 327 /* eloSendControl |
315 */ | 328 */ |
316 int eloSendControl(unsigned char* control, int fd) { | 329 int |
317 if (eloSendPacket(control, fd)) { | 330 eloSendControl (unsigned char *control, int fd) |
318 return eloWaitAck(fd); | 331 { |
319 } | 332 if (eloSendPacket (control, fd)) { |
320 else { | 333 return eloWaitAck (fd); |
321 return 0; | 334 } else { |
322 } | 335 return 0; |
336 } | |
323 } | 337 } |
324 | 338 |
325 /* eloInitController | 339 /* eloInitController |
326 */ | 340 */ |
327 int eloInitController(int fd) { | 341 int |
328 unsigned char req[ELO_PACKET_SIZE]; | 342 eloInitController (int fd) |
329 unsigned char reply[ELO_PACKET_SIZE]; | 343 { |
330 const char *buffer = NULL; | 344 unsigned char req[ELO_PACKET_SIZE]; |
331 int result = 0; | 345 unsigned char reply[ELO_PACKET_SIZE]; |
332 | 346 const char *buffer = NULL; |
333 struct termios mouse_termios; | 347 int result = 0; |
334 | 348 |
335 /* try to read the calibration values */ | 349 struct termios mouse_termios; |
336 buffer = SDL_getenv("SDL_ELO_MIN_X"); | 350 |
337 if(buffer) { | 351 /* try to read the calibration values */ |
338 ELO_MIN_X = SDL_atoi(buffer); | 352 buffer = SDL_getenv ("SDL_ELO_MIN_X"); |
339 } | 353 if (buffer) { |
340 buffer = SDL_getenv("SDL_ELO_MAX_X"); | 354 ELO_MIN_X = SDL_atoi (buffer); |
341 if(buffer) { | 355 } |
342 ELO_MAX_X = SDL_atoi(buffer); | 356 buffer = SDL_getenv ("SDL_ELO_MAX_X"); |
343 } | 357 if (buffer) { |
344 buffer = SDL_getenv("SDL_ELO_MIN_Y"); | 358 ELO_MAX_X = SDL_atoi (buffer); |
345 if(buffer) { | 359 } |
346 ELO_MIN_Y = SDL_atoi(buffer); | 360 buffer = SDL_getenv ("SDL_ELO_MIN_Y"); |
347 } | 361 if (buffer) { |
348 buffer = SDL_getenv("SDL_ELO_MAX_Y"); | 362 ELO_MIN_Y = SDL_atoi (buffer); |
349 if(buffer) { | 363 } |
350 ELO_MAX_Y = SDL_atoi(buffer); | 364 buffer = SDL_getenv ("SDL_ELO_MAX_Y"); |
351 } | 365 if (buffer) { |
352 | 366 ELO_MAX_Y = SDL_atoi (buffer); |
353 #ifdef DEBUG_MOUSE | 367 } |
354 fprintf( stderr, "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n", | 368 #ifdef DEBUG_MOUSE |
355 ELO_MIN_X, | 369 fprintf (stderr, |
356 ELO_MAX_X, | 370 "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n", |
357 ELO_MIN_Y, | 371 ELO_MIN_X, ELO_MAX_X, ELO_MIN_Y, ELO_MAX_Y); |
358 ELO_MAX_Y); | 372 #endif |
359 #endif | 373 |
360 | 374 /* set comm params */ |
361 /* set comm params */ | 375 SDL_memset (&mouse_termios, 0, sizeof (mouse_termios)); |
362 SDL_memset(&mouse_termios, 0, sizeof(mouse_termios)); | 376 mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; |
363 mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; | 377 mouse_termios.c_cc[VMIN] = 1; |
364 mouse_termios.c_cc[VMIN] = 1; | 378 result = tcsetattr (fd, TCSANOW, &mouse_termios); |
365 result = tcsetattr(fd, TCSANOW, &mouse_termios); | 379 |
366 | 380 if (result < 0) { |
367 if (result < 0) { | 381 #ifdef DEBUG_MOUSE |
368 #ifdef DEBUG_MOUSE | 382 fprintf (stderr, |
369 fprintf( stderr, "Unable to configure Elographics touchscreen port\n"); | 383 "Unable to configure Elographics touchscreen port\n"); |
370 #endif | 384 #endif |
371 return 0; | 385 return 0; |
372 } | 386 } |
373 | 387 |
374 SDL_memset(req, 0, ELO_PACKET_SIZE); | 388 SDL_memset (req, 0, ELO_PACKET_SIZE); |
375 req[1] = tolower(ELO_PARAMETER); | 389 req[1] = tolower (ELO_PARAMETER); |
376 if (!eloSendQuery(req, reply, fd)) { | 390 if (!eloSendQuery (req, reply, fd)) { |
377 #ifdef DEBUG_MOUSE | 391 #ifdef DEBUG_MOUSE |
378 fprintf( stderr, "Not at the specified rate or model 2310, will continue\n"); | 392 fprintf (stderr, |
379 #endif | 393 "Not at the specified rate or model 2310, will continue\n"); |
380 } | 394 #endif |
381 | 395 } |
382 SDL_memset(req, 0, ELO_PACKET_SIZE); | 396 |
383 req[1] = tolower(ELO_ID); | 397 SDL_memset (req, 0, ELO_PACKET_SIZE); |
384 if (eloSendQuery(req, reply, fd)) { | 398 req[1] = tolower (ELO_ID); |
385 #ifdef DEBUG_MOUSE | 399 if (eloSendQuery (req, reply, fd)) { |
386 fprintf(stderr, "Ok, controller configured!\n"); | 400 #ifdef DEBUG_MOUSE |
387 #endif | 401 fprintf (stderr, "Ok, controller configured!\n"); |
388 } | 402 #endif |
389 else { | 403 } else { |
390 #ifdef DEBUG_MOUSE | 404 #ifdef DEBUG_MOUSE |
391 fprintf( stderr, "Unable to ask Elographics touchscreen identification\n"); | 405 fprintf (stderr, |
392 #endif | 406 "Unable to ask Elographics touchscreen identification\n"); |
393 return 0; | 407 #endif |
394 } | 408 return 0; |
395 | 409 } |
396 SDL_memset(req, 0, ELO_PACKET_SIZE); | 410 |
397 req[1] = ELO_MODE; | 411 SDL_memset (req, 0, ELO_PACKET_SIZE); |
398 req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE; | 412 req[1] = ELO_MODE; |
399 req[4] = ELO_TRACKING_MODE; | 413 req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE; |
400 if (!eloSendControl(req, fd)) { | 414 req[4] = ELO_TRACKING_MODE; |
401 #ifdef DEBUG_MOUSE | 415 if (!eloSendControl (req, fd)) { |
402 fprintf( stderr, "Unable to change Elographics touchscreen operating mode\n"); | 416 #ifdef DEBUG_MOUSE |
403 #endif | 417 fprintf (stderr, |
404 return 0; | 418 "Unable to change Elographics touchscreen operating mode\n"); |
405 } | 419 #endif |
406 | 420 return 0; |
407 SDL_memset(req, 0, ELO_PACKET_SIZE); | 421 } |
408 req[1] = ELO_REPORT; | 422 |
409 req[2] = ELO_UNTOUCH_DELAY; | 423 SDL_memset (req, 0, ELO_PACKET_SIZE); |
410 req[3] = ELO_REPORT_DELAY; | 424 req[1] = ELO_REPORT; |
411 if (!eloSendControl(req, fd)) { | 425 req[2] = ELO_UNTOUCH_DELAY; |
412 #ifdef DEBUG_MOUSE | 426 req[3] = ELO_REPORT_DELAY; |
413 fprintf( stderr, "Unable to change Elographics touchscreen reports timings\n"); | 427 if (!eloSendControl (req, fd)) { |
414 #endif | 428 #ifdef DEBUG_MOUSE |
415 return 0; | 429 fprintf (stderr, |
416 } | 430 "Unable to change Elographics touchscreen reports timings\n"); |
417 | 431 #endif |
418 return 1; | 432 return 0; |
419 } | 433 } |
420 | 434 |
421 int eloReadPosition(_THIS, int fd, int* x, int* y, int* button_state, int* realx, int* realy) { | 435 return 1; |
422 unsigned char buffer[ELO_PACKET_SIZE]; | 436 } |
423 int pointer = 0; | 437 |
424 int checksum = ELO_INIT_CHECKSUM; | 438 int |
425 | 439 eloReadPosition (_THIS, int fd, int *x, int *y, int *button_state, int *realx, |
426 while(pointer < ELO_PACKET_SIZE) { | 440 int *realy) |
427 if(eloGetPacket(buffer, &pointer, &checksum, fd)) { | 441 { |
428 break; | 442 unsigned char buffer[ELO_PACKET_SIZE]; |
429 } | 443 int pointer = 0; |
430 } | 444 int checksum = ELO_INIT_CHECKSUM; |
431 | 445 |
432 if(!eloParsePacket(buffer, realx, realy, button_state)) { | 446 while (pointer < ELO_PACKET_SIZE) { |
433 return 0; | 447 if (eloGetPacket (buffer, &pointer, &checksum, fd)) { |
434 } | 448 break; |
435 | 449 } |
436 *x = *realx; | 450 } |
437 *y = *realy; | 451 |
438 | 452 if (!eloParsePacket (buffer, realx, realy, button_state)) { |
439 eloConvertXY(this, x, y); | 453 return 0; |
440 | 454 } |
441 return 1; | 455 |
442 } | 456 *x = *realx; |
457 *y = *realy; | |
458 | |
459 eloConvertXY (this, x, y); | |
460 | |
461 return 1; | |
462 } | |
463 | |
464 /* vi: set ts=4 sw=4 expandtab: */ |