diff options
| author | OatmealDome <julian@oatmealdome.me> | 2026-01-09 20:15:52 -0500 |
|---|---|---|
| committer | OatmealDome <julian@oatmealdome.me> | 2026-03-21 11:16:14 -0400 |
| commit | 36d8dbc590580bd5694b143c62350f092c4fcdb6 (patch) | |
| tree | 88aa40fad228a7eb275928be4818149918d1e906 /Source/Core/Common | |
| parent | f074cdb08be338948d517e48a9bad6a8a2c991e0 (diff) | |
CommonFuncsObjC: Make function to fetch the current macOS version common
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | Source/Core/Common/CommonFuncs.h | 17 | ||||
| -rw-r--r-- | Source/Core/Common/CommonFuncsObjC.mm | 15 |
3 files changed, 34 insertions, 0 deletions
diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index e134acabd3..fe7aa9f72b 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -204,6 +204,7 @@ if (APPLE) PRIVATE ${APPKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} + ${FOUNDATION_LIBRARY} ${IOK_LIBRARY} ) elseif(WIN32) @@ -239,6 +240,7 @@ elseif(WIN32) ) elseif(APPLE) target_sources(common PRIVATE + CommonFuncsObjC.mm Logging/ConsoleListenerNix.cpp MemArenaDarwin.cpp ) diff --git a/Source/Core/Common/CommonFuncs.h b/Source/Core/Common/CommonFuncs.h index a2c20c67e3..b9238dad1c 100644 --- a/Source/Core/Common/CommonFuncs.h +++ b/Source/Core/Common/CommonFuncs.h @@ -8,6 +8,10 @@ #endif #include <string> +#ifdef __APPLE__ +#include "Common/CommonTypes.h" +#endif + #ifndef _WIN32 // go to debugger mode @@ -61,4 +65,17 @@ std::string GetWin32ErrorString(unsigned long error_code); // Obtains a full path to the specified module. std::optional<std::wstring> GetModuleName(void* hInstance); #endif + +#ifdef __APPLE__ +struct MacOSVersion // NSOperatingSystemVersion +{ + s64 major; // NSInteger majorVersion + s64 minor; // NSInteger minorVersion + s64 patch; // NSInteger patchVersion +}; + +// Helper function to get the current macOS version, which is easy to do with +// from Objective-C code, but a little harder from C++. +MacOSVersion GetMacOSVersion(); +#endif } // namespace Common diff --git a/Source/Core/Common/CommonFuncsObjC.mm b/Source/Core/Common/CommonFuncsObjC.mm new file mode 100644 index 0000000000..fdc7f48ce2 --- /dev/null +++ b/Source/Core/Common/CommonFuncsObjC.mm @@ -0,0 +1,15 @@ +// Copyright 2026 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "Common/CommonFuncs.h" + +#include <Foundation/Foundation.h> + +namespace Common +{ +MacOSVersion GetMacOSVersion() +{ + const NSOperatingSystemVersion ver = [[NSProcessInfo processInfo] operatingSystemVersion]; + return {ver.majorVersion, ver.minorVersion, ver.patchVersion}; +} +} // namespace Common |
