Update VS2010 project to add new files; update new files so code builds on Win32/Win64
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Mon, 23 Aug 2010 23:44:28 -0700
changeset 4865 fff50e86c891
parent 4864 ebcb4988b16f
child 4866 f42e8db53f78
Update VS2010 project to add new files; update new files so code builds on Win32/Win64
VisualC/SDL/SDL_VS2010.vcxproj
src/audio/SDL_audio.c
src/events/SDL_gesture.c
src/events/SDL_touch.c
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Sun Aug 22 17:19:10 2010 -0700
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Mon Aug 23 23:44:28 2010 -0700
@@ -110,7 +110,7 @@
       <Culture>0x0409</Culture>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>msvcrt.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>msvcrt.lib;msimg32.lib;version.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(IntDir)SDL.dll</OutputFile>
       <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -274,6 +274,9 @@
     <ClInclude Include="..\..\src\events\blank_cursor.h" />
     <ClInclude Include="..\..\src\events\default_cursor.h" />
     <ClInclude Include="..\..\src\audio\windx5\directx.h" />
+    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
+    <ClInclude Include="..\..\src\events\SDL_gesture_c.h" />
+    <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
     <ClInclude Include="..\..\src\libm\math.h" />
     <ClInclude Include="..\..\src\libm\math_private.h" />
     <ClInclude Include="..\..\src\video\mmx.h" />
@@ -326,6 +329,7 @@
     <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
     <ClInclude Include="..\..\src\video\win32\SDL_vkeys.h" />
     <ClInclude Include="..\..\src\audio\SDL_wave.h" />
+    <ClInclude Include="..\..\src\video\win32\SDL_win32clipboard.h" />
     <ClInclude Include="..\..\src\video\win32\SDL_win32events.h" />
     <ClInclude Include="..\..\src\video\win32\SDL_win32gamma.h" />
     <ClInclude Include="..\..\src\video\win32\SDL_win32keyboard.h" />
@@ -340,6 +344,9 @@
     <ClInclude Include="..\..\src\video\win32\wmmsg.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
+    <ClCompile Include="..\..\src\events\SDL_gesture.c" />
+    <ClCompile Include="..\..\src\events\SDL_touch.c" />
     <ClCompile Include="..\..\src\libm\e_log.c" />
     <ClCompile Include="..\..\src\libm\e_pow.c" />
     <ClCompile Include="..\..\src\libm\e_rem_pio2.c" />
@@ -431,6 +438,7 @@
     <ClCompile Include="..\..\src\timer\SDL_timer.c" />
     <ClCompile Include="..\..\src\video\SDL_video.c" />
     <ClCompile Include="..\..\src\audio\SDL_wave.c" />
+    <ClCompile Include="..\..\src\video\win32\SDL_win32clipboard.c" />
     <ClCompile Include="..\..\src\video\win32\SDL_win32events.c" />
     <ClCompile Include="..\..\src\video\win32\SDL_win32gamma.c" />
     <ClCompile Include="..\..\src\video\win32\SDL_win32keyboard.c" />
--- a/src/audio/SDL_audio.c	Sun Aug 22 17:19:10 2010 -0700
+++ b/src/audio/SDL_audio.c	Mon Aug 23 23:44:28 2010 -0700
@@ -29,7 +29,7 @@
 #include "SDL_audiomem.h"
 #include "SDL_sysaudio.h"
 
-#define _THIS    SDL_AudioDevice *this
+#define _THIS SDL_AudioDevice *_this
 
 static SDL_AudioDriver current_audio;
 static SDL_AudioDevice *open_devices[16];
@@ -321,8 +321,9 @@
     }
 }
 
-
+#if defined(ANDROID)
 #include <android/log.h>
+#endif
 
 /* The general mixing thread function */
 int SDLCALL
@@ -891,7 +892,7 @@
     device->opened = 1;
 
     /* Allocate a fake audio memory buffer */
