Hi,
as some of you may know, the commands GetMaxDeviceWidth() and GetMaxDeviceHeight() don't work for certain iOS devices.
I have used a workaround that took me a while to implement: retrieving the device name and then setting the resolution according to the device name. For this I used the link that xCept graciously provided to me (see
https://forum.thegamecreators.com/thread/222755) together with the resolutions that appear on Wikipedia (
https://en.wikipedia.org/wiki/List_of_iOS_devices).
I'm putting the corresponding C++ code below; only devices compatible with iOS>=9.35 are specified. It's readable, so it benefits both Tier 2 and Tier 1 users.
Cheers,
#include <valarray>
#include <string>
#include "agk.h"
std::valarray size;
std::string deviceType=std::string(agk::GetDeviceType());
if (deviceType=="iPhone4,1"){
//this is for iPhone 4s
size={640,76};
}
else if (deviceType=="iPhone5,1" || deviceType=="iPhone5,2" || deviceType=="iPhone5,3" || deviceType=="iPhone5,4" || deviceType=="iPhone6,1" || deviceType=="iPhone6,2" || deviceType=="iPhone8,4" || deviceType=="iPod5,1" || deviceType=="iPod7,1"){
//this is for iPhone 5, 5s, 5c, SE and iPod Touch 5, 6
size={640,1136};
}
else if (deviceType=="iPhone7,2" || deviceType=="iPhone8,1" || deviceType=="iPhone9,1" || deviceType=="iPhone9,3" || deviceType=="iPhone10,1" || deviceType=="iPhone10,4") {
//this is for iPhone 6, 6S, 7 and 8
size={750, 1334};
}
else if(deviceType=="iPhone7,1" || deviceType=="iPhone8,2" || deviceType=="iPhone9,2" || deviceType=="iPhone9,4" || deviceType=="iPhone10,2" || deviceType=="iPhone10,5") {
//this is for iPhone 6 Plus, 6S Plus, 7 Plus, 8 Plus
size={1080, 1920};
}
else if(deviceType=="iPhone10,3" || deviceType=="iPhone10,6" || deviceType=="iPhone11,2") {
//this is for iPhone X, Xs
size={1125, 2436};
}
else if(deviceType=="iPhone11,4" || deviceType=="iPhone11,6"){
//this is for iPhone Xs Max
size={1242,2688};
}
else if(deviceType=="iPhone11,8"){
//this is for iPhone Xr
size={828,1792};
}
else if(deviceType=="iPad2,1" || deviceType=="iPad2,2" || deviceType=="iPad2,3" || deviceType=="iPad2,4" || deviceType=="iPad2,5" || deviceType=="iPad2,6" || deviceType=="iPad2,7"){
//this is for iPad 2, and iPad Mini 1
size={768,1024};
}
else if(deviceType=="iPad3,1" || deviceType=="iPad3,2" || deviceType=="iPad3,3" || deviceType=="iPad3,4" || deviceType=="iPad3,5" || deviceType=="iPad3,6" || deviceType=="iPad4,1" || deviceType=="iPad4,2" || deviceType=="iPad4,3" || deviceType=="iPad4,4" || deviceType=="iPad4,5" || deviceType=="iPad4,6" || deviceType=="iPad4,7" || deviceType=="iPad4,8" || deviceType=="iPad4,9" || deviceType=="iPad5,1" || deviceType=="iPad5,2" || deviceType=="iPad5,3" || deviceType=="iPad5,4" || deviceType=="iPad6,3" || deviceType=="iPad6,4" || deviceType=="iPad6,11" || deviceType=="iPad6,12"|| deviceType=="iPad7,5"|| deviceType=="iPad7,6"){
//this is for iPad 3, 4, 5, 6, iPad Air 1, 2, and iPad Mini 2, 3, 4, (notice 5 is not yet in list in https://github.com/fieldnotescommunities/ios-device-identifiers/blob/master/ios-device-identifiers.json )
size={1536,2048};
}
else if(deviceType=="ipad7,1" || deviceType=="iPad7,2" || deviceType=="iPad8,5" || deviceType=="iPad8,6" || deviceType=="iPad8,7" || deviceType=="iPad8,8") {
//this is for iPad Pro (12.9") 1, 2, 3
size={2048, 2732};
}
else if(deviceType=="iPad7,3" || deviceType=="iPad7,4"){
//this is for iPad Pro 10.5"
size={1668,2224};
}
else if (deviceType=="iPad8,1" || deviceType=="iPad8,2" || deviceType=="iPad8,3" || deviceType=="iPad8,4"){
//this is for iPad Pro 11"
size={1668,2388};
}
else {
//the cases not covered
size={agk::GetMaxDeviceWidth(), agk::GetMaxDeviceHeight()};
}
AppGameKit 2018.10.10
iMac Book Pro, MacOS 10.14, Xcode 10.1;
iPhone 6, iOS 12; iPad (3rd gen), iOS 9.35; iPad Pro 12'9 (2nd gen), iOS 12.
Dell Precision T7400, Windows 7 Professional 64bit, Visual Studio Community 2017;