comparison src/events/SDL_touch.c @ 4865:fff50e86c891

Update VS2010 project to add new files; update new files so code builds on Win32/Win64
author Andreas Schiffler <aschiffler@ferzkopp.net>
date Mon, 23 Aug 2010 23:44:28 -0700
parents f9ab8df6d45a
children d6adaafcfb10
comparison
equal deleted inserted replaced
4864:ebcb4988b16f 4865:fff50e86c891
311 int 311 int
312 SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, 312 SDL_SendFingerDown(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down,
313 float xin, float yin, float pressurein) 313 float xin, float yin, float pressurein)
314 { 314 {
315 int posted; 315 int posted;
316 Uint16 x;
317 Uint16 y;
318 Uint16 pressure;
319 SDL_Finger *finger;
320
316 SDL_Touch* touch = SDL_GetTouch(id); 321 SDL_Touch* touch = SDL_GetTouch(id);
317 322
318 if(!touch) { 323 if(!touch) {
319 return SDL_TouchNotFoundError(id); 324 return SDL_TouchNotFoundError(id);
320 } 325 }
321 326
322 327
323 //scale to Integer coordinates 328 //scale to Integer coordinates
324 Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres); 329 x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
325 Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres); 330 y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
326 Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres); 331 pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
327 332
328 SDL_Finger *finger = SDL_GetFinger(touch,fingerid); 333 finger = SDL_GetFinger(touch,fingerid);
329 if(down) { 334 if(down) {
330 if(finger == NULL) { 335 if(finger == NULL) {
331 SDL_Finger nf; 336 SDL_Finger nf;
332 nf.id = fingerid; 337 nf.id = fingerid;
333 nf.x = x; 338 nf.x = x;
391 SDL_Touch *touch = SDL_GetTouch(id); 396 SDL_Touch *touch = SDL_GetTouch(id);
392 SDL_Finger *finger = SDL_GetFinger(touch,fingerid); 397 SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
393 int posted; 398 int posted;
394 Sint16 xrel, yrel; 399 Sint16 xrel, yrel;
395 float x_max = 0, y_max = 0; 400 float x_max = 0, y_max = 0;
401 Uint16 x;
402 Uint16 y;
403 Uint16 pressure;
396 404
397 if (!touch) { 405 if (!touch) {
398 return SDL_TouchNotFoundError(id); 406 return SDL_TouchNotFoundError(id);
399 } 407 }
400 408
401 //scale to Integer coordinates 409 //scale to Integer coordinates
402 Uint16 x = (xin+touch->x_min)*(touch->xres)/(touch->native_xres); 410 x = (Uint16)((xin+touch->x_min)*(touch->xres)/(touch->native_xres));
403 Uint16 y = (yin+touch->y_min)*(touch->yres)/(touch->native_yres); 411 y = (Uint16)((yin+touch->y_min)*(touch->yres)/(touch->native_yres));
404 Uint16 pressure = (yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres); 412 pressure = (Uint16)((yin+touch->pressure_min)*(touch->pressureres)/(touch->native_pressureres));
405 if(touch->flush_motion) { 413 if(touch->flush_motion) {
406 return 0; 414 return 0;
407 } 415 }
408 416
409 if(finger == NULL || !finger->down) { 417 if(finger == NULL || !finger->down) {
542 } 550 }
543 return touch->name; 551 return touch->name;
544 } 552 }
545 553
546 int SDL_TouchNotFoundError(SDL_TouchID id) { 554 int SDL_TouchNotFoundError(SDL_TouchID id) {
555 int i;
547 printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id); 556 printf("ERROR: Cannot send touch on non-existent device with id: %li make sure SDL_AddTouch has been called\n",id);
548 printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch); 557 printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
549 int i;
550 for(i=0;i < SDL_num_touch;i++) { 558 for(i=0;i < SDL_num_touch;i++) {
551 printf("ERROR: %li\n",SDL_touchPads[i]->id); 559 printf("ERROR: %li\n",SDL_touchPads[i]->id);
552 } 560 }
553 return 0; 561 return 0;
554 } 562 }