-    device->fake_stream = SDL_AllocAudioMem(device->spec.size);
+    device->fake_stream = (Uint8 *)SDL_AllocAudioMem(device->spec.size);
     if (device->fake_stream == NULL) {
         close_audio_device(device);
         SDL_OutOfMemory();
--- a/src/events/SDL_gesture.c	Sun Aug 22 17:19:10 2010 -0700
+++ b/src/events/SDL_gesture.c	Mon Aug 23 23:44:28 2010 -0700
@@ -18,6 +18,7 @@
     Sam Lantinga
     slouken@libsdl.org
 */
+
 #include "SDL_config.h"
 
 /* General mouse handling code for SDL */
@@ -26,6 +27,11 @@
 #include "SDL_events_c.h"
 #include "SDL_gesture_c.h"
 
+#include <memory.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
 //TODO: Replace with malloc
 
 #define MAXPATHSIZE 1024
@@ -100,8 +106,8 @@
   unsigned long hash = 5381;
   int i;
   for(i = 0;i < DOLLARNPOINTS; i++) { 
-    hash = ((hash<<5) + hash) + points[i].x;
-    hash = ((hash<<5) + hash) + points[i].y;
+    hash = ((hash<<5) + hash) + (unsigned long)points[i].x;
+    hash = ((hash<<5) + hash) + (unsigned long)points[i].y;
   }
   return hash;
 }
