cocoaTouch/OverlayViewController.m
changeset 3364 e5403e2bf02c
parent 3357 3836a31879e7
child 3385 361bd29293f4
equal deleted inserted replaced
3363:bcd6d76db4f7 3364:e5403e2bf02c
    13 #import "SDL_mouse.h"
    13 #import "SDL_mouse.h"
    14 #import "PopoverMenuViewController.h"
    14 #import "PopoverMenuViewController.h"
    15 #import "CommodityFunctions.h"
    15 #import "CommodityFunctions.h"
    16 
    16 
    17 @implementation OverlayViewController
    17 @implementation OverlayViewController
    18 @synthesize dimTimer, popoverController, popupMenu;
    18 @synthesize popoverController, popupMenu;
    19 
    19 
    20 
    20 
    21 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    21 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    22 	return rotationManager(interfaceOrientation);
    22 	return rotationManager(interfaceOrientation);
    23 }
    23 }
   292 	// this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances
   292 	// this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances
   293 	[self touchesEnded:touches withEvent:event];
   293 	[self touchesEnded:touches withEvent:event];
   294 }
   294 }
   295 
   295 
   296 -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
   296 -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
   297     int minimumGestureLength;
   297     CGFloat minimumGestureLength;
   298     int logCoeff;
   298     int logCoeff;
   299     
   299     
   300     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   300     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   301         minimumGestureLength =	5;
   301         minimumGestureLength = 5.0f;
   302         logCoeff = 19;
   302         logCoeff = 19;
   303     } else {
   303     } else {
   304         minimumGestureLength =	3;
   304         minimumGestureLength = 3.0f;
   305         logCoeff = 3;
   305         logCoeff = 3;
   306     }
   306     }
   307     
   307     
   308 	NSArray *twoTouches;
   308 	NSArray *twoTouches;
   309 	CGPoint currentPosition;
   309 	CGPoint currentPosition;
   316 			CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
   316 			CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
   317 			CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
   317 			CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
   318 			
   318 			
   319             if (deltaX >= minimumGestureLength) {
   319             if (deltaX >= minimumGestureLength) {
   320                 NSLog(@"Horizontal swipe detected, deltaX: %f deltaY: %f",deltaX, deltaY);
   320                 NSLog(@"Horizontal swipe detected, deltaX: %f deltaY: %f",deltaX, deltaY);
   321                 if (currentPosition.x > gestureStartPoint.x ) {
   321                 if (currentPosition.x > gestureStartPoint.x) {
   322                     HW_cursorLeft(logCoeff*log(deltaX));
   322                     HW_cursorLeft(logCoeff*log(deltaX));
   323                 } else {
   323                 } else {
   324                     HW_cursorRight(logCoeff*log(deltaX));
   324                     HW_cursorRight(logCoeff*log(deltaX));
   325                 }
   325                 }
   326 
   326 
   327             } 
   327             } 
   328             if (deltaY >= minimumGestureLength) {
   328             if (deltaY >= minimumGestureLength) {
   329                 NSLog(@"Horizontal swipe detected, deltaX: %f deltaY: %f",deltaX, deltaY);
   329                 NSLog(@"Horizontal swipe detected, deltaX: %f deltaY: %f",deltaX, deltaY);
   330                 if (currentPosition.y < gestureStartPoint.y ) {
   330                 if (currentPosition.y < gestureStartPoint.y) {
   331                     HW_cursorDown(logCoeff*log(deltaY));
   331                     HW_cursorDown(logCoeff*log(deltaY));
   332                 } else {
   332                 } else {
   333                     HW_cursorUp(logCoeff*log(deltaY));
   333                     HW_cursorUp(logCoeff*log(deltaY));
   334                 }            
   334                 }            
   335             }
   335             }