src/video/uikit/SDL_uikitview.m
changeset 7050 aa1f44908402
parent 6951 7833f01322b3
child 7111 f4ae9f1233df
child 8460 f483e8bdae3c
equal deleted inserted replaced
7049:d4b70d310ade 7050:aa1f44908402
    92             SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    92             SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    93 
    93 
    94             /* send mouse down event */
    94             /* send mouse down event */
    95             SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    95             SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    96 
    96 
    97             leftFingerDown = (SDL_FingerID)touch;
    97             leftFingerDown = touch;
    98         }
    98         }
    99 
    99 
   100         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   100         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   101 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   101 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   102         // FIXME: TODO: Using touch as the fingerId is potentially dangerous
   102         // FIXME: TODO: Using touch as the fingerId is potentially dangerous
   103         // It is also much more efficient than storing the UITouch pointer
   103         // It is also much more efficient than storing the UITouch pointer
   104         // and comparing it to the incoming event.
   104         // and comparing it to the incoming event.
   105         SDL_SendTouch(touchId, (SDL_FingerID)touch,
   105         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
   106                       SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
   106                       SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
   107 #else
   107 #else
   108         int i;
   108         int i;
   109         for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
   109         for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
   110             if (finger[i] == NULL) {
   110             if (finger[i] == NULL) {
   123 {
   123 {
   124     NSEnumerator *enumerator = [touches objectEnumerator];
   124     NSEnumerator *enumerator = [touches objectEnumerator];
   125     UITouch *touch = (UITouch*)[enumerator nextObject];
   125     UITouch *touch = (UITouch*)[enumerator nextObject];
   126 
   126 
   127     while(touch) {
   127     while(touch) {
   128         if ((SDL_FingerID)touch == leftFingerDown) {
   128         if (touch == leftFingerDown) {
   129             /* send mouse up */
   129             /* send mouse up */
   130             SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
   130             SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
   131             leftFingerDown = 0;
   131             leftFingerDown = nil;
   132         }
   132         }
   133 
   133 
   134         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   134         CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   135 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   135 #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   136         SDL_SendTouch(touchId, (long)touch,
   136         SDL_SendTouch(touchId, (long)touch,
   164 {
   164 {
   165     NSEnumerator *enumerator = [touches objectEnumerator];
   165     NSEnumerator *enumerator = [touches objectEnumerator];
   166     UITouch *touch = (UITouch*)[enumerator nextObject];
   166     UITouch *touch = (UITouch*)[enumerator nextObject];
   167 
   167 
   168     while (touch) {
   168     while (touch) {
   169         if ((SDL_FingerID)touch == leftFingerDown) {
   169         if (touch == leftFingerDown) {
   170             CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   170             CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   171 
   171 
   172             /* send moved event */
   172             /* send moved event */
   173             SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
   173             SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
   174         }
   174         }