Fixed various type and print format issues
authorSam Lantinga <slouken@libsdl.org>
Sat, 31 Jul 2010 20:38:37 -0700
changeset 46795ee96ba0c01e
parent 4678 f8431f66613d
child 4680 229529693289
Fixed various type and print format issues
include/SDL_gesture.h
include/SDL_touch.h
src/events/SDL_touch.c
src/video/cocoa/SDL_cocoawindow.m
touchTest/gestureSDLTest.c
     1.1 --- a/include/SDL_gesture.h	Sat Jul 31 20:02:54 2010 +0400
     1.2 +++ b/include/SDL_gesture.h	Sat Jul 31 20:38:37 2010 -0700
     1.3 @@ -44,7 +44,7 @@
     1.4  /* *INDENT-ON* */
     1.5  #endif
     1.6  
     1.7 -  typedef Uint64 SDL_GestureID;
     1.8 +typedef Sint64 SDL_GestureID;
     1.9  
    1.10  /* Function prototypes */
    1.11  
    1.12 @@ -53,7 +53,7 @@
    1.13   *
    1.14   *
    1.15   */
    1.16 -  extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
    1.17 +extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
    1.18  
    1.19  
    1.20  /**
    1.21 @@ -61,15 +61,14 @@
    1.22   *
    1.23   *
    1.24   */
    1.25 -  extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src);
    1.26 +extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src);
    1.27  
    1.28  /**
    1.29   *  \brief Save a currently loaded Dollar Gesture template
    1.30   *
    1.31   *
    1.32   */
    1.33 -  extern DECLSPEC int 
    1.34 -  SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);
    1.35 +extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src);
    1.36  
    1.37  
    1.38  /**
    1.39 @@ -77,9 +76,7 @@
    1.40   *
    1.41   *
    1.42   */
    1.43 -  extern DECLSPEC 
    1.44 -  int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
    1.45 -
    1.46 +extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
    1.47  
    1.48  
    1.49  /* Ends C function definitions when using C++ */
     2.1 --- a/include/SDL_touch.h	Sat Jul 31 20:02:54 2010 +0400
     2.2 +++ b/include/SDL_touch.h	Sat Jul 31 20:38:37 2010 -0700
     2.3 @@ -42,8 +42,8 @@
     2.4  #endif
     2.5  
     2.6  
     2.7 -typedef Uint64 SDL_TouchID;
     2.8 -typedef Uint64 SDL_FingerID;
     2.9 +typedef Sint64 SDL_TouchID;
    2.10 +typedef Sint64 SDL_FingerID;
    2.11  
    2.12  
    2.13  struct SDL_Finger {
     3.1 --- a/src/events/SDL_touch.c	Sat Jul 31 20:02:54 2010 +0400
     3.2 +++ b/src/events/SDL_touch.c	Sat Jul 31 20:38:37 2010 -0700
     3.3 @@ -393,7 +393,7 @@
     3.4      Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres);
     3.5      Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres);
     3.6  	Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres);
     3.7 -	printf("(%f,%f) --> (%i,%i)",xin,yin,x,y);
     3.8 +	printf("(%f,%f) --> (%i,%i)\n",xin,yin,x,y);
     3.9      if(touch->flush_motion) {
    3.10  	return 0;
    3.11      }
     4.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 31 20:02:54 2010 +0400
     4.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 31 20:38:37 2010 -0700
     4.3 @@ -315,7 +315,7 @@
     4.4              if (SDL_AddTouch(&touch, "") < 0) {
     4.5                  continue;
     4.6              }
     4.7 -	    printf("Success, added touch: %lin",touchId);
     4.8 +	    printf("Success, added touch: %li\n",touchId);
     4.9          } 
    4.10          float x = [touch normalizedPosition].x;
    4.11          float y = [touch normalizedPosition].y;
     5.1 --- a/touchTest/gestureSDLTest.c	Sat Jul 31 20:02:54 2010 +0400
     5.2 +++ b/touchTest/gestureSDLTest.c	Sat Jul 31 20:38:37 2010 -0700
     5.3 @@ -4,6 +4,28 @@
     5.4  #include <SDL_touch.h>
     5.5  #include <SDL_gesture.h>
     5.6  
     5.7 +/* Make sure we have good macros for printing 32 and 64 bit values */
     5.8 +#ifndef PRIs32
     5.9 +#define PRIs32 "d"
    5.10 +#endif
    5.11 +#ifndef PRIu32
    5.12 +#define PRIu32 "u"
    5.13 +#endif
    5.14 +#ifndef PRIs64
    5.15 +#ifdef __WIN32__
    5.16 +#define PRIs64 "I64"
    5.17 +#else
    5.18 +#define PRIs64 "lld"
    5.19 +#endif
    5.20 +#endif
    5.21 +#ifndef PRIu64
    5.22 +#ifdef __WIN32__
    5.23 +#define PRIu64 "I64u"
    5.24 +#else
    5.25 +#define PRIu64 "llu"
    5.26 +#endif
    5.27 +#endif
    5.28 +
    5.29  #define PI 3.1415926535897
    5.30  #define PHI ((sqrt(5)-1)/2)
    5.31  #define WIDTH 640
    5.32 @@ -28,7 +50,7 @@
    5.33  
    5.34  int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
    5.35  
    5.36 -long index2fingerid[MAXFINGERS];
    5.37 +SDL_FingerID index2fingerid[MAXFINGERS];
    5.38  int fingersDown;
    5.39  
    5.40  typedef struct {
    5.41 @@ -38,7 +60,7 @@
    5.42  typedef struct {
    5.43    Point p;
    5.44    float pressure;
    5.45 -  long id;
    5.46 +  SDL_FingerID id;
    5.47  } Finger;
    5.48  
    5.49  typedef struct {
    5.50 @@ -378,7 +400,7 @@
    5.51  	    
    5.52  	    break;	    
    5.53  	  case SDL_FINGERDOWN:
    5.54 -	    printf("Finger: %li down - x: %f, y: %f\n",event.tfinger.fingerId,
    5.55 +	    printf("Finger: %"PRIs64" down - x: %i, y: %i\n",event.tfinger.fingerId,
    5.56  		   event.tfinger.x,event.tfinger.y);
    5.57  
    5.58  	    for(i = 0;i<MAXFINGERS;i++) 
    5.59 @@ -390,7 +412,7 @@
    5.60  	    finger[i].p.y = event.tfinger.y;
    5.61  	    break;
    5.62  	  case SDL_FINGERUP:
    5.63 -	    printf("Figner: %li up - x: %f, y: %f\n",event.tfinger.fingerId,
    5.64 +	    printf("Finger: %"PRIs64" up - x: %i, y: %i\n",event.tfinger.fingerId,
    5.65  	           event.tfinger.x,event.tfinger.y);
    5.66  	    for(i = 0;i<MAXFINGERS;i++) 
    5.67  	      if(index2fingerid[i] == event.tfinger.fingerId) {
    5.68 @@ -407,12 +429,12 @@
    5.69  	    knob.r += event.mgesture.dDist;
    5.70  	    break;
    5.71  	  case SDL_DOLLARGESTURE:
    5.72 -	    printf("Gesture %lu performed, error: %f\n",
    5.73 +	    printf("Gesture %"PRIs64" performed, error: %f\n",
    5.74  		   event.dgesture.gestureId,
    5.75  		   event.dgesture.error);
    5.76  	    break;
    5.77  	  case SDL_DOLLARRECORD:
    5.78 -	    printf("Recorded gesture: %lu\n",event.dgesture.gestureId);
    5.79 +	    printf("Recorded gesture: %"PRIs64"\n",event.dgesture.gestureId);
    5.80  	    break;
    5.81  	  }
    5.82        }