Add: Display refresh rate game option (#8813)

This commit is contained in:
sean
2021-03-09 10:22:52 +01:00
committed by GitHub
parent 64a8c38d2f
commit 0464a50ab8
12 changed files with 173 additions and 28 deletions

View File

@@ -47,6 +47,8 @@ public:
void EditBoxLostFocus() override;
std::vector<int> GetListOfMonitorRefreshRates() override;
/* --- The following methods should be private, but can't be due to Obj-C limitations. --- */
void MainLoopReal();

View File

@@ -43,6 +43,7 @@
#import <sys/param.h> /* for MAXPATHLEN */
#import <sys/time.h> /* gettimeofday */
#include <array>
/**
* Important notice regarding all modifications!!!!!!!
@@ -228,6 +229,30 @@ void VideoDriver_Cocoa::EditBoxLostFocus()
HandleTextInput(nullptr, true);
}
/**
* Get refresh rates of all connected monitors.
*/
std::vector<int> VideoDriver_Cocoa::GetListOfMonitorRefreshRates()
{
std::vector<int> rates{};
if (MacOSVersionIsAtLeast(10, 6, 0)) {
std::array<CGDirectDisplayID, 16> displays;
uint32_t count = 0;
CGGetActiveDisplayList(displays.size(), displays.data(), &count);
for (uint32_t i = 0; i < count; i++) {
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
int rate = (int)CGDisplayModeGetRefreshRate(mode);
if (rate > 0) rates.push_back(rate);
CGDisplayModeRelease(mode);
}
}
return rates;
}
/**
* Get the resolution of the main screen.
*/