MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / GetRefreshRateFromDWM

Function GetRefreshRateFromDWM

common/WindowInfo.cpp:83–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static std::optional<float> GetRefreshRateFromDWM(HWND hwnd)
84{
85 BOOL composition_enabled;
86 if (FAILED(DwmIsCompositionEnabled(&composition_enabled)))
87 return std::nullopt;
88
89 DWM_TIMING_INFO ti = {};
90 ti.cbSize = sizeof(ti);
91 HRESULT hr = DwmGetCompositionTimingInfo(nullptr, &ti);
92 if (SUCCEEDED(hr))
93 {
94 if (ti.rateRefresh.uiNumerator == 0 || ti.rateRefresh.uiDenominator == 0)
95 return std::nullopt;
96
97 return static_cast<float>(ti.rateRefresh.uiNumerator) / static_cast<float>(ti.rateRefresh.uiDenominator);
98 }
99
100 return std::nullopt;
101}
102
103static std::optional<float> GetRefreshRateFromMonitor(HWND hwnd)
104{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected