# HG changeset patch # User Jim Grandpre # Date 1275113356 14400 # Node ID fb500b3e17174717b7552aedc07fb099bc3b5249 # Parent 8806b78988f7306ff74a8679de4aa8daa9c8ec80 Added pressure support for touch events. diff -r 8806b78988f7 -r fb500b3e1717 include/SDL_events.h --- a/include/SDL_events.h Sat May 29 01:47:19 2010 -0400 +++ b/include/SDL_events.h Sat May 29 02:09:16 2010 -0400 @@ -312,6 +312,7 @@ Uint8 padding1; int x; int y; + int pressure; } SDL_TouchFingerEvent; diff -r 8806b78988f7 -r fb500b3e1717 src/events/SDL_touch.c --- a/src/events/SDL_touch.c Sat May 29 01:47:19 2010 -0400 +++ b/src/events/SDL_touch.c Sat May 29 02:09:16 2010 -0400 @@ -424,6 +424,7 @@ event.tfinger.fingerId = (Uint8) fingerid; event.tfinger.x = x; event.tfinger.y = y; + event.tfinger.pressure = pressure; event.tfinger.state = touch->buttonstate; event.tfinger.windowID = touch->focus ? touch->focus->id : 0; posted = (SDL_PushEvent(&event) > 0); diff -r 8806b78988f7 -r fb500b3e1717 src/video/x11/SDL_x11events.c --- a/src/video/x11/SDL_x11events.c Sat May 29 01:47:19 2010 -0400 +++ b/src/video/x11/SDL_x11events.c Sat May 29 02:09:16 2010 -0400 @@ -448,14 +448,21 @@ switch (ev[i].type) { case EV_ABS: //printf("Got position x: %i!\n",data->x); - if(ev[i].code == ABS_X) - 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; - } + switch (ev[i].code) { + case ABS_X: + data->x = ev[i].value; + break; + case ABS_Y: + data->y = ev[i].value; + break; + case ABS_PRESSURE: + data->pressure = ev[i].value; + break; + case ABS_MISC: + data->up = SDL_TRUE; + data->finger = ev[i].value; + break; + } break; case EV_MSC: if(ev[i].code == MSC_SERIAL) diff -r 8806b78988f7 -r fb500b3e1717 touchTest/touchPong Binary file touchTest/touchPong has changed diff -r 8806b78988f7 -r fb500b3e1717 touchTest/touchSimp Binary file touchTest/touchSimp has changed diff -r 8806b78988f7 -r fb500b3e1717 touchTest/touchTest.c --- a/touchTest/touchTest.c Sat May 29 01:47:19 2010 -0400 +++ b/touchTest/touchTest.c Sat May 29 02:09:16 2010 -0400 @@ -22,8 +22,13 @@ int x,y; } Point; +typedef struct { + Point p; + int pressure; +} Finger; -Point finger[MAXFINGERS]; + +Finger finger[MAXFINGERS]; void handler (int sig) { @@ -56,9 +61,12 @@ { float a; - for(a=0;a<2*PI;a+=1.f/(float)r) + for(a=0;a= 0 && finger[i].y >= 0) - drawCircle(screen,finger[i].x,finger[i].y,20,0xFF6600); + if(finger[i].p.x >= 0 && finger[i].p.y >= 0) + drawCircle(screen,finger[i].p.x,finger[i].p.y,20,0xFF6600-finger[i].pressure); if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); @@ -157,20 +165,23 @@ //printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId, // event.tfinger.x,event.tfinger.y); - finger[event.tfinger.fingerId].x = event.tfinger.x; - finger[event.tfinger.fingerId].y = event.tfinger.y; + finger[event.tfinger.fingerId].p.x = event.tfinger.x; + finger[event.tfinger.fingerId].p.y = event.tfinger.y; + finger[event.tfinger.fingerId].pressure = event.tfinger.pressure; + printf("Finger: %i, pressure: %i\n",event.tfinger.fingerId, + event.tfinger.pressure); break; case SDL_FINGERDOWN: printf("Figner: %i down - x: %i, y: %i\n",event.tfinger.fingerId, event.tfinger.x,event.tfinger.y); - finger[event.tfinger.fingerId].x = event.tfinger.x; - finger[event.tfinger.fingerId].y = event.tfinger.y; + finger[event.tfinger.fingerId].p.x = event.tfinger.x; + finger[event.tfinger.fingerId].p.y = event.tfinger.y; break; case SDL_FINGERUP: printf("Figner: %i up - x: %i, y: %i\n",event.tfinger.fingerId, event.tfinger.x,event.tfinger.y); - finger[event.tfinger.fingerId].x = -1; - finger[event.tfinger.fingerId].y = -1; + finger[event.tfinger.fingerId].p.x = -1; + finger[event.tfinger.fingerId].p.y = -1; break; } }