@@ -110,7 +116,6 @@
 static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) {
   if(src == NULL) return 0;
 
-  int i;
   
   //No Longer storing the Hash, rehash on load
   //if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;
@@ -151,14 +156,16 @@
 //path is an already sampled set of points
 //Returns the index of the gesture on success, or -1
 static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch,SDL_FloatPoint* path) {
+  SDL_DollarTemplate* dollarTemplate;
+  SDL_DollarTemplate *templ;
+  int i = 0;
   if(inTouch == NULL) {
     if(SDL_numGestureTouches == 0) return -1;
-    int i = 0;
     for(i = 0;i < SDL_numGestureTouches; i++) {
       inTouch = &SDL_gestureTouch[i];
 
-      SDL_DollarTemplate* dollarTemplate = 
-	SDL_realloc(inTouch->dollarTemplate,
+    dollarTemplate = 
+	(SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
 		    (inTouch->numDollarTemplates + 1) * 
 		    sizeof(SDL_DollarTemplate));
       if(!dollarTemplate) {
@@ -168,7 +175,7 @@
 	
       inTouch->dollarTemplate = dollarTemplate;
 
-      SDL_DollarTemplate *templ = 
+    templ = 
 	&inTouch->dollarTemplate[inTouch->numDollarTemplates];
       memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
       templ->hash = SDL_HashDollar(templ->path);
@@ -177,7 +184,7 @@
     return inTouch->numDollarTemplates - 1;
   } else {
     SDL_DollarTemplate* dollarTemplate = 
-      SDL_realloc(inTouch->dollarTemplate,
+      ( SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
 		  (inTouch->numDollarTemplates + 1) * 
 		  sizeof(SDL_DollarTemplate));
     if(!dollarTemplate) {
@@ -187,7 +194,7 @@
     
     inTouch->dollarTemplate = dollarTemplate;
 
-    SDL_DollarTemplate *templ = 
+    templ = 
       &inTouch->dollarTemplate[inTouch->numDollarTemplates];
     memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint));
     templ->hash = SDL_HashDollar(templ->path);
@@ -198,9 +205,9 @@
 }
 
 int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
-  if(src == NULL) return 0;
   int i,loaded = 0;
   SDL_GestureTouch *touch = NULL;
+  if(src == NULL) return 0;
   if(touchId >= 0) {
     for(i = 0;i < SDL_numGestureTouches; i++)
       if(SDL_gestureTouch[i].id == touchId)
@@ -240,10 +247,10 @@
   SDL_FloatPoint p;
   int i;
   for(i = 0; i < DOLLARNPOINTS; i++) {
-    p.x = points[i].x * cos(ang) - points[i].y * sin(ang);
-    p.y = points[i].x * sin(ang) + points[i].y * cos(ang);
-    dist += sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
-		 (p.y-templ[i].y)*(p.y-templ[i].y));
+    p.x = (float)(points[i].x * cos(ang) - points[i].y * sin(ang));
+    p.y = (float)(points[i].x * sin(ang) + points[i].y * cos(ang));
+    dist += (float)(sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
+		 (p.y-templ[i].y)*(p.y-templ[i].y)));
   }
   return dist/DOLLARNPOINTS;
   
@@ -253,26 +260,26 @@
   //------------BEGIN DOLLAR BLACKBOX----------------//
   //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-//
   //-"http://depts.washington.edu/aimgroup/proj/dollar/"-//
-  float ta = -M_PI/4;
-  float tb = M_PI/4;
-  float dt = M_PI/90;
-  float x1 = PHI*ta + (1-PHI)*tb;
+  double ta = -M_PI/4;
+  double tb = M_PI/4;
+  double dt = M_PI/90;
+  float x1 = (float)(PHI*ta + (1-PHI)*tb);
   float f1 = dollarDifference(points,templ,x1);
-  float x2 = (1-PHI)*ta + PHI*tb;
+  float x2 = (float)((1-PHI)*ta + PHI*tb);
   float f2 = dollarDifference(points,templ,x2);
-  while(abs(ta-tb) > dt) {
+  while(fabs(ta-tb) > dt) {
     if(f1 < f2) {
       tb = x2;
       x2 = x1;
       f2 = f1;
-      x1 = PHI*ta + (1-PHI)*tb;
+      x1 = (float)(PHI*ta + (1-PHI)*tb);
       f1 = dollarDifference(points,templ,x1);
     }
     else {
       ta = x1;
       x1 = x2;
       f1 = f2;
-      x2 = (1-PHI)*ta + PHI*tb;
+      x2 = (float)((1-PHI)*ta + PHI*tb);
       f2 = dollarDifference(points,templ,x2);
     }
   }
@@ -288,6 +295,14 @@
 //DollarPath contains raw points, plus (possibly) the calculated length
 int dollarNormalize(SDL_DollarPath path,SDL_FloatPoint *points) {
   int i;
+  float interval;
+  float dist;
+  int numPoints = 0;
+  SDL_FloatPoint centroid; 
+  float xmin,xmax,ymin,ymax;
+  float ang;
+  float w,h;
+
   //Calculate length if it hasn't already been done
   if(path.length <= 0) {
     for(i=1;i<path.numPoints;i++) {
@@ -295,22 +310,20 @@
 	         path.p[i-1].x;
       float dy = path.p[i  ].y - 
 	         path.p[i-1].y;
-      path.length += sqrt(dx*dx+dy*dy);
+      path.length += (float)(sqrt(dx*dx+dy*dy));
     }
   }
 
   //Resample
-  float interval = path.length/(DOLLARNPOINTS - 1);
-  float dist = interval;
+  interval = path.length/(DOLLARNPOINTS - 1);
+  dist = interval;
 
-  int numPoints = 0;
-  SDL_FloatPoint centroid; 
   centroid.x = 0;centroid.y = 0;
   
   //printf("(%f,%f)\n",path.p[path.numPoints-1].x,path.p[path.numPoints-1].y);
   for(i = 1;i < path.numPoints;i++) {
-    float d = sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
-		   (path.p[i-1].y-path.p[i].y)*(path.p[i-1].y-path.p[i].y));
+    float d = (float)(sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
+		             (path.p[i-1].y-path.p[i].y)*(path.p[i-1].y-path.p[i].y)));
     //printf("d = %f dist = %f/%f\n",d,dist,interval);
     while(dist + d > interval) {
       points[numPoints].x = path.p[i-1].x + 
@@ -338,22 +351,21 @@
  
   //printf("Centroid (%f,%f)",centroid.x,centroid.y);
   //Rotate Points so point 0 is left of centroid and solve for the bounding box
-  float xmin,xmax,ymin,ymax;
   xmin = centroid.x;
   xmax = centroid.x;
   ymin = centroid.y;
   ymax = centroid.y;
   
-  float ang = atan2(centroid.y - points[0].y,
-		    centroid.x - points[0].x);
+  ang = (float)(atan2(centroid.y - points[0].y,
+		    centroid.x - points[0].x));
 
   for(i = 0;i<numPoints;i++) {					       
     float px = points[i].x;
     float py = points[i].y;
-    points[i].x = (px - centroid.x)*cos(ang) - 
-                  (py - centroid.y)*sin(ang) + centroid.x;
-    points[i].y = (px - centroid.x)*sin(ang) + 
-                  (py - centroid.y)*cos(ang) + centroid.y;
+    points[i].x = (float)((px - centroid.x)*cos(ang) - 
+                  (py - centroid.y)*sin(ang) + centroid.x);
+    points[i].y = (float)((px - centroid.x)*sin(ang) + 
+                  (py - centroid.y)*cos(ang) + centroid.y);
 
 
     if(points[i].x < xmin) xmin = points[i].x;
@@ -363,8 +375,8 @@
   }
 
   //Scale points to DOLLARSIZE, and translate to the origin
-  float w = xmax-xmin;
-  float h = ymax-ymin;
+  w = xmax-xmin;
+  h = ymax-ymin;
 
   for(i=0;i<numPoints;i++) {
     points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
@@ -380,17 +392,17 @@
 	//SDL_PrintPath(points);
 	int i;
 	
-	int bestDiff = 10000;
+	float bestDiff = 10000;
 	*bestTempl = -1;
 	for(i = 0;i < touch->numDollarTemplates;i++) {
-		int diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
+		float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
 		if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
 	}
 	return bestDiff;
 }
 
 int SDL_GestureAddTouch(SDL_Touch* touch) {  
-  SDL_GestureTouch *gestureTouch = SDL_realloc(SDL_gestureTouch,
+  SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch,
 					       (SDL_numGestureTouches + 1) *
 					       sizeof(SDL_GestureTouch));
 
@@ -479,6 +491,18 @@
 
 void SDL_GestureProcessEvent(SDL_Event* event)
 {
+  float x,y; 
+  SDL_FloatPoint path[DOLLARNPOINTS];
+  int index;
+  int i;
+  float pathDx, pathDy;
+  SDL_FloatPoint lastP;
+  SDL_FloatPoint lastCentroid;
+  float lDist;
+  float Dist;
+  float dtheta;
+  float dDist;
+
   if(event->type == SDL_FINGERMOTION || 
      event->type == SDL_FINGERDOWN ||
      event->type == SDL_FINGERUP) {
@@ -492,8 +516,8 @@
     //   (int)inTouch->res.x,(int)inTouch->res.y);
 
     
-    float x = ((float)event->tfinger.x)/(float)inTouch->res.x;
-    float y = ((float)event->tfinger.y)/(float)inTouch->res.y;   
+    x = ((float)event->tfinger.x)/(float)inTouch->res.x;
+    y = ((float)event->tfinger.y)/(float)inTouch->res.y;   
 
 
     //Finger Up
@@ -502,14 +526,11 @@
       
 #ifdef ENABLE_DOLLAR
       if(inTouch->recording) {
-	inTouch->recording = SDL_FALSE;
-	SDL_FloatPoint path[DOLLARNPOINTS];
+	inTouch->recording = SDL_FALSE;	
 	dollarNormalize(inTouch->dollarPath,path);
 	//SDL_PrintPath(path);
-	int index;
 	if(recordAll) {
 	  index = SDL_AddDollarGesture(NULL,path);
-	  int i;
 	  for(i = 0;i < SDL_numGestureTouches; i++)
 	    SDL_gestureTouch[i].recording = SDL_FALSE;
 	}
@@ -554,18 +575,16 @@
       if(path->numPoints < MAXPATHSIZE) {
 	path->p[path->numPoints].x = inTouch->centroid.x;
 	path->p[path->numPoints].y = inTouch->centroid.y;
-	float pathDx = 
+	pathDx = 
 	  (path->p[path->numPoints].x-path->p[path->numPoints-1].x);
-	float pathDy = 
+	pathDy = 
 	  (path->p[path->numPoints].y-path->p[path->numPoints-1].y);
-	path->length += sqrt(pathDx*pathDx + pathDy*pathDy);
+	path->length += (float)sqrt(pathDx*pathDx + pathDy*pathDy);
 	path->numPoints++;
       }
 #endif
-      SDL_FloatPoint lastP;
       lastP.x = x - dx;
       lastP.y = y - dy;
-      SDL_FloatPoint lastCentroid;
       lastCentroid = inTouch->centroid;
       
       inTouch->centroid.x += dx/inTouch->numDownFingers;
@@ -577,12 +596,12 @@
 	//lv = inTouch->gestureLast[j].cv;
 	lv.x = lastP.x - lastCentroid.x;
 	lv.y = lastP.y - lastCentroid.y;
-	float lDist = sqrt(lv.x*lv.x + lv.y*lv.y);
+	lDist = (float)sqrt(lv.x*lv.x + lv.y*lv.y);
 	//printf("lDist = %f\n",lDist);
 	v.x = x - inTouch->centroid.x;
 	v.y = y - inTouch->centroid.y;
 	//inTouch->gestureLast[j].cv = v;
-	float Dist = sqrt(v.x*v.x+v.y*v.y);
+	Dist = (float)sqrt(v.x*v.x+v.y*v.y);
 	// cos(dTheta) = (v . lv)/(|v| * |lv|)
 	
 	//Normalize Vectors to simplify angle calculation
@@ -590,9 +609,9 @@
 	lv.y/=lDist;
 	v.x/=Dist;
 	v.y/=Dist;
-	float dtheta = atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
+	dtheta = (float)atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
 	
-	float dDist = (Dist - lDist);
+	dDist = (Dist - lDist);
 	if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values
 	
 	//inTouch->gestureLast[j].dDist = dDist;
--- a/src/events/SDL_touch.c	Sun Aug 22 17:19:10 2010 -0700
+++ b/src/events/SDL_touch.c	Mon Aug 23 23:44:28 2010 -0700
@@ -313,6 +313,11 @@
 		   float xin, float yin, float pressurein)
 {
     int posted;
+	Uint16 x;
+	Uint16 y;
+	Uint16 pressure;
+	SDL_Finger *finger;
+
     SDL_Touch* touch = SDL_GetTouch(id);
 
     if(!touch) {
@@ -321,11 +326,11 @@
 
     
     //scale to Integer coordinates
-    Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres);
-    Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres);
-    Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres);
+    x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
+    y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
+    pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
     
-    SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
+    finger = SDL_GetFinger(touch,fingerid);
     if(down) {
 	if(finger == NULL) {
 	    SDL_Finger nf;
@@ -393,15 +398,18 @@
     int posted;
     Sint16 xrel, yrel;
     float x_max = 0, y_max = 0;
+	Uint16 x;
+	Uint16 y;
+	Uint16 pressure;
     
     if (!touch) {
       return SDL_TouchNotFoundError(id);
     }
 
     //scale to Integer coordinates
-    Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres);
-    Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres);
-    Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres);
+    x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
+    y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
+    pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
     if(touch->flush_motion) {
 	return 0;
     }
@@ -544,9 +552,9 @@
 }
 
 int SDL_TouchNotFoundError(SDL_TouchID id) {
+  int i;
   printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
   printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
-  int i;
   for(i=0;i < SDL_num_touch;i++) {
     printf("ERROR: %li\n",SDL_touchPads[i]->id);
   }