Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
X11 touch handling fixed for one device (LPC32xx Touchscreen).
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 5, 2011
1 parent ab4948e commit 7e4015f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
47 changes: 27 additions & 20 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -549,6 +549,7 @@ X11_PumpEvents(_THIS)
struct input_event ev[64];
int size = sizeof (struct input_event);

/* !!! FIXME: clean the tabstops out of here. */
for(i = 0;i < SDL_GetNumTouch();++i) {
SDL_Touch* touch = SDL_GetTouchIndex(i);
if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
Expand All @@ -561,12 +562,10 @@ X11_PumpEvents(_THIS)
if(data->eventStream <= 0)
printf("Error: Couldn't open stream\n");
rd = read(data->eventStream, ev, size * 64);
//printf("Got %i/%i bytes\n",rd,size);
if(rd >= size) {
for (i = 0; i < rd / sizeof(struct input_event); i++) {
switch (ev[i].type) {
case EV_ABS:
//printf("Got position x: %i!\n",data->x);
switch (ev[i].code) {
case ABS_X:
data->x = ev[i].value;
Expand All @@ -585,29 +584,37 @@ X11_PumpEvents(_THIS)
}
break;
case EV_MSC:
if(ev[i].code == MSC_SERIAL)
data->finger = ev[i].value;
break;
if(ev[i].code == MSC_SERIAL)
data->finger = ev[i].value;
break;
case EV_KEY:
if(ev[i].code == BTN_TOUCH)
if(ev[i].value == 0)
data->up = SDL_TRUE;
break;
case EV_SYN:
//printf("Id: %i\n",touch->id);
if(data->up) {
if(!data->down) {
data->down = SDL_TRUE;
SDL_SendFingerDown(touch->id,data->finger,
SDL_FALSE,data->x,data->y,
data->pressure);
data->down, data->x, data->y,
data->pressure);
}
else if(data->x >= 0 || data->y >= 0)
else if(!data->up)
SDL_SendTouchMotion(touch->id,data->finger,
SDL_FALSE,data->x,data->y,
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;

else
{
data->down = SDL_FALSE;
SDL_SendFingerDown(touch->id,data->finger,
data->down, data->x,data->y,
data->pressure);
data->x = -1;
data->y = -1;
data->pressure = -1;
data->finger = 0;
data->up = SDL_FALSE;
}
break;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/video/x11/SDL_x11touch.c
Expand Up @@ -47,10 +47,9 @@ X11_InitTouch(_THIS)
while(!feof(fd)) {
if(fgets(line,256,fd) <=0) continue;
if(line[0] == '\n') {
if(vendor == 1386){
/*printf("Wacom... Assuming it is a touch device\n");*/
/*sprintf(tstr,"/dev/input/event%i",event);*/
/*printf("At location: %s\n",tstr);*/
if(vendor == 1386 || vendor==1){

sprintf(tstr,"/dev/input/event%i",event);

SDL_Touch touch;
touch.pressure_max = 0;
Expand All @@ -66,6 +65,7 @@ X11_InitTouch(_THIS)
data->pressure = -1;
data->finger = 0;
data->up = SDL_FALSE;
data->down = SDL_FALSE;


data->eventStream = open(tstr,
Expand Down

0 comments on commit 7e4015f

Please sign in to comment.