Removed the codepath that gets compiled if IPHONE_TOUCH_EFFICIENT_DANGEROUS is not defined. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Fri, 24 Oct 2014 04:06:45 -0300
branchiOS-improvements
changeset 951937ade10d4570
parent 9518 4bd15ffec1ad
child 9520 6a655264dd47
Removed the codepath that gets compiled if IPHONE_TOUCH_EFFICIENT_DANGEROUS is not defined.

The "dangerous" codepath relies on the fact that UITouch objects are persistent for the entire touch sequence, which is always guaranteed by Apple.
src/video/uikit/SDL_uikitview.h
src/video/uikit/SDL_uikitview.m
     1.1 --- a/src/video/uikit/SDL_uikitview.h	Fri Oct 24 03:56:34 2014 -0300
     1.2 +++ b/src/video/uikit/SDL_uikitview.h	Fri Oct 24 04:06:45 2014 -0300
     1.3 @@ -24,12 +24,6 @@
     1.4  
     1.5  #include "SDL_touch.h"
     1.6  
     1.7 -#define IPHONE_TOUCH_EFFICIENT_DANGEROUS
     1.8 -
     1.9 -#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.10 -#define MAX_SIMULTANEOUS_TOUCHES 5
    1.11 -#endif
    1.12 -
    1.13  #if SDL_IPHONE_KEYBOARD
    1.14  @interface SDL_uikitview : UIView <UITextFieldDelegate>
    1.15  #else
     2.1 --- a/src/video/uikit/SDL_uikitview.m	Fri Oct 24 03:56:34 2014 -0300
     2.2 +++ b/src/video/uikit/SDL_uikitview.m	Fri Oct 24 04:06:45 2014 -0300
     2.3 @@ -41,9 +41,6 @@
     2.4  
     2.5      SDL_TouchID touchId;
     2.6      UITouch *leftFingerDown;
     2.7 -#ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
     2.8 -    UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
     2.9 -#endif
    2.10  
    2.11  #if SDL_IPHONE_KEYBOARD
    2.12      UITextField *textField;
    2.13 @@ -99,24 +96,8 @@
    2.14          }
    2.15  
    2.16          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    2.17 -#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    2.18 -        /* FIXME: TODO: Using touch as the fingerId is potentially dangerous
    2.19 -         * It is also much more efficient than storing the UITouch pointer
    2.20 -         * and comparing it to the incoming event.
    2.21 -         */
    2.22          SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
    2.23                        SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
    2.24 -#else
    2.25 -        int i;
    2.26 -        for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
    2.27 -            if (finger[i] == NULL) {
    2.28 -                finger[i] = touch;
    2.29 -                SDL_SendTouch(touchId, i,
    2.30 -                              SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
    2.31 -                break;
    2.32 -            }
    2.33 -        }
    2.34 -#endif
    2.35      }
    2.36  }
    2.37  
    2.38 @@ -130,20 +111,8 @@
    2.39          }
    2.40  
    2.41          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    2.42 -#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    2.43          SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
    2.44                        SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
    2.45 -#else
    2.46 -        int i;
    2.47 -        for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
    2.48 -            if (finger[i] == touch) {
    2.49 -                SDL_SendTouch(touchId, i,
    2.50 -                              SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
    2.51 -                finger[i] = NULL;
    2.52 -                break;
    2.53 -            }
    2.54 -        }
    2.55 -#endif
    2.56      }
    2.57  }
    2.58  
    2.59 @@ -168,19 +137,8 @@
    2.60          }
    2.61  
    2.62          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    2.63 -#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    2.64          SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch),
    2.65                              locationInView.x, locationInView.y, 1.0f);
    2.66 -#else
    2.67 -        int i;
    2.68 -        for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
    2.69 -            if (finger[i] == touch) {
    2.70 -                SDL_SendTouchMotion(touchId, i,
    2.71 -                                    locationInView.x, locationInView.y, 1.0f);
    2.72 -                break;
    2.73 -            }
    2.74 -        }
    2.75 -#endif
    2.76      }
    2.77  }
    2.78