diff options
author | Memphiz <memphis@machzwo.de> | 2012-05-27 01:48:07 +0200 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2012-05-28 15:52:08 +0200 |
commit | 3841cbe5a750830f081eadfb45533253804f5eef (patch) | |
tree | 3b3c76f6879ad937ed1cc446293e876649755455 | |
parent | 135b03123e1cbbfbf47b9eecdb38f4bf51b3357a (diff) |
[ios/atv2] - add helper for detecting ipad3, refactor a bit for reusing the sysctlbyname code from DarwinIsAppleTV2
-rw-r--r-- | xbmc/osx/DarwinUtils.h | 1 | ||||
-rw-r--r-- | xbmc/osx/DarwinUtils.mm | 40 |
2 files changed, 32 insertions, 9 deletions
diff --git a/xbmc/osx/DarwinUtils.h b/xbmc/osx/DarwinUtils.h index d942edbac3..c2a4875520 100644 --- a/xbmc/osx/DarwinUtils.h +++ b/xbmc/osx/DarwinUtils.h @@ -28,6 +28,7 @@ extern "C" { #endif bool DarwinIsAppleTV2(void); + bool DarwinIsIPad3(void); const char *GetDarwinVersionString(void); float GetIOSVersion(void); int GetDarwinFrameworkPath(bool forPython, char* path, uint32_t *pathsize); diff --git a/xbmc/osx/DarwinUtils.mm b/xbmc/osx/DarwinUtils.mm index b9dc320a4e..bf05107214 100644 --- a/xbmc/osx/DarwinUtils.mm +++ b/xbmc/osx/DarwinUtils.mm @@ -43,6 +43,22 @@ #import "AutoPool.h" #import "DarwinUtils.h" +bool SysctlMatches(std::string key, std::string searchValue) +{ + int result = -1; +#if defined(TARGET_DARWIN_IOS) + char buffer[512]; + size_t len = 512; + result = 0; + + if (sysctlbyname(key.c_str(), &buffer, &len, NULL, 0) == 0) + key = buffer; + + if (key.find(searchValue) != std::string::npos) + result = 1; +#endif + return result; +} bool DarwinIsAppleTV2(void) { @@ -50,21 +66,27 @@ bool DarwinIsAppleTV2(void) #if defined(TARGET_DARWIN_IOS) if( result == -1 ) { - char buffer[512]; - size_t len = 512; - result = 0; - std::string hw_machine = "unknown"; - - if (sysctlbyname("hw.machine", &buffer, &len, NULL, 0) == 0) - hw_machine = buffer; + result = SysctlMatches("hw.machine", "AppleTV2,1"); + } +#endif + return (result == 1); +} - if (hw_machine.find("AppleTV2,1") != std::string::npos) - result = 1; +bool DarwinIsIPad3(void) +{ + static int result = -1; +#if defined(TARGET_DARWIN_IOS) + if( result == -1 ) + { + //valid ipad3 identifiers - iPad3,1 iPad3,2 and iPad3,3 + //taken from http://stackoverflow.com/questions/9638970/ios-the-new-ipad-uidevicehardware-hw-machine-codename + result = SysctlMatches("hw.machine", "iPad3"); } #endif return (result == 1); } + const char *GetDarwinVersionString(void) { return [[[NSProcessInfo processInfo] operatingSystemVersionString] UTF8String]; |