Fixed some Gesture bugs
authorJim Grandpre <jim.tla@gmail.com>
Mon, 02 Aug 2010 00:14:53 -0400
changeset 46815378f2d0754f
parent 4680 229529693289
child 4682 4ba1048a324c
Fixed some Gesture bugs
configure.in
src/events/SDL_gesture.c
src/events/SDL_touch.c
src/video/x11/SDL_eventtouch.c
src/video/x11/SDL_x11events.c
touchTest/gestureSDLTest.c
     1.1 --- a/configure.in	Sat Jul 31 20:55:33 2010 -0700
     1.2 +++ b/configure.in	Mon Aug 02 00:14:53 2010 -0400
     1.3 @@ -285,8 +285,6 @@
     1.4      AC_DEFINE(uintptr_t, unsigned long)
     1.5  fi
     1.6  
     1.7 -AC_CHECK_HEADER(Linux/input.h,AC_DEFINE(HAVE_LINUX_INPUT_H))
     1.8 -
     1.9  # Standard C sources
    1.10  SOURCES="$SOURCES $srcdir/src/*.c"
    1.11  SOURCES="$SOURCES $srcdir/src/audio/*.c"
    1.12 @@ -1007,6 +1005,8 @@
    1.13  dnl Find the X11 include and library directories
    1.14  CheckX11()
    1.15  {
    1.16 +
    1.17 +
    1.18      AC_ARG_ENABLE(video-x11,
    1.19  AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
    1.20                    , enable_video_x11=yes)
     2.1 --- a/src/events/SDL_gesture.c	Sat Jul 31 20:55:33 2010 -0700
     2.2 +++ b/src/events/SDL_gesture.c	Mon Aug 02 00:14:53 2010 -0400
     2.3 @@ -27,7 +27,7 @@
     2.4  #include "SDL_gesture_c.h"
     2.5  
     2.6  //TODO: Replace with malloc
     2.7 -#define MAXFINGERS 3
     2.8 +#define MAXFINGERS 5
     2.9  #define MAXTOUCHES 2
    2.10  #define MAXTEMPLATES 4
    2.11  #define MAXPATHSIZE 1024
    2.12 @@ -496,6 +496,7 @@
    2.13  	  }
    2.14  	} 
    2.15  	inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];
    2.16 +	j = -1;
    2.17  	break;
    2.18        }
    2.19        else {
     3.1 --- a/src/events/SDL_touch.c	Sat Jul 31 20:55:33 2010 -0700
     3.2 +++ b/src/events/SDL_touch.c	Mon Aug 02 00:14:53 2010 -0400
     3.3 @@ -392,8 +392,7 @@
     3.4      //scale to Integer coordinates
     3.5      Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres);
     3.6      Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres);
     3.7 -	Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres);
     3.8 -	printf("(%f,%f) --> (%i,%i)\n",xin,yin,x,y);
     3.9 +    Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres);
    3.10      if(touch->flush_motion) {
    3.11  	return 0;
    3.12      }
     4.1 --- a/src/video/x11/SDL_eventtouch.c	Sat Jul 31 20:55:33 2010 -0700
     4.2 +++ b/src/video/x11/SDL_eventtouch.c	Mon Aug 02 00:14:53 2010 -0400
     4.3 @@ -24,7 +24,8 @@
     4.4  #include "SDL_eventtouch.h"
     4.5  #include "../../events/SDL_touch_c.h"
     4.6  
     4.7 -#ifdef HAVE_LINUX_INPUT_H
     4.8 +
     4.9 +#ifdef SDL_INPUT_LINUXEV
    4.10  #include <linux/input.h>
    4.11  #include <fcntl.h>
    4.12  #endif
    4.13 @@ -32,7 +33,7 @@
    4.14  void
    4.15  X11_InitTouch(_THIS)
    4.16  {
    4.17 -#ifdef HAVE_LINUX_INPUT_H
    4.18 +#ifdef SDL_INPUT_LINUXEV
    4.19    printf("Initializing touch...\n");
    4.20  
    4.21    FILE *fd;
     5.1 --- a/src/video/x11/SDL_x11events.c	Sat Jul 31 20:55:33 2010 -0700
     5.2 +++ b/src/video/x11/SDL_x11events.c	Mon Aug 02 00:14:53 2010 -0400
     5.3 @@ -37,7 +37,7 @@
     5.4  
     5.5  #include <stdio.h>
     5.6  
     5.7 -#ifdef HAVE_LINUX_INPUT_H
     5.8 +#ifdef SDL_INPUT_LINUXEV
     5.9  //Touch Input/event* includes
    5.10  #include <linux/input.h>
    5.11  #include <fcntl.h>
    5.12 @@ -402,7 +402,7 @@
    5.13          X11_DispatchEvent(_this);
    5.14      }
    5.15  
    5.16 -#ifdef HAVE_LINUX_INPUT_H
    5.17 +#ifdef SDL_INPUT_LINUXEV
    5.18      /* Process Touch events - TODO When X gets touch support, use that instead*/
    5.19      int i = 0,rd;
    5.20      char name[256];
     6.1 --- a/touchTest/gestureSDLTest.c	Sat Jul 31 20:55:33 2010 -0700
     6.2 +++ b/touchTest/gestureSDLTest.c	Mon Aug 02 00:14:53 2010 -0400
     6.3 @@ -131,7 +131,7 @@
     6.4    
     6.5    memcpy(&colour,pixmem32,screen->format->BytesPerPixel);
     6.6  
     6.7 -  SDL_GetRGB(colour,screen->format,&r,&g,&b); //Always returns 0xFFFFFF?
     6.8 +  SDL_GetRGB(colour,screen->format,&r,&g,&b);
     6.9    //r = 0;g = 0; b = 0;
    6.10    a = (col>>24)&0xFF;
    6.11    if(a == 0) a = 0xFF; //Hack, to make things easier.
    6.12 @@ -400,8 +400,7 @@
    6.13  	    
    6.14  	    break;	    
    6.15  	  case SDL_FINGERDOWN:
    6.16 -	    printf("Finger: %"PRIs64" down - x: %i, y: %i\n",event.tfinger.fingerId,
    6.17 -		   event.tfinger.x,event.tfinger.y);
    6.18 +	    //printf("Finger: %"PRIs64" down - x: %i, y: %i\n",event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
    6.19  
    6.20  	    for(i = 0;i<MAXFINGERS;i++) 
    6.21  	      if(index2fingerid[i] == -1) {
    6.22 @@ -412,8 +411,7 @@
    6.23  	    finger[i].p.y = event.tfinger.y;
    6.24  	    break;
    6.25  	  case SDL_FINGERUP:
    6.26 -	    printf("Finger: %"PRIs64" up - x: %i, y: %i\n",event.tfinger.fingerId,
    6.27 -	           event.tfinger.x,event.tfinger.y);
    6.28 +	    //printf("Finger: %"PRIs64" up - x: %i, y: %i\n",event.tfinger.fingerId,event.tfinger.x,event.tfinger.y);
    6.29  	    for(i = 0;i<MAXFINGERS;i++) 
    6.30  	      if(index2fingerid[i] == event.tfinger.fingerId) {
    6.31  		index2fingerid[i] = -1;
    6.32 @@ -423,6 +421,11 @@
    6.33  	    finger[i].p.y = -1;
    6.34  	    break;
    6.35  	  case SDL_MULTIGESTURE:
    6.36 +	    printf("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f\n",
    6.37 +		   event.mgesture.x,
    6.38 +		   event.mgesture.y,
    6.39 +		   event.mgesture.dTheta,
    6.40 +		   event.mgesture.dDist);
    6.41  	    knob.p.x = event.mgesture.x;
    6.42  	    knob.p.y = event.mgesture.y;
    6.43  	    knob.ang += event.mgesture.dTheta;