Fixed compiling with Visual Studio 2008
authorSam Lantinga
Sun, 29 Aug 2010 14:22:22 -0700
changeset 4868d6adaafcfb10
parent 4867 ba7492f9e2b8
child 4869 2b1bcf74e4c4
Fixed compiling with Visual Studio 2008
VisualC/SDL/SDL_VS2008.vcproj
src/events/SDL_gesture.c
src/events/SDL_touch.c
src/haptic/nds/SDL_syshaptic.c
src/stdlib/SDL_stdlib.c
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32video.h
     1.1 --- a/VisualC/SDL/SDL_VS2008.vcproj	Sun Aug 29 12:00:09 2010 -0700
     1.2 +++ b/VisualC/SDL/SDL_VS2008.vcproj	Sun Aug 29 14:22:22 2010 -0700
     1.3 @@ -76,7 +76,7 @@
     1.4  			/>
     1.5  			<Tool
     1.6  				Name="VCLinkerTool"
     1.7 -				AdditionalDependencies="msimg32.lib winmm.lib"
     1.8 +				AdditionalDependencies="msimg32.lib winmm.lib imm32.lib version.lib"
     1.9  				OutputFile="$(IntDir)\SDL.dll"
    1.10  				IgnoreAllDefaultLibraries="true"
    1.11  				GenerateDebugInformation="true"
    1.12 @@ -249,7 +249,7 @@
    1.13  			/>
    1.14  			<Tool
    1.15  				Name="VCLinkerTool"
    1.16 -				AdditionalDependencies="msimg32.lib winmm.lib"
    1.17 +				AdditionalDependencies="msimg32.lib winmm.lib imm32.lib version.lib"
    1.18  				OutputFile="$(IntDir)\SDL.dll"
    1.19  				IgnoreAllDefaultLibraries="true"
    1.20  				SubSystem="2"
    1.21 @@ -840,6 +840,14 @@
    1.22  			>
    1.23  		</File>
    1.24  		<File
    1.25 +			RelativePath="..\..\src\events\SDL_gesture.c"
    1.26 +			>
    1.27 +		</File>
    1.28 +		<File
    1.29 +			RelativePath="..\..\src\events\SDL_gesture_c.h"
    1.30 +			>
    1.31 +		</File>
    1.32 +		<File
    1.33  			RelativePath="..\..\src\stdlib\SDL_getenv.c"
    1.34  			>
    1.35  		</File>
    1.36 @@ -1004,6 +1012,14 @@
    1.37  			>
    1.38  		</File>
    1.39  		<File
    1.40 +			RelativePath="..\..\src\video\SDL_shape.c"
    1.41 +			>
    1.42 +		</File>
    1.43 +		<File
    1.44 +			RelativePath="..\..\src\video\SDL_shape_internals.h"
    1.45 +			>
    1.46 +		</File>
    1.47 +		<File
    1.48  			RelativePath="..\..\src\stdlib\SDL_stdlib.c"
    1.49  			>
    1.50  		</File>
    1.51 @@ -1096,6 +1112,14 @@
    1.52  			>
    1.53  		</File>
    1.54  		<File
    1.55 +			RelativePath="..\..\src\events\SDL_touch.c"
    1.56 +			>
    1.57 +		</File>
    1.58 +		<File
    1.59 +			RelativePath="..\..\src\events\SDL_touch_c.h"
    1.60 +			>
    1.61 +		</File>
    1.62 +		<File
    1.63  			RelativePath="..\..\src\video\SDL_video.c"
    1.64  			>
    1.65  		</File>
    1.66 @@ -1168,6 +1192,14 @@
    1.67  			>
    1.68  		</File>
    1.69  		<File
    1.70 +			RelativePath="..\..\src\video\win32\SDL_win32shape.c"
    1.71 +			>
    1.72 +		</File>
    1.73 +		<File
    1.74 +			RelativePath="..\..\src\video\win32\SDL_win32shape.h"
    1.75 +			>
    1.76 +		</File>
    1.77 +		<File
    1.78  			RelativePath="..\..\src\video\win32\SDL_win32video.c"
    1.79  			>
    1.80  		</File>
     2.1 --- a/src/events/SDL_gesture.c	Sun Aug 29 12:00:09 2010 -0700
     2.2 +++ b/src/events/SDL_gesture.c	Sun Aug 29 14:22:22 2010 -0700
     2.3 @@ -44,7 +44,6 @@
     2.4  
     2.5  #define ENABLE_DOLLAR
     2.6  
     2.7 -//PHI = ((sqrt(5)-1)/2)
     2.8  #define PHI 0.618033989 
     2.9  
    2.10  typedef struct {
    2.11 @@ -80,7 +79,8 @@
    2.12  int SDL_numGestureTouches = 0;
    2.13  SDL_bool recordAll;
    2.14  
    2.15 -void SDL_PrintPath(SDL_FloatPoint *path) {
    2.16 +#if 0
    2.17 +static void PrintPath(SDL_FloatPoint *path) {
    2.18    int i;
    2.19    printf("Path:");
    2.20    for(i=0;i<DOLLARNPOINTS;i++) {
    2.21 @@ -88,6 +88,7 @@
    2.22    }
    2.23    printf("\n");
    2.24  }
    2.25 +#endif
    2.26  
    2.27  int SDL_RecordGesture(SDL_TouchID touchId) {
    2.28    int i;
    2.29 @@ -177,7 +178,7 @@
    2.30  
    2.31      templ = 
    2.32  	&inTouch->dollarTemplate[inTouch->numDollarTemplates];
    2.33 -      memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
    2.34 +      SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
    2.35        templ->hash = SDL_HashDollar(templ->path);
    2.36        inTouch->numDollarTemplates++;    
    2.37      }
    2.38 @@ -196,7 +197,7 @@
    2.39  
    2.40      templ = 
    2.41        &inTouch->dollarTemplate[inTouch->numDollarTemplates];
    2.42 -    memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
    2.43 +    SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
    2.44      templ->hash = SDL_HashDollar(templ->path);
    2.45      inTouch->numDollarTemplates++;
    2.46      return inTouch->numDollarTemplates - 1;
    2.47 @@ -222,14 +223,14 @@
    2.48         DOLLARNPOINTS) break;
    2.49  
    2.50      if(touchId >= 0) {
    2.51 -      printf("Adding loaded gesture to 1 touch\n");
    2.52 +      //printf("Adding loaded gesture to 1 touch\n");
    2.53        if(SDL_AddDollarGesture(touch,templ.path)) loaded++;
    2.54      }
    2.55      else {
    2.56 -      printf("Adding to: %i touches\n",SDL_numGestureTouches);
    2.57 +      //printf("Adding to: %i touches\n",SDL_numGestureTouches);
    2.58        for(i = 0;i < SDL_numGestureTouches; i++) {
    2.59  	touch = &SDL_gestureTouch[i];
    2.60 -	printf("Adding loaded gesture to + touches\n");
    2.61 +	//printf("Adding loaded gesture to + touches\n");
    2.62  	//TODO: What if this fails?
    2.63  	SDL_AddDollarGesture(touch,templ.path);	
    2.64        }
    2.65 @@ -247,9 +248,9 @@
    2.66    SDL_FloatPoint p;
    2.67    int i;
    2.68    for(i = 0; i < DOLLARNPOINTS; i++) {
    2.69 -    p.x = (float)(points[i].x * cos(ang) - points[i].y * sin(ang));
    2.70 -    p.y = (float)(points[i].x * sin(ang) + points[i].y * cos(ang));
    2.71 -    dist += (float)(sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
    2.72 +    p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang));
    2.73 +    p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang));
    2.74 +    dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
    2.75  		 (p.y-templ[i].y)*(p.y-templ[i].y)));
    2.76    }
    2.77    return dist/DOLLARNPOINTS;
    2.78 @@ -267,7 +268,7 @@
    2.79    float f1 = dollarDifference(points,templ,x1);
    2.80    float x2 = (float)((1-PHI)*ta + PHI*tb);
    2.81    float f2 = dollarDifference(points,templ,x2);
    2.82 -  while(fabs(ta-tb) > dt) {
    2.83 +  while(SDL_fabs(ta-tb) > dt) {
    2.84      if(f1 < f2) {
    2.85        tb = x2;
    2.86        x2 = x1;
    2.87 @@ -310,7 +311,7 @@
    2.88  	         path.p[i-1].x;
    2.89        float dy = path.p[i  ].y - 
    2.90  	         path.p[i-1].y;
    2.91 -      path.length += (float)(sqrt(dx*dx+dy*dy));
    2.92 +      path.length += (float)(SDL_sqrt(dx*dx+dy*dy));
    2.93      }
    2.94    }
    2.95  
    2.96 @@ -322,7 +323,7 @@
    2.97    
    2.98    //printf("(%f,%f)\n",path.p[path.numPoints-1].x,path.p[path.numPoints-1].y);
    2.99    for(i = 1;i < path.numPoints;i++) {
   2.100 -    float d = (float)(sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
   2.101 +    float d = (float)(SDL_sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
   2.102  		             (path.p[i-1].y-path.p[i].y)*(path.p[i-1].y-path.p[i].y)));
   2.103      //printf("d = %f dist = %f/%f\n",d,dist,interval);
   2.104      while(dist + d > interval) {
   2.105 @@ -339,7 +340,7 @@
   2.106      dist += d;
   2.107    }
   2.108    if(numPoints < DOLLARNPOINTS-1) {
   2.109 -    printf("ERROR: NumPoints = %i\n",numPoints); 
   2.110 +    SDL_SetError("ERROR: NumPoints = %i\n",numPoints); 
   2.111      return 0;
   2.112    }
   2.113    //copy the last point
   2.114 @@ -356,16 +357,16 @@
   2.115    ymin = centroid.y;
   2.116    ymax = centroid.y;
   2.117    
   2.118 -  ang = (float)(atan2(centroid.y - points[0].y,
   2.119 +  ang = (float)(SDL_atan2(centroid.y - points[0].y,
   2.120  		    centroid.x - points[0].x));
   2.121  
   2.122    for(i = 0;i<numPoints;i++) {					       
   2.123      float px = points[i].x;
   2.124      float py = points[i].y;
   2.125 -    points[i].x = (float)((px - centroid.x)*cos(ang) - 
   2.126 -                  (py - centroid.y)*sin(ang) + centroid.x);
   2.127 -    points[i].y = (float)((px - centroid.x)*sin(ang) + 
   2.128 -                  (py - centroid.y)*cos(ang) + centroid.y);
   2.129 +    points[i].x = (float)((px - centroid.x)*SDL_cos(ang) - 
   2.130 +                  (py - centroid.y)*SDL_sin(ang) + centroid.x);
   2.131 +    points[i].y = (float)((px - centroid.x)*SDL_sin(ang) + 
   2.132 +                  (py - centroid.y)*SDL_cos(ang) + centroid.y);
   2.133  
   2.134  
   2.135      if(points[i].x < xmin) xmin = points[i].x;
   2.136 @@ -389,10 +390,10 @@
   2.137  	
   2.138  	SDL_FloatPoint points[DOLLARNPOINTS];
   2.139  	int numPoints = dollarNormalize(path,points);
   2.140 -	//SDL_PrintPath(points);
   2.141  	int i;
   2.142 -	
   2.143  	float bestDiff = 10000;
   2.144 +
   2.145 +	//PrintPath(points);
   2.146  	*bestTempl = -1;
   2.147  	for(i = 0;i < touch->numDollarTemplates;i++) {
   2.148  		float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
   2.149 @@ -430,10 +431,10 @@
   2.150  
   2.151  int SDL_GestureRemoveTouch(SDL_TouchID id) {
   2.152    int i;
   2.153 -  for(i = 0;i < SDL_numGestureTouches; i++) {
   2.154 -    if(SDL_gestureTouch[i].id == id) {
   2.155 +  for (i = 0; i < SDL_numGestureTouches; i++) {
   2.156 +    if (SDL_gestureTouch[i].id == id) {
   2.157        SDL_numGestureTouches--;
   2.158 -      SDL_gestureTouch[i] = SDL_gestureTouch[SDL_numGestureTouches];
   2.159 +      SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i]));
   2.160        return 1;
   2.161      }
   2.162    }
   2.163 @@ -528,7 +529,7 @@
   2.164        if(inTouch->recording) {
   2.165  	inTouch->recording = SDL_FALSE;	
   2.166  	dollarNormalize(inTouch->dollarPath,path);
   2.167 -	//SDL_PrintPath(path);
   2.168 +	//PrintPath(path);
   2.169  	if(recordAll) {
   2.170  	  index = SDL_AddDollarGesture(NULL,path);
   2.171  	  for(i = 0;i < SDL_numGestureTouches; i++)
   2.172 @@ -579,7 +580,7 @@
   2.173  	  (path->p[path->numPoints].x-path->p[path->numPoints-1].x);
   2.174  	pathDy = 
   2.175  	  (path->p[path->numPoints].y-path->p[path->numPoints-1].y);
   2.176 -	path->length += (float)sqrt(pathDx*pathDx + pathDy*pathDy);
   2.177 +	path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
   2.178  	path->numPoints++;
   2.179        }
   2.180  #endif
   2.181 @@ -596,20 +597,20 @@
   2.182  	//lv = inTouch->gestureLast[j].cv;
   2.183  	lv.x = lastP.x - lastCentroid.x;
   2.184  	lv.y = lastP.y - lastCentroid.y;
   2.185 -	lDist = (float)sqrt(lv.x*lv.x + lv.y*lv.y);
   2.186 +	lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
   2.187  	//printf("lDist = %f\n",lDist);
   2.188  	v.x = x - inTouch->centroid.x;
   2.189  	v.y = y - inTouch->centroid.y;
   2.190  	//inTouch->gestureLast[j].cv = v;
   2.191 -	Dist = (float)sqrt(v.x*v.x+v.y*v.y);
   2.192 -	// cos(dTheta) = (v . lv)/(|v| * |lv|)
   2.193 +	Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
   2.194 +	// SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)
   2.195  	
   2.196  	//Normalize Vectors to simplify angle calculation
   2.197  	lv.x/=lDist;
   2.198  	lv.y/=lDist;
   2.199  	v.x/=Dist;
   2.200  	v.y/=Dist;
   2.201 -	dtheta = (float)atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
   2.202 +	dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
   2.203  	
   2.204  	dDist = (Dist - lDist);
   2.205  	if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values
     3.1 --- a/src/events/SDL_touch.c	Sun Aug 29 12:00:09 2010 -0700
     3.2 +++ b/src/events/SDL_touch.c	Sun Aug 29 14:22:22 2010 -0700
     3.3 @@ -366,7 +366,10 @@
     3.4  	return posted;
     3.5      }
     3.6      else {
     3.7 -        if(finger == NULL) {printf("Finger not found...\n");return 0;}      
     3.8 +        if(finger == NULL) {
     3.9 +            SDL_SetError("Finger not found.");
    3.10 +            return 0;
    3.11 +        }      
    3.12  	posted = 0;
    3.13  	if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
    3.14  	    SDL_Event event;
    3.15 @@ -552,12 +555,14 @@
    3.16  }
    3.17  
    3.18  int SDL_TouchNotFoundError(SDL_TouchID id) {
    3.19 -  int i;
    3.20 -  printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
    3.21 +  //int i;
    3.22 +  SDL_SetError("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
    3.23 +#if 0
    3.24    printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
    3.25    for(i=0;i < SDL_num_touch;i++) {
    3.26      printf("ERROR: %li\n",SDL_touchPads[i]->id);
    3.27    }
    3.28 +#endif
    3.29    return 0;
    3.30  }
    3.31  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/haptic/nds/SDL_syshaptic.c	Sun Aug 29 12:00:09 2010 -0700
     4.2 +++ b/src/haptic/nds/SDL_syshaptic.c	Sun Aug 29 14:22:22 2010 -0700
     4.3 @@ -52,8 +52,9 @@
     4.4      GBA_BUS[0x0020000] = 0x1500;
     4.5      GBA_BUS[0x0E20000] = 0x1500;
     4.6      GBA_BUS[0x0FE0000] = 0x1500;
     4.7 -} 

void
     4.8 +}
     4.9  
    4.10 +void
    4.11  NDS_EZF_CloseNorWrite() 
    4.12  {
    4.13      GBA_BUS[0x0FF0000] = 0xD200;
     5.1 --- a/src/stdlib/SDL_stdlib.c	Sun Aug 29 12:00:09 2010 -0700
     5.2 +++ b/src/stdlib/SDL_stdlib.c	Sun Aug 29 14:22:22 2010 -0700
     5.3 @@ -39,6 +39,12 @@
     5.4  
     5.5  #else
     5.6  
     5.7 +void
     5.8 +__declspec(naked)
     5.9 +_chkstk()
    5.10 +{
    5.11 +}
    5.12 +
    5.13  /* Float to long */
    5.14  void
    5.15  __declspec(naked)
     6.1 --- a/src/video/win32/SDL_win32events.c	Sun Aug 29 12:00:09 2010 -0700
     6.2 +++ b/src/video/win32/SDL_win32events.c	Sun Aug 29 14:22:22 2010 -0700
     6.3 @@ -20,11 +20,6 @@
     6.4      slouken@libsdl.org
     6.5  */
     6.6  
     6.7 -#if (_WIN32_WINNT < 0x601)
     6.8 -#undef _WIN32_WINNT
     6.9 -#define _WIN32_WINNT 0x601
    6.10 -#endif
    6.11 -
    6.12  #include "SDL_config.h"
    6.13  
    6.14  #include "SDL_win32video.h"
    6.15 @@ -35,12 +30,11 @@
    6.16  
    6.17  
    6.18  
    6.19 -#define WMMSG_DEBUG
    6.20 +/*#define WMMSG_DEBUG*/
    6.21  #ifdef WMMSG_DEBUG
    6.22  #include <stdio.h>	
    6.23  #include "wmmsg.h"
    6.24  #endif
    6.25 -//#include <stdio.h>
    6.26  
    6.27  /* Masks for processing the windows KEYDOWN and KEYUP messages */
    6.28  #define REPEATED_KEYMASK    (1<<30)
    6.29 @@ -61,6 +55,12 @@
    6.30  #ifndef WM_INPUT
    6.31  #define WM_INPUT 0x00ff
    6.32  #endif
    6.33 +#ifndef WM_GESTURE
    6.34 +#define WM_GESTURE 0x0119
    6.35 +#endif
    6.36 +#ifndef WM_TOUCH
    6.37 +#define WM_TOUCH 0x0240
    6.38 +#endif
    6.39  
    6.40  static WPARAM
    6.41  RemapVKEY(WPARAM wParam, LPARAM lParam)
    6.42 @@ -138,8 +138,8 @@
    6.43          fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam);
    6.44          fclose(log);
    6.45      }
    6.46 +#endif
    6.47  
    6.48 -#endif
    6.49      if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
    6.50          return 0;
    6.51  
    6.52 @@ -522,6 +522,7 @@
    6.53  		{
    6.54  			//printf("Got Touch Event!\n");
    6.55      
    6.56 +#ifdef WMMSG_DEBUG
    6.57  			FILE *log = fopen("wmmsg.txt", "a");
    6.58  			fprintf(log, "Received Touch Message: %p ", hwnd);
    6.59  			if (msg > MAX_WMMSG) {
    6.60 @@ -531,6 +532,7 @@
    6.61  			}
    6.62  			fprintf(log, "WM_TOUCH = %d -- 0x%X, 0x%X\n",msg, wParam, lParam);
    6.63  			fclose(log);
    6.64 +#endif
    6.65      
    6.66  		}
    6.67  		break;
    6.68 @@ -538,6 +540,7 @@
    6.69  		{
    6.70  			//printf("Got Touch Event!\n");
    6.71      
    6.72 +#ifdef WMMSG_DEBUG
    6.73  			FILE *log = fopen("wmmsg.txt", "a");
    6.74  			fprintf(log, "Received Gesture Message: %p ", hwnd);
    6.75  			if (msg > MAX_WMMSG) {
    6.76 @@ -547,7 +550,7 @@
    6.77  			}
    6.78  			fprintf(log, "WM_GESTURE = %d -- 0x%X, 0x%X\n",msg, wParam, lParam);
    6.79  			fclose(log);
    6.80 -    
    6.81 +#endif
    6.82  		}
    6.83  		break;		
    6.84  	}
     7.1 --- a/src/video/win32/SDL_win32video.h	Sun Aug 29 12:00:09 2010 -0700
     7.2 +++ b/src/video/win32/SDL_win32video.h	Sun Aug 29 14:22:22 2010 -0700
     7.3 @@ -32,13 +32,7 @@
     7.4  #define UNICODE
     7.5  #endif
     7.6  #undef WINVER
     7.7 -//#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
     7.8 -#define WINVER 0x601  /* Need 0x600 (_WIN32_WINNT_WIN7) for WM_Touch */
     7.9 -#if (_WIN32_WINNT < 0x601)
    7.10 -#undef _WIN32_WINNT
    7.11 -#define _WIN32_WINNT 0x601
    7.12 -#endif
    7.13 -
    7.14 +#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
    7.15  
    7.16  #include <windows.h>
    7.17