iPad retina display, touch input is misaligned in 1.5 (LOGGED)
by John Vanderbeck · in iTorque 2D · 04/22/2012 (2:37 pm) · 19 replies
I'm sure this is something being fixed in 1.5.1, so i'm not really blaming GG on this, but I noticed that if I run on my iPad 3rd gen with the app deployed as an iPad app, then visually the images all look correct, but TOUCH input is misaligned. It acts as though the resolution is displaying at the retina read, but the touch is interacting at the old iPad res. If I deploy as an iPhone app everything works, though its ugly :p I will use this as a work around for now, but just wanted to through that out there.
Moderator: Logged as ITGB-297
Moderator: Logged as ITGB-297
#2
Is that what you meant?
It seems rather odd. I mean most apps designed for the old iPad resolution work fine on the new one with no updates, so i'm unclear why this doesn't.
04/22/2012 (3:39 pm)
Well since I made all my graphics at iPad1/2 resolution and they are filling the screen on the iPad3 then it would be my guess that the device is indeed doubling them. Is that what you meant?
It seems rather odd. I mean most apps designed for the old iPad resolution work fine on the new one with no updates, so i'm unclear why this doesn't.
#3
04/23/2012 (12:25 am)
I ended up completely rewriting the touch input so i've not noticed this myself.
#4
04/23/2012 (5:26 am)
Perhaps you have some zombie code that by error is hardcoded to compare the position basing on screen resolutions which would then likely fail in such a case?
#5
Tonight I will try building the included demos and see if they exhibit the same problem.
04/23/2012 (8:02 am)
Well the engine is completely stock 1.5, and i've done nothing in script that deals with resolution at all. I mean, i'm pretty much as basic stock as you can get.Tonight I will try building the included demos and see if they exhibit the same problem.
#6
04/23/2012 (9:06 am)
Yes this is a known issue currently. If you use XCode 4.3 the touch controller will be scaled incorrectly, oddly enough the issue doesn't occur with XCode 4.2.
#7
Building on 4.2 would also mean not building for iOS 5.1.
04/23/2012 (11:12 am)
Interesting. Is this a bug in XCode 4.3, or is there some setting that can be changed? Or is the only option to go back to 4.2? Are you even allowed to submit apps built with an old version of XCode? Building on 4.2 would also mean not building for iOS 5.1.
#8
04/23/2012 (12:37 pm)
Just to clarify ... any game that runs on the iPad3 will not work with 1.5?
#9
04/23/2012 (6:04 pm)
So i've managed to get the engine to use the higher res retina display for the DISPLAY, but still having the touch problem. Any clues where to look to track this one down?
#10
A lot stems from the original assumption that only the iPhone exists,and I think it just got worse as new devices started coming out. A total cleanup of all the device detection and handling would be a good thing to do :)
Anyway, for anyone else with this issue the problem with the input is that in iPhoneOGLVideo.mm there are several sections of code that assume that if you are in retina display then it MUST be an iPhone4, so you just need to open those up to allow it to be either device, and set your conversions accordingly.
04/23/2012 (6:18 pm)
Heh nevermind. I found it. Converting everything over to retina graphics and input took only a few hours. Not bad, though I have to admit the underlying code feels so hacky in many places :(A lot stems from the original assumption that only the iPhone exists,and I think it just got worse as new devices started coming out. A total cleanup of all the device detection and handling would be a good thing to do :)
Anyway, for anyone else with this issue the problem with the input is that in iPhoneOGLVideo.mm there are several sections of code that assume that if you are in retina display then it MUST be an iPhone4, so you just need to open those up to allow it to be either device, and set your conversions accordingly.
#11
@Scott
Out of the box 1.5 doesn't currently support the new iPad. If you built it using XCode 4.2 it probably will work without issue. I suspect this is due to 4.2 not being able to build against 5.1(without hacks) myself.
@John
Yes, the reason for the compatibility issue is that the retina display is still being detected and the retina code is getting activated. The retina code makes certain assumptions about resolution as the only device that had it at the time was the iPhone 4. It was a fair assumption to make at the time since it's taken Apple two years to put retina on another device and we intended to improve it later.
04/23/2012 (7:04 pm)
Sorry guys, took me while before I could spin back around and clarify.@Scott
Out of the box 1.5 doesn't currently support the new iPad. If you built it using XCode 4.2 it probably will work without issue. I suspect this is due to 4.2 not being able to build against 5.1(without hacks) myself.
@John
Yes, the reason for the compatibility issue is that the retina display is still being detected and the retina code is getting activated. The retina code makes certain assumptions about resolution as the only device that had it at the time was the iPhone 4. It was a fair assumption to make at the time since it's taken Apple two years to put retina on another device and we intended to improve it later.
#12
Oh yes, it was a fair assumption at the time, I agree. I was just saying it definitely needs some rework now :) In any case, updating it was pretty trivial so not a huge deal. Just had to spend some time getting familiar with the code.
04/23/2012 (7:19 pm)
@ScottOh yes, it was a fair assumption at the time, I agree. I was just saying it definitely needs some rework now :) In any case, updating it was pretty trivial so not a huge deal. Just had to spend some time getting familiar with the code.
#13
04/23/2012 (9:17 pm)
Can we flag this as a recognized bug for addressing in 1.5.1? (As in change the post's subject line and give it a tracking number).
#14
04/27/2012 (12:23 pm)
Logged as ITGB-297
#15
1. in platformiPhone/iPhoneOGLVideo.mm, go to line 366:
As you can see, the previous assumption was that if retina is disabled, then the device is an iPhone 4. Well, my assumption has backfired (like all assumptions do). Still, that's not the main problem. Detecting if the device supports retina is important, but now there are two devices (iPhone 4 and new iPad).
The real problem is located in the same source file, at line 482:
That function will changes the touch offset:
Doh! The code assumes that if retina is on, it must be an iPhone 4, so make use of values related to the iPhone resolutions (480, 320, 960, 640). While I have not coded it out fully, since there are several other areas where assumptions are made about retina, the basic idea for a fix would be this:
I know the above code is incomplete, but you see where I'm going with it. We know we can detect the device type (iPhone or iPad) and whether it has retina enabled. It's just a matter of setting landscapeResolution and portraitResolution to the appropriate values. Again, there are other areas of the code I need to check, but that is where I will start.
04/27/2012 (12:40 pm)
I can go ahead and tell you the exact area of code that the touch offset is busted. This might help you get further along until I can push 1.5.1 out:1. in platformiPhone/iPhoneOGLVideo.mm, go to line 366:
iPhone4 = false;
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
iPhone4 = true;As you can see, the previous assumption was that if retina is disabled, then the device is an iPhone 4. Well, my assumption has backfired (like all assumptions do). Still, that's not the main problem. Detecting if the device supports retina is important, but now there are two devices (iPhone 4 and new iPad).
The real problem is located in the same source file, at line 482:
ConvertToIPhone4(&point, platState.portrait);
That function will changes the touch offset:
void ConvertToIPhone4 (CGPoint *p, bool portrait)
{
p->x *= 2;
if(portrait)
p->y = ((p->y - 480) * 2);
else
p->y = ((p->y - 320) * 2);
}Doh! The code assumes that if retina is on, it must be an iPhone 4, so make use of values related to the iPhone resolutions (480, 320, 960, 640). While I have not coded it out fully, since there are several other areas where assumptions are made about retina, the basic idea for a fix would be this:
S32 landscapeResolution;
S32 portraitResolution;
// This can be either 480 or 1024
landscapeResolution = currentDeviceWidth;
// This can be either 320 or 768
portraitResolution = currentDeviceHeight;
void ConvertToIPhone4 (CGPoint *p, bool portrait)
{
p->x *= 2;
if(portrait)
p->y = ((p->y - landscapeResolution) * 2);
else
p->y = ((p->y - portraitResolution) * 2);
}I know the above code is incomplete, but you see where I'm going with it. We know we can detect the device type (iPhone or iPad) and whether it has retina enabled. It's just a matter of setting landscapeResolution and portraitResolution to the appropriate values. Again, there are other areas of the code I need to check, but that is where I will start.
#16
Would it be useful if I went through and diff'd out the changes that I made to get all this working? It covers both supporting retina resolutions, and fixing the touch alignment.
I can do that if it would be helpful. You do need to do a bit of bouncing around to handle both issues, but IIRC the majority of the changes are in iPhoneOGLVideo.mm and in iPhoneWindow.mm
04/27/2012 (1:08 pm)
@MichaelWould it be useful if I went through and diff'd out the changes that I made to get all this working? It covers both supporting retina resolutions, and fixing the touch alignment.
I can do that if it would be helpful. You do need to do a bit of bouncing around to handle both issues, but IIRC the majority of the changes are in iPhoneOGLVideo.mm and in iPhoneWindow.mm
#17
04/27/2012 (1:19 pm)
There are some areas of the scripts that also need to be touched up on, but you are right in that those two files are the source of problems. Because this is an open community, any contributions you would like to offer would be greatly appreciated. Because it is voluntary, you can share using whatever is most convenient to you. You can create a patch file, write up a step by step resource, or even just send the source files to people who request it.
#19
04/30/2012 (8:11 pm)
Just got bitten by this. I just got rejected on an update.
Torque Owner Scott Wilson-Billing
MeYuMe