comparison src/events/SDL_touch.c @ 4643:8806b78988f7

Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
author Jim Grandpre <jim.tla@gmail.com>
date Sat, 29 May 2010 01:47:19 -0400
parents 057e8762d2a1
children fb500b3e1717
comparison
equal deleted inserted replaced
4642:057e8762d2a1 4643:8806b78988f7
299 299
300 300
301 int 301 int
302 SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure) 302 SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure)
303 { 303 {
304 int posted; 304 int posted;
305 SDL_Touch* touch = SDL_GetTouch(id); 305 SDL_Touch* touch = SDL_GetTouch(id);
306
306 if(down) { 307 if(down) {
307 SDL_Finger nf; 308 SDL_Finger nf;
308 nf.id = id; 309 nf.id = fingerid;
309 nf.x = x; 310 nf.x = x;
310 nf.y = y; 311 nf.y = y;
311 nf.pressure = pressure; 312 nf.pressure = pressure;
312 nf.xdelta = 0; 313 nf.xdelta = 0;
313 nf.ydelta = 0; 314 nf.ydelta = 0;
322 event.tfinger.touchId = (Uint8) id; 323 event.tfinger.touchId = (Uint8) id;
323 event.tfinger.x = x; 324 event.tfinger.x = x;
324 event.tfinger.y = y; 325 event.tfinger.y = y;
325 event.tfinger.state = touch->buttonstate; 326 event.tfinger.state = touch->buttonstate;
326 event.tfinger.windowID = touch->focus ? touch->focus->id : 0; 327 event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
327 event.tfinger.fingerId = id; 328 event.tfinger.fingerId = fingerid;
328 posted = (SDL_PushEvent(&event) > 0); 329 posted = (SDL_PushEvent(&event) > 0);
329 } 330 }
330 return posted; 331 return posted;
331 } 332 }
332 else { 333 else {
333 SDL_DelFinger(touch,id); 334 SDL_DelFinger(touch,fingerid);
334 posted = 0; 335 posted = 0;
335 if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) { 336 if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) {
336 SDL_Event event; 337 SDL_Event event;
337 event.tfinger.type = SDL_FINGERUP; 338 event.tfinger.type = SDL_FINGERUP;
338 event.tfinger.touchId = (Uint8) id; 339 event.tfinger.touchId = (Uint8) id;
339 event.tfinger.state = touch->buttonstate; 340 event.tfinger.state = touch->buttonstate;
340 event.tfinger.windowID = touch->focus ? touch->focus->id : 0; 341 event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
341 event.tfinger.fingerId = id; 342 event.tfinger.fingerId = fingerid;
342 posted = (SDL_PushEvent(&event) > 0); 343 posted = (SDL_PushEvent(&event) > 0);
343 } 344 }
344 return posted; 345 return posted;
345 } 346 }
346 } 347 }
417 /* Post the event, if desired */ 418 /* Post the event, if desired */
418 posted = 0; 419 posted = 0;
419 if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) { 420 if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
420 SDL_Event event; 421 SDL_Event event;
421 event.tfinger.type = SDL_FINGERMOTION; 422 event.tfinger.type = SDL_FINGERMOTION;
422 event.tfinger.touchId = (Uint8) index; 423 event.tfinger.touchId = (Uint8) id;
424 event.tfinger.fingerId = (Uint8) fingerid;
423 event.tfinger.x = x; 425 event.tfinger.x = x;
424 event.tfinger.y = y; 426 event.tfinger.y = y;
425 event.tfinger.state = touch->buttonstate; 427 event.tfinger.state = touch->buttonstate;
426 event.tfinger.windowID = touch->focus ? touch->focus->id : 0; 428 event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
427 posted = (SDL_PushEvent(&event) > 0); 429 posted = (SDL_PushEvent(&event) > 0);