Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11events.c @ 4643:8806b78988f7
Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Sat, 29 May 2010 01:47:19 -0400 |
parents | 057e8762d2a1 |
children | fb500b3e1717 |
comparison
equal
deleted
inserted
replaced
4642:057e8762d2a1 | 4643:8806b78988f7 |
---|---|
417 } | 417 } |
418 | 418 |
419 | 419 |
420 /* Process Touch events - TODO When X gets touch support, use that instead*/ | 420 /* Process Touch events - TODO When X gets touch support, use that instead*/ |
421 int i = 0,rd; | 421 int i = 0,rd; |
422 char * name[256]; | 422 char name[256]; |
423 struct input_event ev[64]; | 423 struct input_event ev[64]; |
424 int size = sizeof (struct input_event); | 424 int size = sizeof (struct input_event); |
425 static int initd = 0; //TODO - HACK! | 425 static int initd = 0; //TODO - HACK! |
426 for(i = 0;i < SDL_GetNumTouch();++i) { | 426 for(i = 0;i < SDL_GetNumTouch();++i) { |
427 SDL_Touch* touch = SDL_GetTouchIndex(i); | 427 SDL_Touch* touch = SDL_GetTouchIndex(i); |
429 EventTouchData* data; | 429 EventTouchData* data; |
430 if(!initd){//data->eventStream <= 0) { | 430 if(!initd){//data->eventStream <= 0) { |
431 touch->driverdata = SDL_malloc(sizeof(EventTouchData)); | 431 touch->driverdata = SDL_malloc(sizeof(EventTouchData)); |
432 data = (EventTouchData*)(touch->driverdata); | 432 data = (EventTouchData*)(touch->driverdata); |
433 printf("Openning device...\n"); | 433 printf("Openning device...\n"); |
434 data->eventStream = open("/dev/input/wacom-touch", | 434 data->eventStream = open("/dev/input/wacom", |
435 O_RDONLY | O_NONBLOCK); | 435 O_RDONLY | O_NONBLOCK); |
436 ioctl (data->eventStream, EVIOCGNAME (sizeof (name)), name); | 436 ioctl (data->eventStream, EVIOCGNAME (sizeof (name)), name); |
437 printf ("Reading From : %s\n", name); | 437 printf ("Reading From : %s\n", name); |
438 initd = 1; | 438 initd = 1; |
439 } | 439 } |
450 //printf("Got position x: %i!\n",data->x); | 450 //printf("Got position x: %i!\n",data->x); |
451 if(ev[i].code == ABS_X) | 451 if(ev[i].code == ABS_X) |
452 data->x = ev[i].value; | 452 data->x = ev[i].value; |
453 else if (ev[i].code == ABS_Y) | 453 else if (ev[i].code == ABS_Y) |
454 data->y = ev[i].value; | 454 data->y = ev[i].value; |
455 else if (ev[i].code == ABS_MISC) { | |
456 data->up = SDL_TRUE; | |
457 data->finger = ev[i].value; | |
458 } | |
455 break; | 459 break; |
456 case EV_MSC: | 460 case EV_MSC: |
457 if(ev[i].code == MSC_SERIAL) | 461 if(ev[i].code == MSC_SERIAL) |
458 data->finger = ev[i].value; | 462 data->finger = ev[i].value; |
459 break; | 463 break; |
460 case EV_SYN: | 464 case EV_SYN: |
461 data->finger -= 1; /*Wacom indexes fingers from 1, | |
462 I index from 0*/ | |
463 if(data->x >= 0 || data->y >= 0) | 465 if(data->x >= 0 || data->y >= 0) |
464 SDL_SendTouchMotion(touch->id,data->finger, | 466 SDL_SendTouchMotion(touch->id,data->finger, |
465 SDL_FALSE,data->x,data->y, | 467 SDL_FALSE,data->x,data->y, |
466 data->pressure); | 468 data->pressure); |
467 | 469 if(data->up) |
470 SDL_SendFingerDown(touch->id,data->finger, | |
471 SDL_FALSE,data->x,data->y, | |
472 data->pressure); | |
468 //printf("Synched: %i tx: %i, ty: %i\n", | 473 //printf("Synched: %i tx: %i, ty: %i\n", |
469 // data->finger,data->x,data->y); | 474 // data->finger,data->x,data->y); |
470 data->x = -1; | 475 data->x = -1; |
471 data->y = -1; | 476 data->y = -1; |
472 data->pressure = -1; | 477 data->pressure = -1; |
478 data->finger = 0; | |
479 data->up = SDL_FALSE; | |
473 | 480 |
474 break; | 481 break; |
475 } | 482 } |
476 } | 483 } |
477 } | 484 } |