comparison src/video/x11/SDL_x11events.c @ 4645:0375d020e7e3

Auto-detects Wacom touch devices.
author Jim Grandpre <jim.tla@gmail.com>
date Mon, 31 May 2010 00:24:37 -0400
parents fb500b3e1717
children eea1bf53effa
comparison
equal deleted inserted replaced
4644:fb500b3e1717 4645:0375d020e7e3
107 SDL_SetMouseFocus(mouse->id, data->window); 107 SDL_SetMouseFocus(mouse->id, data->window);
108 } 108 }
109 #endif 109 #endif
110 } 110 }
111 break; 111 break;
112
113 /* Losing mouse coverage? */ 112 /* Losing mouse coverage? */
114 case LeaveNotify:{ 113 case LeaveNotify:{
115 #ifdef DEBUG_XEVENTS 114 #ifdef DEBUG_XEVENTS
116 printf("LeaveNotify! (%d,%d,%d)\n", 115 printf("LeaveNotify! (%d,%d,%d)\n",
117 xevent.xcrossing.x, 116 xevent.xcrossing.x,
420 /* Process Touch events - TODO When X gets touch support, use that instead*/ 419 /* Process Touch events - TODO When X gets touch support, use that instead*/
421 int i = 0,rd; 420 int i = 0,rd;
422 char name[256]; 421 char name[256];
423 struct input_event ev[64]; 422 struct input_event ev[64];
424 int size = sizeof (struct input_event); 423 int size = sizeof (struct input_event);
425 static int initd = 0; //TODO - HACK! 424
426 for(i = 0;i < SDL_GetNumTouch();++i) { 425 for(i = 0;i < SDL_GetNumTouch();++i) {
427 SDL_Touch* touch = SDL_GetTouchIndex(i); 426 SDL_Touch* touch = SDL_GetTouchIndex(i);
428 if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch()); 427 if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
429 EventTouchData* data; 428 EventTouchData* data;
430 if(!initd){//data->eventStream <= 0) { 429 data = (EventTouchData*)(touch->driverdata);
431 touch->driverdata = SDL_malloc(sizeof(EventTouchData)); 430 if(data == NULL) {
432 data = (EventTouchData*)(touch->driverdata); 431 printf("No driver data\n");
433 printf("Openning device...\n"); 432 continue;
434 data->eventStream = open("/dev/input/wacom",
435 O_RDONLY | O_NONBLOCK);
436 ioctl (data->eventStream, EVIOCGNAME (sizeof (name)), name);
437 printf ("Reading From : %s\n", name);
438 initd = 1;
439 } 433 }
440 else
441 data = (EventTouchData*)(touch->driverdata);
442 if(data->eventStream <= 0) 434 if(data->eventStream <= 0)
443 printf("Error: Couldn't open stream\n"); 435 printf("Error: Couldn't open stream\n");
444 rd = read(data->eventStream, ev, size * 64); 436 rd = read(data->eventStream, ev, size * 64);
445 //printf("Got %i/%i bytes\n",rd,size); 437 //printf("Got %i/%i bytes\n",rd,size);
446 if(rd >= size) { 438 if(rd >= size) {
467 case EV_MSC: 459 case EV_MSC:
468 if(ev[i].code == MSC_SERIAL) 460 if(ev[i].code == MSC_SERIAL)
469 data->finger = ev[i].value; 461 data->finger = ev[i].value;
470 break; 462 break;
471 case EV_SYN: 463 case EV_SYN:
464 printf("Id: %i\n",touch->id);
472 if(data->x >= 0 || data->y >= 0) 465 if(data->x >= 0 || data->y >= 0)
473 SDL_SendTouchMotion(touch->id,data->finger, 466 SDL_SendTouchMotion(touch->id,data->finger,
474 SDL_FALSE,data->x,data->y, 467 SDL_FALSE,data->x,data->y,
475 data->pressure); 468 data->pressure);
476 if(data->up) 469 if(data->up)