Lime3DS/src/common/apple_utils.mm
OpenSauce 885bb71da8
Use MacOS-specific refresh rate check to avoid SDL race condition (#1262)
* Use MacOS-specific refresh rate check to avoid SDL race condition

* IsLowRefreshRate: Change back to `SDL_Init` just to be safe
2025-08-01 16:45:07 +01:00

33 lines
1.0 KiB
Plaintext

// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#import <Cocoa/Cocoa.h>
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
namespace AppleUtils {
float GetRefreshRate() { // TODO: How does this handle multi-monitor? -OS
NSScreen* screen = [NSScreen mainScreen];
if (screen) {
NSDictionary* screenInfo = [screen deviceDescription];
CGDirectDisplayID displayID =
(CGDirectDisplayID)[screenInfo[@"NSScreenNumber"] unsignedIntValue];
CGDisplayModeRef displayMode = CGDisplayCopyDisplayMode(displayID);
if (displayMode) {
CGFloat refreshRate = CGDisplayModeGetRefreshRate(displayMode);
CFRelease(displayMode);
return refreshRate;
}
}
return 60; // Something went wrong, so just return a generic value
}
int IsLowPowerModeEnabled() {
return (int)[NSProcessInfo processInfo].lowPowerModeEnabled;
}
} // namespace AppleUtils