src/video/uikit/SDL_uikitview.m
changeset 8477 ad08f0d710f3
parent 8460 f483e8bdae3c
parent 7191 75360622e65f
child 8535 e8ee0708ef5c
equal deleted inserted replaced
8476:25883bdf3cab 8477:ad08f0d710f3
    28 #include "../../events/SDL_mouse_c.h"
    28 #include "../../events/SDL_mouse_c.h"
    29 #include "../../events/SDL_touch_c.h"
    29 #include "../../events/SDL_touch_c.h"
    30 
    30 
    31 #if SDL_IPHONE_KEYBOARD
    31 #if SDL_IPHONE_KEYBOARD
    32 #include "keyinfotable.h"
    32 #include "keyinfotable.h"
       
    33 #endif
    33 #include "SDL_uikitappdelegate.h"
    34 #include "SDL_uikitappdelegate.h"
    34 #include "SDL_uikitmodes.h"
    35 #include "SDL_uikitmodes.h"
    35 #include "SDL_uikitwindow.h"
    36 #include "SDL_uikitwindow.h"
    36 #endif
       
    37 
    37 
    38 @implementation SDL_uikitview
    38 @implementation SDL_uikitview
    39 
    39 
    40 - (void)dealloc
    40 - (void)dealloc
    41 {
    41 {
    61 
    61 
    62 - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize
    62 - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize
    63 {
    63 {
    64     CGPoint point = [touch locationInView: self];
    64     CGPoint point = [touch locationInView: self];
    65 
    65 
    66     // Get the display scale and apply that to the input coordinates
    66     /* Get the display scale and apply that to the input coordinates */
    67     SDL_Window *window = self->viewcontroller.window;
    67     SDL_Window *window = self->viewcontroller.window;
    68     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    68     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    69     SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
    69     SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
    70     
    70 
    71     if (normalize) {
    71     if (normalize) {
    72         CGRect bounds = [self bounds];
    72         CGRect bounds = [self bounds];
    73         point.x /= bounds.size.width;
    73         point.x /= bounds.size.width;
    74         point.y /= bounds.size.height;
    74         point.y /= bounds.size.height;
    75     } else {
    75     } else {
    97             leftFingerDown = 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          */
   105         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
   106         SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
   106                       SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
   107                       SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
   107 #else
   108 #else
   108         int i;
   109         int i;
   109         for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
   110         for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {