Add: Display refresh rate game option (#8813)
This commit is contained in:
@@ -236,6 +236,16 @@ bool VideoDriver_Allegro::ClaimMousePointer()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<int> VideoDriver_Allegro::GetListOfMonitorRefreshRates()
|
||||
{
|
||||
std::vector<int> rates = {};
|
||||
|
||||
int refresh_rate = get_refresh_rate();
|
||||
if (refresh_rate != 0) rates.push_back(refresh_rate);
|
||||
|
||||
return rates;
|
||||
}
|
||||
|
||||
struct AllegroVkMapping {
|
||||
uint16 vk_from;
|
||||
byte vk_count;
|
||||
|
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
bool ClaimMousePointer() override;
|
||||
|
||||
std::vector<int> GetListOfMonitorRefreshRates() override;
|
||||
|
||||
const char *GetName() const override { return "allegro"; }
|
||||
|
||||
protected:
|
||||
|
@@ -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();
|
||||
|
@@ -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.
|
||||
*/
|
||||
|
@@ -237,6 +237,17 @@ void VideoDriver_SDL_Base::EditBoxLostFocus()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> VideoDriver_SDL_Base::GetListOfMonitorRefreshRates()
|
||||
{
|
||||
std::vector<int> rates = {};
|
||||
for (int i = 0; i < SDL_GetNumVideoDisplays(); i++) {
|
||||
SDL_DisplayMode mode = {};
|
||||
if (SDL_GetDisplayMode(i, 0, &mode) != 0) continue;
|
||||
if (mode.refresh_rate != 0) rates.push_back(mode.refresh_rate);
|
||||
}
|
||||
return rates;
|
||||
}
|
||||
|
||||
|
||||
struct SDLVkMapping {
|
||||
SDL_Keycode vk_from;
|
||||
|
@@ -39,6 +39,8 @@ public:
|
||||
|
||||
void EditBoxLostFocus() override;
|
||||
|
||||
std::vector<int> GetListOfMonitorRefreshRates() override;
|
||||
|
||||
const char *GetName() const override { return "sdl"; }
|
||||
|
||||
protected:
|
||||
|
@@ -149,6 +149,15 @@ public:
|
||||
*/
|
||||
virtual void EditBoxGainedFocus() {}
|
||||
|
||||
/**
|
||||
* Get a list of refresh rates of each available monitor.
|
||||
* @return A vector of the refresh rates of all available monitors.
|
||||
*/
|
||||
virtual std::vector<int> GetListOfMonitorRefreshRates()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a suggested default GUI zoom taking screen DPI into account.
|
||||
*/
|
||||
|
@@ -916,6 +916,27 @@ void VideoDriver_Win32Base::EditBoxLostFocus()
|
||||
SetCandidatePos(this->main_wnd);
|
||||
}
|
||||
|
||||
std::vector<int> VideoDriver_Win32Base::GetListOfMonitorRefreshRates()
|
||||
{
|
||||
std::vector<int> rates = {};
|
||||
EnumDisplayMonitors(nullptr, nullptr, [](HMONITOR hMonitor, HDC hDC, LPRECT rc, LPARAM data) -> BOOL {
|
||||
auto &list = *reinterpret_cast<std::vector<int>*>(data);
|
||||
|
||||
MONITORINFOEX monitorInfo = {};
|
||||
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
||||
GetMonitorInfo(hMonitor, &monitorInfo);
|
||||
|
||||
DEVMODE devMode = {};
|
||||
devMode.dmSize = sizeof(DEVMODE);
|
||||
devMode.dmDriverExtra = 0;
|
||||
EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
|
||||
|
||||
if (devMode.dmDisplayFrequency != 0) list.push_back(devMode.dmDisplayFrequency);
|
||||
return true;
|
||||
}, reinterpret_cast<LPARAM>(&rates));
|
||||
return rates;
|
||||
}
|
||||
|
||||
Dimension VideoDriver_Win32Base::GetScreenSize() const
|
||||
{
|
||||
return { static_cast<uint>(GetSystemMetrics(SM_CXSCREEN)), static_cast<uint>(GetSystemMetrics(SM_CYSCREEN)) };
|
||||
|
@@ -33,6 +33,8 @@ public:
|
||||
|
||||
void EditBoxLostFocus() override;
|
||||
|
||||
std::vector<int> GetListOfMonitorRefreshRates() override;
|
||||
|
||||
protected:
|
||||
HWND main_wnd; ///< Handle to system window.
|
||||
bool fullscreen; ///< Whether to use (true) fullscreen mode.
|
||||
|
Reference in New Issue
Block a user