src/video/cocoa/SDL_cocoawindow.m
changeset 6951 7833f01322b3
parent 6950 1ddb72193079
child 6953 b83579d7d19a
equal deleted inserted replaced
6950:1ddb72193079 6951:7833f01322b3
   406     }
   406     }
   407 
   407 
   408     enumerator = [touches objectEnumerator];
   408     enumerator = [touches objectEnumerator];
   409     touch = (NSTouch*)[enumerator nextObject];
   409     touch = (NSTouch*)[enumerator nextObject];
   410     while (touch) {
   410     while (touch) {
   411         const SDL_TouchID touchId = (SDL_TouchID) ((size_t) [touch device]);
   411         const SDL_TouchID touchId = (SDL_TouchID)[touch device];
   412         if (!SDL_GetTouch(touchId)) {
   412         if (!SDL_GetTouch(touchId)) {
   413             SDL_Touch touch;
   413             if (SDL_AddTouch(touchId, "") < 0) {
   414 
       
   415             touch.id = touchId;
       
   416             touch.x_min = 0;
       
   417             touch.x_max = 1;
       
   418             touch.native_xres = touch.x_max - touch.x_min;
       
   419             touch.y_min = 0;
       
   420             touch.y_max = 1;
       
   421             touch.native_yres = touch.y_max - touch.y_min;
       
   422             touch.pressure_min = 0;
       
   423             touch.pressure_max = 1;
       
   424             touch.native_pressureres = touch.pressure_max - touch.pressure_min;
       
   425             
       
   426             if (SDL_AddTouch(&touch, "") < 0) {
       
   427                 return;
   414                 return;
   428             }
   415             }
   429         } 
   416         } 
   430 
   417 
   431         const SDL_FingerID fingerId = (SDL_FingerID) ((size_t) [touch identity]);
   418         const SDL_FingerID fingerId = (SDL_FingerID)[touch identity];
   432         float x = [touch normalizedPosition].x;
   419         float x = [touch normalizedPosition].x;
   433         float y = [touch normalizedPosition].y;
   420         float y = [touch normalizedPosition].y;
   434         /* Make the origin the upper left instead of the lower left */
   421         /* Make the origin the upper left instead of the lower left */
   435         y = 1.0f - y;
   422         y = 1.0f - y;
   436 
   423 
   437         switch (type) {
   424         switch (type) {
   438         case COCOA_TOUCH_DOWN:
   425         case COCOA_TOUCH_DOWN:
   439             SDL_SendFingerDown(touchId, fingerId, SDL_TRUE, x, y, 1);
   426             SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
   440             break;
   427             break;
   441         case COCOA_TOUCH_UP:
   428         case COCOA_TOUCH_UP:
   442         case COCOA_TOUCH_CANCELLED:
   429         case COCOA_TOUCH_CANCELLED:
   443             SDL_SendFingerDown(touchId, fingerId, SDL_FALSE, x, y, 1);
   430             SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
   444             break;
   431             break;
   445         case COCOA_TOUCH_MOVE:
   432         case COCOA_TOUCH_MOVE:
   446             SDL_SendTouchMotion(touchId, fingerId, SDL_FALSE, x, y, 1);
   433             SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
   447             break;
   434             break;
   448         }
   435         }
   449         
   436 
   450         touch = (NSTouch*)[enumerator nextObject];
   437         touch = (NSTouch*)[enumerator nextObject];
   451     }
   438     }
   452 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */
   439 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */
   453 }
   440 }
   454 
   441