Skip to content

Instantly share code, notes, and snippets.

@frostney
Created June 12, 2011 10:39
Show Gist options
  • Save frostney/1021417 to your computer and use it in GitHub Desktop.
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
/*
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
}
/*
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