Bug fixes. Basic touch events (finger up, finger down, finger move) supported.

This commit is contained in:
Jim Grandpre 2010-05-29 01:47:19 -04:00
parent 72c5a40b07
commit 11b6823d3f
4 changed files with 47 additions and 17 deletions

View file

@ -301,11 +301,12 @@ SDL_DelFinger(SDL_Touch* touch,int fingerid)
int
SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure)
{
int posted;
int posted;
SDL_Touch* touch = SDL_GetTouch(id);
if(down) {
SDL_Finger nf;
nf.id = id;
nf.id = fingerid;
nf.x = x;
nf.y = y;
nf.pressure = pressure;
@ -324,13 +325,13 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
event.tfinger.y = y;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = id;
event.tfinger.fingerId = fingerid;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
else {
SDL_DelFinger(touch,id);
SDL_DelFinger(touch,fingerid);
posted = 0;
if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
SDL_Event event;
@ -338,7 +339,7 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
event.tfinger.touchId = (Uint8) id;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.tfinger.fingerId = id;
event.tfinger.fingerId = fingerid;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
@ -419,7 +420,8 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.touchId = (Uint8) index;
event.tfinger.touchId = (Uint8) id;
event.tfinger.fingerId = (Uint8) fingerid;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.state = touch->buttonstate;

View file

@ -31,6 +31,7 @@ typedef struct EventTouchData
{
int x,y,pressure,finger; //Temporary Variables until sync
int eventStream;
SDL_bool up;
} EventTouchData;
#endif

View file

@ -419,7 +419,7 @@ X11_PumpEvents(_THIS)
/* Process Touch events - TODO When X gets touch support, use that instead*/
int i = 0,rd;
char * name[256];
char name[256];
struct input_event ev[64];
int size = sizeof (struct input_event);
static int initd = 0; //TODO - HACK!
@ -431,7 +431,7 @@ X11_PumpEvents(_THIS)
touch->driverdata = SDL_malloc(sizeof(EventTouchData));
data = (EventTouchData*)(touch->driverdata);
printf("Openning device...\n");
data->eventStream = open("/dev/input/wacom-touch",
data->eventStream = open("/dev/input/wacom",
O_RDONLY | O_NONBLOCK);
ioctl (data->eventStream, EVIOCGNAME (sizeof (name)), name);
printf ("Reading From : %s\n", name);
@ -452,24 +452,31 @@ X11_PumpEvents(_THIS)
data->x = ev[i].value;
else if (ev[i].code == ABS_Y)
data->y = ev[i].value;
else if (ev[i].code == ABS_MISC) {
data->up = SDL_TRUE;
data->finger = ev[i].value;
}
break;
case EV_MSC:
if(ev[i].code == MSC_SERIAL)
data->finger = ev[i].value;
break;
case EV_SYN:
data->finger -= 1; /*Wacom indexes fingers from 1,
I index from 0*/
if(data->x >= 0 || data->y >= 0)
SDL_SendTouchMotion(touch->id,data->finger,
SDL_FALSE,data->x,data->y,
data->pressure);
if(data->up)
SDL_SendFingerDown(touch->id,data->finger,
SDL_FALSE,data->x,data->y,
data->pressure);
//printf("Synched: %i tx: %i, ty: %i\n",
// data->finger,data->x,data->y);
data->x = -1;
data->y = -1;
data->pressure = -1;
data->finger = 0;
data->up = SDL_FALSE;
break;
}