Fixed windo build errors. Should now be compilable.
authorjimtla
Thu, 03 Jun 2010 13:21:35 -0400
changeset 46480350b634c044
parent 4647 be2250bb482b
child 4649 35a80b0791aa
Fixed windo build errors. Should now be compilable.
src/events/SDL_touch.c
src/events/SDL_touch_c.h
     1.1 --- a/src/events/SDL_touch.c	Thu Jun 03 11:08:17 2010 -0400
     1.2 +++ b/src/events/SDL_touch.c	Thu Jun 03 13:21:35 2010 -0400
     1.3 @@ -27,6 +27,8 @@
     1.4  #include "SDL_events_c.h"
     1.5  #include "../video/SDL_sysvideo.h"
     1.6  
     1.7 +#include <stdio.h>
     1.8 +
     1.9  
    1.10  static int SDL_num_touch = 0;
    1.11  static SDL_Touch **SDL_touchPads = NULL;
    1.12 @@ -99,9 +101,7 @@
    1.13  SDL_AddTouch(const SDL_Touch * touch, char *name)
    1.14  {
    1.15      SDL_Touch **touchPads;
    1.16 -    int selected_touch;
    1.17 -    int index;
    1.18 -    size_t length;
    1.19 +    int index,length;
    1.20  
    1.21      if (SDL_GetTouchIndexId(touch->id) != -1) {
    1.22          SDL_SetError("Touch ID already in use");
    1.23 @@ -252,7 +252,6 @@
    1.24  {
    1.25      int index;
    1.26      SDL_Finger **fingers;
    1.27 -    size_t length;
    1.28      //printf("Adding Finger...\n");
    1.29      if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
    1.30          SDL_SetError("Finger ID already in use");
    1.31 @@ -260,19 +259,18 @@
    1.32  
    1.33      /* Add the touch to the list of touch */
    1.34      if(touch->num_fingers  >= touch->max_fingers){
    1.35 -	printf("Making room for it!\n");
    1.36 -     	fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
    1.37 -  		               (touch->num_fingers + 1) * sizeof(SDL_Finger *));
    1.38 -	touch->max_fingers = touch->num_fingers+1;
    1.39 -	if (!fingers) {
    1.40 -	    SDL_OutOfMemory();
    1.41 -	    return -1;
    1.42 -	} 
    1.43 -	else {
    1.44 -	    touch->max_fingers = touch->num_fingers+1;
    1.45 -	    touch->fingers = fingers;
    1.46 +		//printf("Making room for it!\n");
    1.47 +		fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
    1.48 +  						   (touch->num_fingers + 1) * sizeof(SDL_Finger *));
    1.49 +		touch->max_fingers = touch->num_fingers+1;
    1.50 +		if (!fingers) {
    1.51 +			SDL_OutOfMemory();
    1.52 +			return -1;
    1.53 +		} else {
    1.54 +			touch->max_fingers = touch->num_fingers+1;
    1.55 +			touch->fingers = fingers;
    1.56 +		}
    1.57  	}
    1.58 -    }
    1.59  
    1.60      index = touch->num_fingers;
    1.61      //printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
    1.62 @@ -295,13 +293,14 @@
    1.63      SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
    1.64  
    1.65      if (!finger) {
    1.66 -        return;
    1.67 +        return -1;
    1.68      }
    1.69   
    1.70  
    1.71      SDL_free(finger);
    1.72      touch->num_fingers--;
    1.73      touch->fingers[index] = touch->fingers[touch->num_fingers];
    1.74 +	return 0;
    1.75  }
    1.76  
    1.77  
    1.78 @@ -370,79 +369,80 @@
    1.79          return 0;
    1.80      }
    1.81  
    1.82 -    if(finger == NULL)
    1.83 -	SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
    1.84 -    else {
    1.85 -	/* the relative motion is calculated regarding the last position */
    1.86 -	if (relative) {
    1.87 -	    xrel = x;
    1.88 -	    yrel = y;
    1.89 -	    x = (finger->last_x + x);
    1.90 -	    y = (finger->last_y + y);
    1.91 +	if(finger == NULL) {
    1.92 +		SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
    1.93 +		return 0;
    1.94  	} else {
    1.95 -	    if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
    1.96 -	    if(y < 0) y = finger->last_y; /*The other is marked as -1*/
    1.97 -	    if(pressure < 0) pressure = finger->last_pressure;
    1.98 -	    xrel = x - finger->last_x;
    1.99 -	    yrel = y - finger->last_y;
   1.100 +		/* the relative motion is calculated regarding the last position */
   1.101 +		if (relative) {
   1.102 +			xrel = x;
   1.103 +			yrel = y;
   1.104 +			x = (finger->last_x + x);
   1.105 +			y = (finger->last_y + y);
   1.106 +		} else {
   1.107 +			if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
   1.108 +			if(y < 0) y = finger->last_y; /*The other is marked as -1*/
   1.109 +			if(pressure < 0) pressure = finger->last_pressure;
   1.110 +			xrel = x - finger->last_x;
   1.111 +			yrel = y - finger->last_y;
   1.112 +		}
   1.113 +		
   1.114 +		/* Drop events that don't change state */
   1.115 +		if (!xrel && !yrel) {
   1.116 +	#if 0
   1.117 +			printf("Touch event didn't change state - dropped!\n");
   1.118 +	#endif
   1.119 +			return 0;
   1.120 +		}
   1.121 +		
   1.122 +		/* Update internal touch coordinates */
   1.123 +		
   1.124 +		finger->x = x;
   1.125 +		finger->y = y;
   1.126 +		
   1.127 +		/*Should scale to window? Normalize? Maintain Aspect?*/
   1.128 +		//SDL_GetWindowSize(touch->focus, &x_max, &y_max);
   1.129 +		
   1.130 +		/* make sure that the pointers find themselves inside the windows */
   1.131 +		/* only check if touch->xmax is set ! */
   1.132 +		/*
   1.133 +		  if (x_max && touch->x > x_max) {
   1.134 +		  touch->x = x_max;
   1.135 +		  } else if (touch->x < 0) {
   1.136 +		  touch->x = 0;
   1.137 +		  }
   1.138 +		  
   1.139 +		  if (y_max && touch->y > y_max) {
   1.140 +		  touch->y = y_max;
   1.141 +		  } else if (touch->y < 0) {
   1.142 +		  touch->y = 0;
   1.143 +		  }
   1.144 +		*/
   1.145 +		finger->xdelta = xrel;
   1.146 +		finger->ydelta = yrel;
   1.147 +		finger->pressure = pressure;
   1.148 +		
   1.149 +		
   1.150 +		
   1.151 +		/* Post the event, if desired */
   1.152 +		posted = 0;
   1.153 +		if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
   1.154 +			SDL_Event event;
   1.155 +			event.tfinger.type = SDL_FINGERMOTION;
   1.156 +			event.tfinger.touchId = (Uint8) id;
   1.157 +			event.tfinger.fingerId = (Uint8) fingerid;
   1.158 +			event.tfinger.x = x;
   1.159 +			event.tfinger.y = y;
   1.160 +			event.tfinger.pressure = pressure;
   1.161 +			event.tfinger.state = touch->buttonstate;
   1.162 +			event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
   1.163 +			posted = (SDL_PushEvent(&event) > 0);
   1.164 +		}
   1.165 +		finger->last_x = finger->x;
   1.166 +		finger->last_y = finger->y;
   1.167 +		finger->last_pressure = finger->pressure;
   1.168 +		return posted;
   1.169  	}
   1.170 -	
   1.171 -	/* Drop events that don't change state */
   1.172 -	if (!xrel && !yrel) {
   1.173 -#if 0
   1.174 -	    printf("Touch event didn't change state - dropped!\n");
   1.175 -#endif
   1.176 -	    return 0;
   1.177 -	}
   1.178 -	
   1.179 -	/* Update internal touch coordinates */
   1.180 -	
   1.181 -	finger->x = x;
   1.182 -	finger->y = y;
   1.183 -	
   1.184 -	/*Should scale to window? Normalize? Maintain Aspect?*/
   1.185 -	//SDL_GetWindowSize(touch->focus, &x_max, &y_max);
   1.186 -	
   1.187 -	/* make sure that the pointers find themselves inside the windows */
   1.188 -	/* only check if touch->xmax is set ! */
   1.189 -	/*
   1.190 -	  if (x_max && touch->x > x_max) {
   1.191 -	  touch->x = x_max;
   1.192 -	  } else if (touch->x < 0) {
   1.193 -	  touch->x = 0;
   1.194 -	  }
   1.195 -	  
   1.196 -	  if (y_max && touch->y > y_max) {
   1.197 -	  touch->y = y_max;
   1.198 -	  } else if (touch->y < 0) {
   1.199 -	  touch->y = 0;
   1.200 -	  }
   1.201 -	*/
   1.202 -	finger->xdelta = xrel;
   1.203 -	finger->ydelta = yrel;
   1.204 -	finger->pressure = pressure;
   1.205 -	
   1.206 -	
   1.207 -	
   1.208 -	/* Post the event, if desired */
   1.209 -	posted = 0;
   1.210 -	if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
   1.211 -	    SDL_Event event;
   1.212 -	    event.tfinger.type = SDL_FINGERMOTION;
   1.213 -	    event.tfinger.touchId = (Uint8) id;
   1.214 -	    event.tfinger.fingerId = (Uint8) fingerid;
   1.215 -	    event.tfinger.x = x;
   1.216 -	    event.tfinger.y = y;
   1.217 -	    event.tfinger.pressure = pressure;
   1.218 -	    event.tfinger.state = touch->buttonstate;
   1.219 -	    event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
   1.220 -	    posted = (SDL_PushEvent(&event) > 0);
   1.221 -	}
   1.222 -	finger->last_x = finger->x;
   1.223 -	finger->last_y = finger->y;
   1.224 -	finger->last_pressure = finger->pressure;
   1.225 -	return posted;
   1.226 -    }
   1.227  }
   1.228  int
   1.229  SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
   1.230 @@ -483,7 +483,7 @@
   1.231      if (SDL_GetEventState(type) == SDL_ENABLE) {
   1.232          SDL_Event event;
   1.233          event.type = type;
   1.234 -        event.tbutton.touchId = (Uint8) index;
   1.235 +        event.tbutton.touchId = (Uint8) touch->id;
   1.236          event.tbutton.state = state;
   1.237          event.tbutton.button = button;
   1.238          event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
     2.1 --- a/src/events/SDL_touch_c.h	Thu Jun 03 11:08:17 2010 -0400
     2.2 +++ b/src/events/SDL_touch_c.h	Thu Jun 03 13:21:35 2010 -0400
     2.3 @@ -65,7 +65,7 @@
     2.4  extern void SDL_TouchQuit(void);
     2.5  
     2.6  /* Get the index of a touch device */
     2.7 -extern int SDL_GetTouchIndexId(int id)
     2.8 +extern int SDL_GetTouchIndexId(int id);
     2.9  
    2.10  
    2.11