src/video/uikit/SDL_uikitview.m
branchiOS-improvements
changeset 9487 f9fbc2d1edb0
parent 8983 21f5923cfd15
child 9488 f15520430c94
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Sun Jul 13 09:04:55 2014 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Mon Jul 14 16:50:25 2014 -0300
     1.3 @@ -35,7 +35,7 @@
     1.4  #include "SDL_uikitmodes.h"
     1.5  #include "SDL_uikitwindow.h"
     1.6  
     1.7 -void _uikit_keyboard_init() ;
     1.8 +void _uikit_keyboard_init();
     1.9  
    1.10  @implementation SDL_uikitview
    1.11  
    1.12 @@ -66,7 +66,7 @@
    1.13      CGPoint point = [touch locationInView: self];
    1.14  
    1.15      /* Get the display scale and apply that to the input coordinates */
    1.16 -    SDL_Window *window = self->viewcontroller.window;
    1.17 +    SDL_Window *window = viewcontroller.window;
    1.18      SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.19      SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
    1.20  
    1.21 @@ -83,18 +83,15 @@
    1.22  
    1.23  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    1.24  {
    1.25 -    NSEnumerator *enumerator = [touches objectEnumerator];
    1.26 -    UITouch *touch = (UITouch*)[enumerator nextObject];
    1.27 -
    1.28 -    while (touch) {
    1.29 +    for (UITouch *touch in touches) {
    1.30          if (!leftFingerDown) {
    1.31              CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.32  
    1.33              /* send moved event */
    1.34 -            SDL_SendMouseMotion(self->viewcontroller.window, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    1.35 +            SDL_SendMouseMotion(viewcontroller.window, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    1.36  
    1.37              /* send mouse down event */
    1.38 -            SDL_SendMouseButton(self->viewcontroller.window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.39 +            SDL_SendMouseButton(viewcontroller.window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.40  
    1.41              leftFingerDown = touch;
    1.42          }
    1.43 @@ -118,19 +115,15 @@
    1.44              }
    1.45          }
    1.46  #endif
    1.47 -        touch = (UITouch*)[enumerator nextObject];
    1.48      }
    1.49  }
    1.50  
    1.51  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    1.52  {
    1.53 -    NSEnumerator *enumerator = [touches objectEnumerator];
    1.54 -    UITouch *touch = (UITouch*)[enumerator nextObject];
    1.55 -
    1.56 -    while(touch) {
    1.57 +    for (UITouch *touch in touches) {
    1.58          if (touch == leftFingerDown) {
    1.59              /* send mouse up */
    1.60 -            SDL_SendMouseButton(self->viewcontroller.window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.61 +            SDL_SendMouseButton(viewcontroller.window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.62              leftFingerDown = nil;
    1.63          }
    1.64  
    1.65 @@ -149,7 +142,6 @@
    1.66              }
    1.67          }
    1.68  #endif
    1.69 -        touch = (UITouch*)[enumerator nextObject];
    1.70      }
    1.71  }
    1.72  
    1.73 @@ -165,15 +157,12 @@
    1.74  
    1.75  - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    1.76  {
    1.77 -    NSEnumerator *enumerator = [touches objectEnumerator];
    1.78 -    UITouch *touch = (UITouch*)[enumerator nextObject];
    1.79 -
    1.80 -    while (touch) {
    1.81 +    for (UITouch *touch in touches) {
    1.82          if (touch == leftFingerDown) {
    1.83              CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.84  
    1.85              /* send moved event */
    1.86 -            SDL_SendMouseMotion(self->viewcontroller.window, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    1.87 +            SDL_SendMouseMotion(viewcontroller.window, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    1.88          }
    1.89  
    1.90          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.91 @@ -190,7 +179,6 @@
    1.92              }
    1.93          }
    1.94  #endif
    1.95 -        touch = (UITouch*)[enumerator nextObject];
    1.96      }
    1.97  }
    1.98