Upgraded touchId/fingerId to long. Changed position variables to floats.
authorjimtla
Fri, 30 Jul 2010 23:18:35 +0400
changeset 467699b4560b7aa1
parent 4675 641c13b0ce5f
child 4677 31607094315c
Upgraded touchId/fingerId to long. Changed position variables to floats.
include/SDL_events.h
include/SDL_touch.h
src/events/SDL_touch.c
src/events/SDL_touch_c.h
src/video/cocoa/SDL_cocoawindow.m
src/video/uikit/SDL_uikitview.h
touchTest/gestureSDLTest.c
     1.1 --- a/include/SDL_events.h	Thu Jul 29 12:26:59 2010 -0400
     1.2 +++ b/include/SDL_events.h	Fri Jul 30 23:18:35 2010 +0400
     1.3 @@ -288,12 +288,14 @@
     1.4      Uint32 type;        /**< ::SDL_FINGERMOTION OR 
     1.5  			   SDL_FINGERDOWN OR SDL_FINGERUP*/
     1.6      Uint32 windowID;    /**< The window with mouse focus, if any */
     1.7 -    Uint8 touchId;        /**< The touch device id */
     1.8 +    long touchId;        /**< The touch device id */
     1.9 +    long fingerId;
    1.10      Uint8 state;        /**< The current button state */
    1.11 -    Uint8 fingerId;
    1.12      Uint8 padding1;
    1.13 -    int x;
    1.14 -    int y;
    1.15 +    Uint8 padding2;
    1.16 +    Uint8 padding3;
    1.17 +    float x;
    1.18 +    float y;
    1.19      int pressure;
    1.20  } SDL_TouchFingerEvent;
    1.21  
    1.22 @@ -305,11 +307,11 @@
    1.23  {
    1.24      Uint32 type;        /**< ::SDL_TOUCHBUTTONUP OR SDL_TOUCHBUTTONDOWN */
    1.25      Uint32 windowID;    /**< The window with mouse focus, if any */
    1.26 -    Uint8 touchId;        /**< The touch device index */
    1.27 +    long touchId;        /**< The touch device index */
    1.28      Uint8 state;        /**< The current button state */
    1.29      Uint8 button;        /**< The button changing state */
    1.30      Uint8 padding1;
    1.31 -
    1.32 +    Uint8 padding2;
    1.33  } SDL_TouchButtonEvent;
    1.34  
    1.35  
    1.36 @@ -321,10 +323,7 @@
    1.37  {
    1.38      Uint32 type;        /**< ::SDL_MULTIGESTURE */
    1.39      Uint32 windowID;    /**< The window with mouse focus, if any */
    1.40 -    Uint8 touchId;        /**< The touch device index */
    1.41 -    Uint8 padding1;
    1.42 -    Uint8 padding2;
    1.43 -    Uint8 padding3;
    1.44 +    long touchId;        /**< The touch device index */
    1.45      float dTheta;
    1.46      float dDist;
    1.47      float x;  //currently 0...1. Change to screen coords?
    1.48 @@ -336,10 +335,7 @@
    1.49  {
    1.50      Uint32 type;        /**< ::SDL_DOLLARGESTURE */
    1.51      Uint32 windowID;    /**< The window with mouse focus, if any */
    1.52 -    Uint8 touchId;        /**< The touch device index */
    1.53 -    Uint8 padding1;
    1.54 -    Uint8 padding2;
    1.55 -    Uint8 padding3;
    1.56 +    long touchId;        /**< The touch device index */
    1.57      unsigned long gestureId;
    1.58      float error;
    1.59    /*
     2.1 --- a/include/SDL_touch.h	Thu Jul 29 12:26:59 2010 -0400
     2.2 +++ b/include/SDL_touch.h	Fri Jul 30 23:18:35 2010 +0400
     2.3 @@ -43,15 +43,14 @@
     2.4  
     2.5  
     2.6  struct SDL_Finger {
     2.7 -  int id;
     2.8 -  int x;
     2.9 -  int y;
    2.10 -  int z;                      /* for future use */
    2.11 -  int xdelta;
    2.12 -  int ydelta;
    2.13 -  int last_x, last_y,last_pressure;  /* the last reported coordinates */
    2.14 +  long id;
    2.15 +  float x;
    2.16 +  float y;
    2.17 +  float xdelta;
    2.18 +  float ydelta;
    2.19 +  float last_x, last_y,last_pressure;  /* the last reported coordinates */
    2.20    SDL_bool down;
    2.21 -  int pressure;
    2.22 +  float pressure;
    2.23  };
    2.24  
    2.25  typedef struct SDL_Touch SDL_Touch;
    2.26 @@ -64,15 +63,15 @@
    2.27    void (*FreeTouch) (SDL_Touch * touch);
    2.28    
    2.29    /* data common for tablets */
    2.30 -  int pressure_max, pressure_min;
    2.31 -  int x_max,x_min;
    2.32 -  int y_max,y_min;
    2.33 -  int xres,yres,pressureres;
    2.34 -  int tilt;                   /* for future use */
    2.35 -  int rotation;               /* for future use */
    2.36 +  float pressure_max, pressure_min;
    2.37 +  float x_max,x_min;
    2.38 +  float y_max,y_min;
    2.39 +  float xres,yres,pressureres;
    2.40 +  float tilt;                   /* for future use */
    2.41 +  float rotation;               /* for future use */
    2.42    
    2.43    /* Data common to all touch */
    2.44 -  int id;
    2.45 +  long id;
    2.46    SDL_Window *focus;
    2.47    
    2.48    char *name;
    2.49 @@ -96,7 +95,7 @@
    2.50   *
    2.51   *
    2.52   */
    2.53 -  extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(int id);
    2.54 +  extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(long id);
    2.55  
    2.56  
    2.57  
    2.58 @@ -105,7 +104,7 @@
    2.59   *
    2.60   *
    2.61   */
    2.62 -  extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, int id);
    2.63 +  extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, long id);
    2.64  
    2.65  /* Ends C function definitions when using C++ */
    2.66  #ifdef __cplusplus
     3.1 --- a/src/events/SDL_touch.c	Thu Jul 29 12:26:59 2010 -0400
     3.2 +++ b/src/events/SDL_touch.c	Fri Jul 30 23:18:35 2010 +0400
     3.3 @@ -42,7 +42,7 @@
     3.4  }
     3.5  
     3.6  SDL_Touch *
     3.7 -SDL_GetTouch(int id)
     3.8 +SDL_GetTouch(long id)
     3.9  {
    3.10      int index = SDL_GetTouchIndexId(id);
    3.11      if (index < 0 || index >= SDL_num_touch) {
    3.12 @@ -61,7 +61,7 @@
    3.13  }
    3.14  
    3.15  int
    3.16 -SDL_GetFingerIndexId(SDL_Touch* touch,int fingerid)
    3.17 +SDL_GetFingerIndexId(SDL_Touch* touch,long fingerid)
    3.18  {
    3.19      int i;
    3.20      for(i = 0;i < touch->num_fingers;i++)
    3.21 @@ -72,7 +72,7 @@
    3.22  
    3.23  
    3.24  SDL_Finger *
    3.25 -SDL_GetFinger(SDL_Touch* touch,int id)
    3.26 +SDL_GetFinger(SDL_Touch* touch,long id)
    3.27  {
    3.28      int index = SDL_GetFingerIndexId(touch,id);
    3.29      if(index < 0 || index >= touch->num_fingers)
    3.30 @@ -82,7 +82,7 @@
    3.31  
    3.32  
    3.33  int
    3.34 -SDL_GetTouchIndexId(int id)
    3.35 +SDL_GetTouchIndexId(long id)
    3.36  {
    3.37      int index;
    3.38      SDL_Touch *touch;
    3.39 @@ -146,7 +146,7 @@
    3.40  }
    3.41  
    3.42  void
    3.43 -SDL_DelTouch(int id)
    3.44 +SDL_DelTouch(long id)
    3.45  {
    3.46      int index = SDL_GetTouchIndexId(id);
    3.47      SDL_Touch *touch = SDL_GetTouch(id);
    3.48 @@ -189,7 +189,7 @@
    3.49      return SDL_num_touch;
    3.50  }
    3.51  SDL_Window *
    3.52 -SDL_GetTouchFocusWindow(int id)
    3.53 +SDL_GetTouchFocusWindow(long id)
    3.54  {
    3.55      SDL_Touch *touch = SDL_GetTouch(id);
    3.56  
    3.57 @@ -200,7 +200,7 @@
    3.58  }
    3.59  
    3.60  void
    3.61 -SDL_SetTouchFocus(int id, SDL_Window * window)
    3.62 +SDL_SetTouchFocus(long id, SDL_Window * window)
    3.63  {
    3.64      int index = SDL_GetTouchIndexId(id);
    3.65      SDL_Touch *touch = SDL_GetTouch(id);
    3.66 @@ -250,12 +250,12 @@
    3.67  }
    3.68  
    3.69  int 
    3.70 -SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
    3.71 +SDL_AddFinger(SDL_Touch* touch,SDL_Finger finger)
    3.72  {
    3.73      int index;
    3.74      SDL_Finger **fingers;
    3.75      //printf("Adding Finger...\n");
    3.76 -    if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
    3.77 +    if (SDL_GetFingerIndexId(touch,finger.id) != -1) {
    3.78          SDL_SetError("Finger ID already in use");
    3.79  	}
    3.80  
    3.81 @@ -282,14 +282,14 @@
    3.82          SDL_OutOfMemory();
    3.83          return -1;
    3.84      }
    3.85 -    *(touch->fingers[index]) = *finger;
    3.86 +    *(touch->fingers[index]) = finger;
    3.87      touch->num_fingers++;
    3.88  
    3.89      return index;
    3.90  }
    3.91  
    3.92  int
    3.93 -SDL_DelFinger(SDL_Touch* touch,int fingerid)
    3.94 +SDL_DelFinger(SDL_Touch* touch,long fingerid)
    3.95  {
    3.96      int index = SDL_GetFingerIndexId(touch,fingerid);
    3.97      SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
    3.98 @@ -307,7 +307,7 @@
    3.99  
   3.100  
   3.101  int
   3.102 -SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure)
   3.103 +SDL_SendFingerDown(long id, long fingerid, SDL_bool down, float x, float y, float pressure)
   3.104  {
   3.105      int posted;
   3.106      SDL_Touch* touch = SDL_GetTouch(id);
   3.107 @@ -330,7 +330,7 @@
   3.108  	    nf.last_y = y;
   3.109  	    nf.last_pressure = pressure;
   3.110  	    nf.down = SDL_FALSE;
   3.111 -	    SDL_AddFinger(touch,&nf);
   3.112 +	    SDL_AddFinger(touch,nf);
   3.113  	    finger = &nf;
   3.114  	}
   3.115  	else if(finger->down) return 0;
   3.116 @@ -339,7 +339,7 @@
   3.117  	if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
   3.118  	    SDL_Event event;
   3.119  	    event.tfinger.type = SDL_FINGERDOWN;
   3.120 -	    event.tfinger.touchId = (Uint8) id;
   3.121 +	    event.tfinger.touchId = id;
   3.122  	    event.tfinger.x = x;
   3.123  	    event.tfinger.y = y;
   3.124  	    event.tfinger.state = touch->buttonstate;
   3.125 @@ -356,7 +356,7 @@
   3.126  	if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
   3.127  	    SDL_Event event;
   3.128  	    event.tfinger.type = SDL_FINGERUP;
   3.129 -	    event.tfinger.touchId = (Uint8) id;
   3.130 +	    event.tfinger.touchId =  id;
   3.131  	    event.tfinger.state = touch->buttonstate;
   3.132  	    event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
   3.133  	    event.tfinger.fingerId = fingerid;
   3.134 @@ -367,16 +367,16 @@
   3.135  }
   3.136  
   3.137  int
   3.138 -SDL_SendTouchMotion(int id, int fingerid, int relative, 
   3.139 -		    int x, int y, int pressure)
   3.140 +SDL_SendTouchMotion(long id, long fingerid, int relative, 
   3.141 +		    float x, float y, float pressure)
   3.142  {
   3.143      int index = SDL_GetTouchIndexId(id);
   3.144      SDL_Touch *touch = SDL_GetTouch(id);
   3.145      SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
   3.146      int posted;
   3.147 -    int xrel;
   3.148 -    int yrel;
   3.149 -    int x_max = 0, y_max = 0;
   3.150 +    float xrel;
   3.151 +    float yrel;
   3.152 +    float x_max = 0, y_max = 0;
   3.153      
   3.154      if (!touch) {
   3.155        return SDL_TouchNotFoundError(id);
   3.156 @@ -444,8 +444,8 @@
   3.157  	if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
   3.158  	    SDL_Event event;
   3.159  	    event.tfinger.type = SDL_FINGERMOTION;
   3.160 -	    event.tfinger.touchId = (Uint8) id;
   3.161 -	    event.tfinger.fingerId = (Uint8) fingerid;
   3.162 +	    event.tfinger.touchId = id;
   3.163 +	    event.tfinger.fingerId = fingerid;
   3.164  	    event.tfinger.x = x;
   3.165  	    event.tfinger.y = y;
   3.166  	    event.tfinger.pressure = pressure;
   3.167 @@ -460,7 +460,7 @@
   3.168      }
   3.169  }
   3.170  int
   3.171 -SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
   3.172 +SDL_SendTouchButton(long id, Uint8 state, Uint8 button)
   3.173  {
   3.174      SDL_Touch *touch = SDL_GetTouch(id);
   3.175      int posted;
   3.176 @@ -499,7 +499,7 @@
   3.177      if (SDL_GetEventState(type) == SDL_ENABLE) {
   3.178          SDL_Event event;
   3.179          event.type = type;
   3.180 -        event.tbutton.touchId = (Uint8) touch->id;
   3.181 +        event.tbutton.touchId = touch->id;
   3.182          event.tbutton.state = state;
   3.183          event.tbutton.button = button;
   3.184          event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
   3.185 @@ -509,7 +509,7 @@
   3.186  }
   3.187  
   3.188  char *
   3.189 -SDL_GetTouchName(int id)
   3.190 +SDL_GetTouchName(long id)
   3.191  {
   3.192      SDL_Touch *touch = SDL_GetTouch(id);
   3.193      if (!touch) {
   3.194 @@ -518,12 +518,12 @@
   3.195      return touch->name;
   3.196  }
   3.197  
   3.198 -int SDL_TouchNotFoundError(int id) {
   3.199 -  printf("ERROR: Cannot send touch on non-existent device with id: %i make sure SDL_AddTouch has been called\n",id);
   3.200 +int SDL_TouchNotFoundError(long id) {
   3.201 +  printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
   3.202    printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
   3.203    int i;
   3.204    for(i=0;i < SDL_num_touch;i++) {
   3.205 -    printf("ERROR: %i\n",SDL_touchPads[i]->id);
   3.206 +    printf("ERROR: %li\n",SDL_touchPads[i]->id);
   3.207    }
   3.208    return 0;
   3.209  }
     4.1 --- a/src/events/SDL_touch_c.h	Thu Jul 29 12:26:59 2010 -0400
     4.2 +++ b/src/events/SDL_touch_c.h	Fri Jul 30 23:18:35 2010 +0400
     4.3 @@ -34,13 +34,13 @@
     4.4  extern SDL_Touch *SDL_GetTouchIndex(int index);
     4.5  
     4.6  /* Get the touch with id = id */
     4.7 -extern SDL_Touch *SDL_GetTouch(int id);
     4.8 +extern SDL_Touch *SDL_GetTouch(long id);
     4.9  
    4.10  /*Get the finger at an index */
    4.11  extern SDL_Finger *SDL_GetFingerIndex(SDL_Touch *touch, int index);
    4.12  
    4.13  /* Get the finger with id = id */
    4.14 -extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,int id);
    4.15 +extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,long id);
    4.16  
    4.17  
    4.18  /* Add a touch, possibly reattaching at a particular index (or -1),
    4.19 @@ -49,26 +49,23 @@
    4.20                       
    4.21  
    4.22  /* Remove a touch at an index, clearing the slot for later */
    4.23 -extern void SDL_DelTouch(int index);
    4.24 +extern void SDL_DelTouch(long id);
    4.25  
    4.26  /* Set the touch focus window */
    4.27 -extern void SDL_SetTouchFocus(int id, SDL_Window * window);
    4.28 +extern void SDL_SetTouchFocus(long id, SDL_Window * window);
    4.29  
    4.30  /* Send a touch motion event for a touch */
    4.31 -extern int SDL_SendTouchMotion(int id, int fingerid,
    4.32 -			       int relative, int x, int y, int z);
    4.33 +extern int SDL_SendTouchMotion(long id, long fingerid,
    4.34 +			       int relative, float x, float y, float z);
    4.35  
    4.36  /* Send a touch button event for a touch */
    4.37 -extern int SDL_SendTouchButton(int id, Uint8 state, Uint8 button);
    4.38 +extern int SDL_SendTouchButton(long id, Uint8 state, Uint8 button);
    4.39  
    4.40  /* Shutdown the touch subsystem */
    4.41  extern void SDL_TouchQuit(void);
    4.42  
    4.43  /* Get the index of a touch device */
    4.44 -extern int SDL_GetTouchIndexId(int id);
    4.45 -
    4.46 -
    4.47 -
    4.48 +extern int SDL_GetTouchIndexId(long id);
    4.49  
    4.50  #endif /* _SDL_touch_c_h */
    4.51  
     5.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Thu Jul 29 12:26:59 2010 -0400
     5.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Jul 30 23:18:35 2010 +0400
     5.3 @@ -27,7 +27,6 @@
     5.4  #include "../../events/SDL_mouse_c.h"
     5.5  #include "../../events/SDL_touch_c.h"
     5.6  #include "../../events/SDL_windowevents_c.h"
     5.7 -
     5.8  #include "SDL_cocoavideo.h"
     5.9  
    5.10  static __inline__ void ConvertNSRect(NSRect *r)
    5.11 @@ -299,7 +298,7 @@
    5.12      while (touch) {
    5.13          long touchId = (long)[touch device];
    5.14          if (!SDL_GetTouch(touchId)) {
    5.15 -	  printf("Adding touch: %i\n",touchId)
    5.16 +	  printf("Adding touch: %li\n",touchId);
    5.17              SDL_Touch touch;
    5.18  
    5.19              touch.id = touchId;
    5.20 @@ -316,7 +315,7 @@
    5.21              if (SDL_AddTouch(&touch, "") < 0) {
    5.22                  continue;
    5.23              }
    5.24 -	    printf("Success, added touch: %i\n",touchId)
    5.25 +	    printf("Success, added touch: %lin",touchId);
    5.26          } 
    5.27          float x = [touch normalizedPosition].x;
    5.28          float y = [touch normalizedPosition].y;
     6.1 --- a/src/video/uikit/SDL_uikitview.h	Thu Jul 29 12:26:59 2010 -0400
     6.2 +++ b/src/video/uikit/SDL_uikitview.h	Fri Jul 30 23:18:35 2010 +0400
     6.3 @@ -35,7 +35,7 @@
     6.4  #endif
     6.5  
     6.6  #if FIXED_MULTITOUCH
     6.7 -	int touchId;
     6.8 +	long touchId;
     6.9  #ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    6.10  	UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
    6.11  #endif
     7.1 --- a/touchTest/gestureSDLTest.c	Thu Jul 29 12:26:59 2010 -0400
     7.2 +++ b/touchTest/gestureSDLTest.c	Fri Jul 30 23:18:35 2010 +0400
     7.3 @@ -28,7 +28,7 @@
     7.4  
     7.5  int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
     7.6  
     7.7 -int index2fingerid[MAXFINGERS];
     7.8 +long index2fingerid[MAXFINGERS];
     7.9  int fingersDown;
    7.10  
    7.11  typedef struct {
    7.12 @@ -38,7 +38,7 @@
    7.13  typedef struct {
    7.14    Point p;
    7.15    float pressure;
    7.16 -  int id;
    7.17 +  long id;
    7.18  } Finger;
    7.19  
    7.20  typedef struct {
    7.21 @@ -378,7 +378,7 @@
    7.22  	    
    7.23  	    break;	    
    7.24  	  case SDL_FINGERDOWN:
    7.25 -	    printf("Finger: %i down - x: %i, y: %i\n",event.tfinger.fingerId,
    7.26 +	    printf("Finger: %li down - x: %f, y: %f\n",event.tfinger.fingerId,
    7.27  		   event.tfinger.x,event.tfinger.y);
    7.28  
    7.29  	    for(i = 0;i<MAXFINGERS;i++) 
    7.30 @@ -390,7 +390,7 @@
    7.31  	    finger[i].p.y = event.tfinger.y;
    7.32  	    break;
    7.33  	  case SDL_FINGERUP:
    7.34 -	    printf("Figner: %i up - x: %i, y: %i\n",event.tfinger.fingerId,
    7.35 +	    printf("Figner: %li up - x: %f, y: %f\n",event.tfinger.fingerId,
    7.36  	           event.tfinger.x,event.tfinger.y);
    7.37  	    for(i = 0;i<MAXFINGERS;i++) 
    7.38  	      if(index2fingerid[i] == event.tfinger.fingerId) {