src/events/SDL_touch.c
changeset 4676 99b4560b7aa1
parent 4674 89d5e2201b00
child 4678 f8431f66613d
     1.1 --- a/src/events/SDL_touch.c	Thu Jul 29 12:26:59 2010 -0400
     1.2 +++ b/src/events/SDL_touch.c	Fri Jul 30 23:18:35 2010 +0400
     1.3 @@ -42,7 +42,7 @@
     1.4  }
     1.5  
     1.6  SDL_Touch *
     1.7 -SDL_GetTouch(int id)
     1.8 +SDL_GetTouch(long id)
     1.9  {
    1.10      int index = SDL_GetTouchIndexId(id);
    1.11      if (index < 0 || index >= SDL_num_touch) {
    1.12 @@ -61,7 +61,7 @@
    1.13  }
    1.14  
    1.15  int
    1.16 -SDL_GetFingerIndexId(SDL_Touch* touch,int fingerid)
    1.17 +SDL_GetFingerIndexId(SDL_Touch* touch,long fingerid)
    1.18  {
    1.19      int i;
    1.20      for(i = 0;i < touch->num_fingers;i++)
    1.21 @@ -72,7 +72,7 @@
    1.22  
    1.23  
    1.24  SDL_Finger *
    1.25 -SDL_GetFinger(SDL_Touch* touch,int id)
    1.26 +SDL_GetFinger(SDL_Touch* touch,long id)
    1.27  {
    1.28      int index = SDL_GetFingerIndexId(touch,id);
    1.29      if(index < 0 || index >= touch->num_fingers)
    1.30 @@ -82,7 +82,7 @@
    1.31  
    1.32  
    1.33  int
    1.34 -SDL_GetTouchIndexId(int id)
    1.35 +SDL_GetTouchIndexId(long id)
    1.36  {
    1.37      int index;
    1.38      SDL_Touch *touch;
    1.39 @@ -146,7 +146,7 @@
    1.40  }
    1.41  
    1.42  void
    1.43 -SDL_DelTouch(int id)
    1.44 +SDL_DelTouch(long id)
    1.45  {
    1.46      int index = SDL_GetTouchIndexId(id);
    1.47      SDL_Touch *touch = SDL_GetTouch(id);
    1.48 @@ -189,7 +189,7 @@
    1.49      return SDL_num_touch;
    1.50  }
    1.51  SDL_Window *
    1.52 -SDL_GetTouchFocusWindow(int id)
    1.53 +SDL_GetTouchFocusWindow(long id)
    1.54  {
    1.55      SDL_Touch *touch = SDL_GetTouch(id);
    1.56  
    1.57 @@ -200,7 +200,7 @@
    1.58  }
    1.59  
    1.60  void
    1.61 -SDL_SetTouchFocus(int id, SDL_Window * window)
    1.62 +SDL_SetTouchFocus(long id, SDL_Window * window)
    1.63  {
    1.64      int index = SDL_GetTouchIndexId(id);
    1.65      SDL_Touch *touch = SDL_GetTouch(id);
    1.66 @@ -250,12 +250,12 @@
    1.67  }
    1.68  
    1.69  int 
    1.70 -SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
    1.71 +SDL_AddFinger(SDL_Touch* touch,SDL_Finger finger)
    1.72  {
    1.73      int index;
    1.74      SDL_Finger **fingers;
    1.75      //printf("Adding Finger...\n");
    1.76 -    if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
    1.77 +    if (SDL_GetFingerIndexId(touch,finger.id) != -1) {
    1.78          SDL_SetError("Finger ID already in use");
    1.79  	}
    1.80  
    1.81 @@ -282,14 +282,14 @@
    1.82          SDL_OutOfMemory();
    1.83          return -1;
    1.84      }
    1.85 -    *(touch->fingers[index]) = *finger;
    1.86 +    *(touch->fingers[index]) = finger;
    1.87      touch->num_fingers++;
    1.88  
    1.89      return index;
    1.90  }
    1.91  
    1.92  int
    1.93 -SDL_DelFinger(SDL_Touch* touch,int fingerid)
    1.94 +SDL_DelFinger(SDL_Touch* touch,long fingerid)
    1.95  {
    1.96      int index = SDL_GetFingerIndexId(touch,fingerid);
    1.97      SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
    1.98 @@ -307,7 +307,7 @@
    1.99  
   1.100  
   1.101  int
   1.102 -SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure)
   1.103 +SDL_SendFingerDown(long id, long fingerid, SDL_bool down, float x, float y, float pressure)
   1.104  {
   1.105      int posted;
   1.106      SDL_Touch* touch = SDL_GetTouch(id);
   1.107 @@ -330,7 +330,7 @@
   1.108  	    nf.last_y = y;
   1.109  	    nf.last_pressure = pressure;
   1.110  	    nf.down = SDL_FALSE;
   1.111 -	    SDL_AddFinger(touch,&nf);
   1.112 +	    SDL_AddFinger(touch,nf);
   1.113  	    finger = &nf;
   1.114  	}
   1.115  	else if(finger->down) return 0;
   1.116 @@ -339,7 +339,7 @@
   1.117  	if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
   1.118  	    SDL_Event event;
   1.119  	    event.tfinger.type = SDL_FINGERDOWN;
   1.120 -	    event.tfinger.touchId = (Uint8) id;
   1.121 +	    event.tfinger.touchId = id;
   1.122  	    event.tfinger.x = x;
   1.123  	    event.tfinger.y = y;
   1.124  	    event.tfinger.state = touch->buttonstate;
   1.125 @@ -356,7 +356,7 @@
   1.126  	if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
   1.127  	    SDL_Event event;
   1.128  	    event.tfinger.type = SDL_FINGERUP;
   1.129 -	    event.tfinger.touchId = (Uint8) id;
   1.130 +	    event.tfinger.touchId =  id;
   1.131  	    event.tfinger.state = touch->buttonstate;
   1.132  	    event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
   1.133  	    event.tfinger.fingerId = fingerid;
   1.134 @@ -367,16 +367,16 @@
   1.135  }
   1.136  
   1.137  int
   1.138 -SDL_SendTouchMotion(int id, int fingerid, int relative, 
   1.139 -		    int x, int y, int pressure)
   1.140 +SDL_SendTouchMotion(long id, long fingerid, int relative, 
   1.141 +		    float x, float y, float pressure)
   1.142  {
   1.143      int index = SDL_GetTouchIndexId(id);
   1.144      SDL_Touch *touch = SDL_GetTouch(id);
   1.145      SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
   1.146      int posted;
   1.147 -    int xrel;
   1.148 -    int yrel;
   1.149 -    int x_max = 0, y_max = 0;
   1.150 +    float xrel;
   1.151 +    float yrel;
   1.152 +    float x_max = 0, y_max = 0;
   1.153      
   1.154      if (!touch) {
   1.155        return SDL_TouchNotFoundError(id);
   1.156 @@ -444,8 +444,8 @@
   1.157  	if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
   1.158  	    SDL_Event event;
   1.159  	    event.tfinger.type = SDL_FINGERMOTION;
   1.160 -	    event.tfinger.touchId = (Uint8) id;
   1.161 -	    event.tfinger.fingerId = (Uint8) fingerid;
   1.162 +	    event.tfinger.touchId = id;
   1.163 +	    event.tfinger.fingerId = fingerid;
   1.164  	    event.tfinger.x = x;
   1.165  	    event.tfinger.y = y;
   1.166  	    event.tfinger.pressure = pressure;
   1.167 @@ -460,7 +460,7 @@
   1.168      }
   1.169  }
   1.170  int
   1.171 -SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
   1.172 +SDL_SendTouchButton(long id, Uint8 state, Uint8 button)
   1.173  {
   1.174      SDL_Touch *touch = SDL_GetTouch(id);
   1.175      int posted;
   1.176 @@ -499,7 +499,7 @@
   1.177      if (SDL_GetEventState(type) == SDL_ENABLE) {
   1.178          SDL_Event event;
   1.179          event.type = type;
   1.180 -        event.tbutton.touchId = (Uint8) touch->id;
   1.181 +        event.tbutton.touchId = touch->id;
   1.182          event.tbutton.state = state;
   1.183          event.tbutton.button = button;
   1.184          event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
   1.185 @@ -509,7 +509,7 @@
   1.186  }
   1.187  
   1.188  char *
   1.189 -SDL_GetTouchName(int id)
   1.190 +SDL_GetTouchName(long id)
   1.191  {
   1.192      SDL_Touch *touch = SDL_GetTouch(id);
   1.193      if (!touch) {
   1.194 @@ -518,12 +518,12 @@
   1.195      return touch->name;
   1.196  }
   1.197  
   1.198 -int SDL_TouchNotFoundError(int id) {
   1.199 -  printf("ERROR: Cannot send touch on non-existent device with id: %i make sure SDL_AddTouch has been called\n",id);
   1.200 +int SDL_TouchNotFoundError(long id) {
   1.201 +  printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
   1.202    printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
   1.203    int i;
   1.204    for(i=0;i < SDL_num_touch;i++) {
   1.205 -    printf("ERROR: %i\n",SDL_touchPads[i]->id);
   1.206 +    printf("ERROR: %li\n",SDL_touchPads[i]->id);
   1.207    }
   1.208    return 0;
   1.209  }