|
|
@@ -36,40 +36,6 @@ static bool __shiftDown = false;
|
|
|
long getMachTimeInMilliseconds();
|
|
|
int getKey(unichar keyCode);
|
|
|
|
|
|
-@interface UITouch (RotationPointExtension)
|
|
|
-- (CGPoint)locationInViewWithRotation:(UIView *)view;
|
|
|
-@end
|
|
|
-@implementation UITouch (RotationPointExtension)
|
|
|
-- (CGPoint)locationInViewWithRotation:(UIView *)view
|
|
|
-{
|
|
|
- CGPoint touchLoc = [self locationInView:view];
|
|
|
- CGPoint rotatedPoint = touchLoc;
|
|
|
- if(view == nil) view = self.window;
|
|
|
-
|
|
|
- if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait)
|
|
|
- {
|
|
|
- rotatedPoint.x = touchLoc.x;
|
|
|
- rotatedPoint.y = touchLoc.y;
|
|
|
- }
|
|
|
- else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)
|
|
|
- {
|
|
|
- rotatedPoint.x = view.frame.size.width - touchLoc.x;
|
|
|
- rotatedPoint.y = view.frame.size.height - touchLoc.y;
|
|
|
- }
|
|
|
- else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
|
|
|
- {
|
|
|
- rotatedPoint.x = touchLoc.y;
|
|
|
- rotatedPoint.y = view.frame.size.width - touchLoc.x;
|
|
|
- }
|
|
|
- else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
|
|
|
- {
|
|
|
- rotatedPoint.x = view.frame.size.height - touchLoc.y;
|
|
|
- rotatedPoint.y = touchLoc.x;
|
|
|
- }
|
|
|
- return rotatedPoint;
|
|
|
-}
|
|
|
-@end
|
|
|
-
|
|
|
@interface View : UIView <UIKeyInput>
|
|
|
{
|
|
|
EAGLContext* context;
|
|
|
@@ -339,8 +305,8 @@ int getKey(unichar keyCode);
|
|
|
unsigned int uniqueTouch = 0;
|
|
|
for(UITouch *t in touches)
|
|
|
{
|
|
|
- CGPoint touchLoc = [t locationInViewWithRotation:nil];
|
|
|
- Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.y, WINDOW_WIDTH - touchLoc.x, uniqueTouch);
|
|
|
+ CGPoint touchLoc = [t locationInView:self];
|
|
|
+ Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.y, touchLoc.x, uniqueTouch);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -349,8 +315,8 @@ int getKey(unichar keyCode);
|
|
|
unsigned int uniqueTouch = 0;
|
|
|
for(UITouch* t in touches)
|
|
|
{
|
|
|
- CGPoint touchLoc = [t locationInViewWithRotation:nil];
|
|
|
- Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.y, WINDOW_WIDTH - touchLoc.x, uniqueTouch);
|
|
|
+ CGPoint touchLoc = [t locationInView:self];
|
|
|
+ Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.y, touchLoc.x, uniqueTouch);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -366,8 +332,8 @@ int getKey(unichar keyCode);
|
|
|
int uniqueTouch = 0;
|
|
|
for(UITouch* t in touches)
|
|
|
{
|
|
|
- CGPoint touchLoc = [t locationInViewWithRotation:nil];
|
|
|
- Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.y, WINDOW_WIDTH - touchLoc.x, uniqueTouch);
|
|
|
+ CGPoint touchLoc = [t locationInView:self];
|
|
|
+ Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.y, touchLoc.x, uniqueTouch);
|
|
|
}
|
|
|
}
|
|
|
|