Created
June 12, 2011 10:39
-
-
Save frostney/1021417 to your computer and use it in GitHub Desktop.
Add a simple function in SDL iOS 1.3 to detect whether the current target is an iPhone or an iPad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add the function header to the your source file or header. | |
*/ | |
extern DECLSPEC int SDLCALL SDL_iPhoneIsDevicePad(void); | |
/* | |
How to call this function | |
*/ | |
if (SDL_iPhoneIsDevicePad()) | |
{ | |
// Initialize window with resolution of 768 x 1024 pixels or 1024 x 768 pixels | |
} | |
else | |
{ | |
// Initialize window with resolution of 320 x 480 pixels or 480 x 320 pixels | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add this little function to a .m file of your choice. I chose SDL_uikitview.m as it already has the iPhone specific keyboard functions in it. | |
I'm pretty sure you can choose any *.m file in /Library Source/video/uikit from the Xcode project file. | |
Make sure this function is added after @implementation ... @end. | |
*/ | |
int | |
SDL_iPhoneIsDevicePad(void) | |
{ | |
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 1 : 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment