Mercurial > sdl-ios-xcode
comparison src/events/SDL_touch.c @ 4645:0375d020e7e3
Auto-detects Wacom touch devices.
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Mon, 31 May 2010 00:24:37 -0400 |
parents | fb500b3e1717 |
children | eea1bf53effa |
comparison
equal
deleted
inserted
replaced
4644:fb500b3e1717 | 4645:0375d020e7e3 |
---|---|
34 | 34 |
35 /* Public functions */ | 35 /* Public functions */ |
36 int | 36 int |
37 SDL_TouchInit(void) | 37 SDL_TouchInit(void) |
38 { | 38 { |
39 SDL_Touch touch; | |
40 touch.pressure_max = 0; | |
41 touch.pressure_min = 0; | |
42 touch.id = 0; //Should be function? | |
43 | 39 |
44 SDL_AddTouch(&touch, "Touch1"); | |
45 return (0); | 40 return (0); |
46 } | 41 } |
47 | 42 |
48 SDL_Touch * | 43 SDL_Touch * |
49 SDL_GetTouch(int id) | 44 SDL_GetTouch(int id) |
136 SDL_touchPads[index]->focus = 0; | 131 SDL_touchPads[index]->focus = 0; |
137 SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char)); | 132 SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char)); |
138 SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1); | 133 SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1); |
139 | 134 |
140 SDL_touchPads[index]->num_fingers = 0; | 135 SDL_touchPads[index]->num_fingers = 0; |
136 SDL_touchPads[index]->max_fingers = 0; | |
137 SDL_touchPads[index]->fingers = NULL; | |
138 | |
141 SDL_touchPads[index]->buttonstate = 0; | 139 SDL_touchPads[index]->buttonstate = 0; |
142 SDL_touchPads[index]->relative_mode = SDL_FALSE; | 140 SDL_touchPads[index]->relative_mode = SDL_FALSE; |
143 SDL_touchPads[index]->flush_motion = SDL_FALSE; | 141 SDL_touchPads[index]->flush_motion = SDL_FALSE; |
144 | 142 |
145 return index; | 143 return index; |
259 if (SDL_GetFingerIndexId(touch,finger->id) != -1) { | 257 if (SDL_GetFingerIndexId(touch,finger->id) != -1) { |
260 SDL_SetError("Finger ID already in use"); | 258 SDL_SetError("Finger ID already in use"); |
261 } | 259 } |
262 | 260 |
263 /* Add the touch to the list of touch */ | 261 /* Add the touch to the list of touch */ |
264 fingers = (SDL_Finger **) SDL_realloc(touch->fingers, | 262 if(touch->num_fingers >= touch->max_fingers){ |
265 (touch->num_fingers + 1) * sizeof(*touch)); | 263 if(fingers == NULL) { |
264 touch->max_fingers = 1; | |
265 fingers = (SDL_Finger **) SDL_malloc(sizeof(finger)); | |
266 } | |
267 else { | |
268 fingers = (SDL_Finger **) SDL_realloc(touch->fingers, | |
269 (touch->num_fingers + 1) * sizeof(finger)); | |
270 touch->max_fingers = touch->num_fingers+1; | |
271 } | |
272 | |
273 } | |
274 | |
266 if (!fingers) { | 275 if (!fingers) { |
267 SDL_OutOfMemory(); | 276 SDL_OutOfMemory(); |
268 return -1; | 277 return -1; |
269 } | 278 } |
270 | 279 |
271 touch->fingers = fingers; | 280 touch->fingers = fingers; |
272 index = touch->num_fingers++; | 281 index = touch->num_fingers; |
273 | 282 touch->num_fingers++; |
274 touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index]))); | 283 touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index]))); |
275 if (!touch->fingers[index]) { | 284 if (!touch->fingers[index]) { |
276 SDL_OutOfMemory(); | 285 SDL_OutOfMemory(); |
277 return -1; | 286 return -1; |
278 } | 287 } |