Commit 5759a8f1 authored by Sam Lantinga's avatar Sam Lantinga

Fixed issues with the touch coordinates in landscape mode.

In landscape mode the frame stays the same, and the transform property is modified with the appropriate rotation.
The touch coordinates are rotated by the transform, so if I want to normalize them by the frame rect, I have to transform the frame rect first.
parent f9a731d5
......@@ -50,6 +50,7 @@
@public
SDL_uikitviewcontroller *viewcontroller;
}
- (CGPoint)touchLocation:(UITouch *)touch;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
......
/*
/*
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
......@@ -60,10 +60,10 @@
//EventTouchData* data = (EventTouchData*)(touch.driverdata);
touch.x_min = 0;
touch.x_max = frame.size.width;
touch.x_max = 1;
touch.native_xres = touch.x_max - touch.x_min;
touch.y_min = 0;
touch.y_max = frame.size.height;
touch.y_max = 1;
touch.native_yres = touch.y_max - touch.y_min;
touch.pressure_min = 0;
touch.pressure_max = 1;
......@@ -77,6 +77,17 @@
}
- (CGPoint)touchLocation:(UITouch *)touch
{
CGPoint point = [touch locationInView: self];
CGRect frame = [self frame];
frame = CGRectApplyAffineTransform(frame, [self transform]);
point.x /= frame.size.width;
point.y /= frame.size.height;
return point;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSEnumerator *enumerator = [touches objectEnumerator];
......@@ -94,7 +105,7 @@
#ifdef FIXED_MULTITOUCH
while(touch) {
CGPoint locationInView = [touch locationInView: self];
CGPoint locationInView = [self touchLocation:touch];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
//FIXME: TODO: Using touch as the fingerId is potentially dangerous
......@@ -133,7 +144,7 @@
#ifdef FIXED_MULTITOUCH
while(touch) {
CGPoint locationInView = [touch locationInView: self];
CGPoint locationInView = [self touchLocation:touch];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
SDL_SendFingerDown(touchId, (long)touch,
......@@ -181,7 +192,7 @@
#ifdef FIXED_MULTITOUCH
while(touch) {
CGPoint locationInView = [touch locationInView: self];
CGPoint locationInView = [self touchLocation:touch];
#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
SDL_SendTouchMotion(touchId, (long)touch,
......
......@@ -138,16 +138,8 @@
return;
}
if (w == frame.size.width && h == frame.size.height) {
return;
}
frame.size.width = w;
frame.size.height = h;
frame.origin.x = 0;
frame.origin.y = 0;
[uiwindow setFrame:frame];
[data->view setFrame:frame];
[data->view updateFrame];
SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment