From 9d074519b25c5d2a562bb4f06a61b8d7955497ae Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 17 Aug 2026 02:09:58 +1000 Subject: [PATCH] [idd] config: retain four-decimal refresh rates --- idd/LGCommon/PipeMsg.h | 4 +-- idd/LGCommon/RefreshRate.cpp | 26 ++++++++------- idd/LGCommon/RefreshRate.h | 7 +++-- idd/LGIdd/config/CSettings.cpp | 24 +++++++------- idd/LGIdd/config/CSettings.h | 4 +-- idd/LGIdd/display/CDeviceContext.cpp | 2 +- idd/LGIdd/display/CDisplayConfiguration.cpp | 35 ++++++++++++--------- idd/LGIdd/display/CEdid.cpp | 11 ++++--- idd/LGIdd/ipc/CPipeServer.cpp | 4 +-- idd/LGIdd/ipc/CPipeServer.h | 2 +- idd/LGIdd/transport/FrameCaps.h | 2 +- idd/LGIdd/transport/lgmp/CLGMPFrameCaps.cpp | 2 +- idd/LGIddHelper/CConfigWindow.cpp | 14 ++++----- idd/LGIddHelper/CPipeClient.cpp | 4 ++- idd/LGIddHelper/CRegistrySettings.cpp | 24 +++++++------- idd/LGIddHelper/CRegistrySettings.h | 4 +-- 16 files changed, 93 insertions(+), 76 deletions(-) diff --git a/idd/LGCommon/PipeMsg.h b/idd/LGCommon/PipeMsg.h index f9e11580..3bb4968d 100644 --- a/idd/LGCommon/PipeMsg.h +++ b/idd/LGCommon/PipeMsg.h @@ -51,7 +51,7 @@ struct LGPipeMsg enum : uint32_t { RECOVERY_ACTIVE = 0x1U, - PROTOCOL_VERSION = 2U + PROTOCOL_VERSION = 3U }; union @@ -67,7 +67,7 @@ struct LGPipeMsg { uint32_t width; uint32_t height; - uint32_t refreshMilliHz; + uint32_t refresh100uHz; } displayMode; diff --git a/idd/LGCommon/RefreshRate.cpp b/idd/LGCommon/RefreshRate.cpp index aa4a575e..3b770d55 100644 --- a/idd/LGCommon/RefreshRate.cpp +++ b/idd/LGCommon/RefreshRate.cpp @@ -50,14 +50,14 @@ static bool ToUnsigned(const std::wstring& text, unsigned& value) return true; } -bool LGParseRefreshRate(const std::wstring& text, unsigned& refreshMilliHz) +bool LGParseRefreshRate(const std::wstring& text, unsigned& refresh100uHz) { const std::wstring value = Trim(text); const size_t decimal = value.find(L'.'); if (value.empty() || (decimal != std::wstring::npos && (value.find(L'.', decimal + 1) != std::wstring::npos || - decimal == 0 || decimal + 4 < value.size()))) + decimal == 0 || decimal + 5 < value.size()))) return false; const std::wstring wholeText = value.substr(0, decimal); @@ -71,30 +71,34 @@ bool LGParseRefreshRate(const std::wstring& text, unsigned& refreshMilliHz) return false; if (fractionText.size() == 1) - fraction *= 100; + fraction *= 1000; else if (fractionText.size() == 2) + fraction *= 100; + else if (fractionText.size() == 3) fraction *= 10; - const unsigned long long valueMilliHz = - (unsigned long long)whole * 1000 + fraction; - if (valueMilliHz < 23900 || valueMilliHz > 1000000) + const unsigned long long value100uHz = + (unsigned long long)whole * LG_REFRESH_RATE_SCALE + fraction; + if (value100uHz < 239000 || value100uHz > 10000000) return false; - refreshMilliHz = (unsigned)valueMilliHz; + refresh100uHz = (unsigned)value100uHz; return true; } -std::wstring LGFormatRefreshRate(unsigned refreshMilliHz) +std::wstring LGFormatRefreshRate(unsigned refresh100uHz) { - std::wstring result = std::to_wstring(refreshMilliHz / 1000); - const unsigned fraction = refreshMilliHz % 1000; + std::wstring result = std::to_wstring( + refresh100uHz / LG_REFRESH_RATE_SCALE); + const unsigned fraction = refresh100uHz % LG_REFRESH_RATE_SCALE; if (!fraction) return result; const wchar_t text[] = { L'.', - (wchar_t)(L'0' + fraction / 100), + (wchar_t)(L'0' + fraction / 1000), + (wchar_t)(L'0' + fraction / 100 % 10), (wchar_t)(L'0' + fraction / 10 % 10), (wchar_t)(L'0' + fraction % 10), L'\0' diff --git a/idd/LGCommon/RefreshRate.h b/idd/LGCommon/RefreshRate.h index f1bac3bf..3c3ba530 100644 --- a/idd/LGCommon/RefreshRate.h +++ b/idd/LGCommon/RefreshRate.h @@ -22,5 +22,8 @@ #include -bool LGParseRefreshRate(const std::wstring& text, unsigned& refreshMilliHz); -std::wstring LGFormatRefreshRate(unsigned refreshMilliHz); +// Refresh rates are represented in 100 microhertz units. +static constexpr unsigned LG_REFRESH_RATE_SCALE = 10000; + +bool LGParseRefreshRate(const std::wstring& text, unsigned& refresh100uHz); +std::wstring LGFormatRefreshRate(unsigned refresh100uHz); diff --git a/idd/LGIdd/config/CSettings.cpp b/idd/LGIdd/config/CSettings.cpp index cc5604a7..b66b8f84 100644 --- a/idd/LGIdd/config/CSettings.cpp +++ b/idd/LGIdd/config/CSettings.cpp @@ -33,14 +33,14 @@ CSettings::CSettings() CSettings::DisplayModes CSettings::LoadModes() { - const unsigned defaultRefreshMilliHz = GetDefaultRefreshMilliHz(); + const unsigned defaultRefresh100uHz = GetDefaultRefresh100uHz(); DisplayModes displayModes; bool hasPreferred = false; DisplayMode m; if (GetExtraMode(m)) { - const std::wstring refresh = LGFormatRefreshRate(m.refreshMilliHz); + const std::wstring refresh = LGFormatRefreshRate(m.refresh100uHz); DEBUG_INFO("ExtraMode: %ux%u@%ls%s", m.width, m.height, refresh.c_str(), m.preferred ? "*" : ""); displayModes.push_back(m); @@ -57,7 +57,7 @@ CSettings::DisplayModes CSettings::LoadModes() { m.width = DefaultDisplayModes[i][0]; m.height = DefaultDisplayModes[i][1]; - m.refreshMilliHz = defaultRefreshMilliHz; + m.refresh100uHz = defaultRefresh100uHz; m.preferred = !hasPreferred && (i == DefaultPreferredDisplayMode); m.extraMode = false; @@ -96,7 +96,7 @@ TransportInstances CSettings::LoadTransportInstances() const bool CSettings::SetExtraMode(const DisplayMode& mode) { WCHAR buf[64]; - const std::wstring refresh = LGFormatRefreshRate(mode.refreshMilliHz); + const std::wstring refresh = LGFormatRefreshRate(mode.refresh100uHz); _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%ux%u@%ls%s", mode.width, mode.height, refresh.c_str(), mode.preferred ? L"*" : L""); @@ -199,13 +199,13 @@ bool CSettings::GetExtraMode(DisplayMode& mode) return true; } -unsigned CSettings::GetDefaultRefreshMilliHz() const +unsigned CSettings::GetDefaultRefresh100uHz() const { HKEY hKey = nullptr; LONG status = RegOpenKeyExW( HKEY_LOCAL_MACHINE, RegistryKey(), 0, KEY_QUERY_VALUE, &hKey); if (status != ERROR_SUCCESS) - return 60000; + return 60 * LG_REFRESH_RATE_SCALE; DWORD type = 0; DWORD size = 0; @@ -214,17 +214,17 @@ unsigned CSettings::GetDefaultRefreshMilliHz() const if (status != ERROR_SUCCESS) { RegCloseKey(hKey); - return 60000; + return 60 * LG_REFRESH_RATE_SCALE; } - unsigned refreshMilliHz = 0; + unsigned refresh100uHz = 0; if (type == REG_DWORD && size == sizeof(DWORD)) { DWORD refresh = 0; status = RegQueryValueExW(hKey, L"DefaultRefresh", nullptr, &type, (LPBYTE)&refresh, &size); if (status == ERROR_SUCCESS && refresh >= 24 && refresh <= 1000) - refreshMilliHz = refresh * 1000; + refresh100uHz = refresh * LG_REFRESH_RATE_SCALE; } else if ((type == REG_SZ || type == REG_EXPAND_SZ) && size && size % sizeof(wchar_t) == 0) @@ -233,11 +233,11 @@ unsigned CSettings::GetDefaultRefreshMilliHz() const status = RegQueryValueExW(hKey, L"DefaultRefresh", nullptr, &type, (LPBYTE)value.data(), &size); if (status == ERROR_SUCCESS) - LGParseRefreshRate(value.data(), refreshMilliHz); + LGParseRefreshRate(value.data(), refresh100uHz); } RegCloseKey(hKey); - return refreshMilliHz ? refreshMilliHz : 60000; + return refresh100uHz ? refresh100uHz : 60 * LG_REFRESH_RATE_SCALE; } bool CSettings::ReadMultiStringValue(const wchar_t * name, @@ -331,7 +331,7 @@ bool CSettings::ParseModeString(const std::wstring& in, DisplayMode& out) if (!toUnsigned(s.substr(0, xPos), out.width) || !toUnsigned(s.substr(xPos + 1, atPos - (xPos + 1)), out.height) || - !LGParseRefreshRate(s.substr(atPos + 1), out.refreshMilliHz)) + !LGParseRefreshRate(s.substr(atPos + 1), out.refresh100uHz)) return false; // sanity check diff --git a/idd/LGIdd/config/CSettings.h b/idd/LGIdd/config/CSettings.h index faa4fbee..51c40209 100644 --- a/idd/LGIdd/config/CSettings.h +++ b/idd/LGIdd/config/CSettings.h @@ -32,7 +32,7 @@ class CSettings { unsigned width; unsigned height; - unsigned refreshMilliHz; + unsigned refresh100uHz; bool preferred; bool extraMode; }; @@ -44,7 +44,7 @@ class CSettings TransportInstances LoadTransportInstances() const; bool SetExtraMode(const DisplayMode & mode); bool GetExtraMode(DisplayMode & mode); - unsigned GetDefaultRefreshMilliHz() const; + unsigned GetDefaultRefresh100uHz() const; std::wstring ReadStringValue(const wchar_t* name, const wchar_t* defaultValue = nullptr); static bool ReadBoolValue( diff --git a/idd/LGIdd/display/CDeviceContext.cpp b/idd/LGIdd/display/CDeviceContext.cpp index aaf5c500..ebb6b2fa 100644 --- a/idd/LGIdd/display/CDeviceContext.cpp +++ b/idd/LGIdd/display/CDeviceContext.cpp @@ -440,7 +440,7 @@ void CDeviceContext::OnSwapChainReady() m_monitorManager.QueueReplug(); else if (action.setMode) g_pipe.SetDisplayMode( - action.mode.width, action.mode.height, action.mode.refreshMilliHz); + action.mode.width, action.mode.height, action.mode.refresh100uHz); } // Display configuration diff --git a/idd/LGIdd/display/CDisplayConfiguration.cpp b/idd/LGIdd/display/CDisplayConfiguration.cpp index 00d66da0..d974f4de 100644 --- a/idd/LGIdd/display/CDisplayConfiguration.cpp +++ b/idd/LGIdd/display/CDisplayConfiguration.cpp @@ -22,6 +22,7 @@ #include "CDebug.h" #include "CSRWLock.h" +#include "RefreshRate.h" #include #include @@ -66,24 +67,26 @@ bool CDisplayConfiguration::LoadModes(const FrameCaps& caps) { configuredMode.width, configuredMode.height, - configuredMode.refreshMilliHz, + configuredMode.refresh100uHz, }; if (!frameMode.width || !frameMode.height || - !frameMode.refreshMilliHz) + !frameMode.refresh100uHz) { - DEBUG_WARN("Filtering invalid %s mode %ux%u@%.3f", + DEBUG_WARN("Filtering invalid %s mode %ux%u@%.4f", configuredMode.extraMode ? "extra" : "configured", configuredMode.width, configuredMode.height, - configuredMode.refreshMilliHz / 1000.0); + configuredMode.refresh100uHz / + static_cast(LG_REFRESH_RATE_SCALE)); continue; } if (!caps.CanUseMode(frameMode)) { DEBUG_WARN( - "Filtering unsupported %s mode %ux%u@%.3f", + "Filtering unsupported %s mode %ux%u@%.4f", configuredMode.extraMode ? "extra" : "configured", configuredMode.width, configuredMode.height, - configuredMode.refreshMilliHz / 1000.0); + configuredMode.refresh100uHz / + static_cast(LG_REFRESH_RATE_SCALE)); continue; } @@ -128,11 +131,11 @@ bool CDisplayConfiguration::ReloadSettings( CSettings::DisplayMode extraMode = {}; if (m_settings.GetExtraMode(extraMode)) { - const unsigned refreshMilliHz = - m_settings.GetDefaultRefreshMilliHz(); - if (extraMode.refreshMilliHz != refreshMilliHz) + const unsigned refresh100uHz = + m_settings.GetDefaultRefresh100uHz(); + if (extraMode.refresh100uHz != refresh100uHz) { - extraMode.refreshMilliHz = refreshMilliHz; + extraMode.refresh100uHz = refresh100uHz; settingsUpdated = m_settings.SetExtraMode(extraMode); } } @@ -155,10 +158,10 @@ CDisplayConfiguration::SetResolution( CSettings::DisplayMode mode = {}; mode.width = width; mode.height = height; - mode.refreshMilliHz = m_settings.GetDefaultRefreshMilliHz(); + mode.refresh100uHz = m_settings.GetDefaultRefresh100uHz(); mode.preferred = true; - if (!mode.width || !mode.height || !mode.refreshMilliHz) + if (!mode.width || !mode.height || !mode.refresh100uHz) { DEBUG_WARN("Ignoring invalid resolution request: %ux%u", width, height); return result; @@ -168,7 +171,7 @@ CDisplayConfiguration::SetResolution( { mode.width, mode.height, - mode.refreshMilliHz, + mode.refresh100uHz, }; if (!caps.CanUseMode(frameMode, &result.requiredMiB)) { @@ -289,9 +292,11 @@ static inline void FillSignalInfo(DISPLAYCONFIG_VIDEO_SIGNAL_INFO& signal, signal.AdditionalSignalInfo.vSyncFreqDivider = monitorMode ? 0 : 1; signal.AdditionalSignalInfo.videoStandard = 255; - SetSignalRate(signal.vSyncFreq, mode.refreshMilliHz, 1000); + SetSignalRate(signal.vSyncFreq, mode.refresh100uHz, + LG_REFRESH_RATE_SCALE); SetSignalRate(signal.hSyncFreq, - (UINT64)mode.refreshMilliHz * signal.totalSize.cy, 1000); + (UINT64)mode.refresh100uHz * signal.totalSize.cy, + LG_REFRESH_RATE_SCALE); signal.scanLineOrdering = DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE; signal.pixelRate = timing.pixelClock; diff --git a/idd/LGIdd/display/CEdid.cpp b/idd/LGIdd/display/CEdid.cpp index b0972920..6775cca8 100644 --- a/idd/LGIdd/display/CEdid.cpp +++ b/idd/LGIdd/display/CEdid.cpp @@ -20,6 +20,8 @@ #include "display/CEdid.h" +#include "RefreshRate.h" + #include #include @@ -367,7 +369,7 @@ bool CEdid::GetTiming(Timing& timing, const CSettings::DisplayMode& mode) timing.vActive = mode.height; if (timing.hActive == 0 || timing.vActive == 0 || - mode.refreshMilliHz == 0) + mode.refresh100uHz == 0) return false; timing.hBlank = std::max(160, @@ -391,11 +393,12 @@ bool CEdid::GetTiming(Timing& timing, const CSettings::DisplayMode& mode) if (timing.vFront + timing.vSync >= timing.vBlank) return false; - const UINT64 pixelClockMilliHz = + const UINT64 pixelClock100uHz = (UINT64)(timing.hActive + timing.hBlank) * (UINT64)(timing.vActive + timing.vBlank) * - (UINT64)mode.refreshMilliHz; - timing.pixelClock = (pixelClockMilliHz + 500) / 1000; + (UINT64)mode.refresh100uHz; + timing.pixelClock = (pixelClock100uHz + LG_REFRESH_RATE_SCALE / 2) / + LG_REFRESH_RATE_SCALE; return timing.pixelClock != 0; } diff --git a/idd/LGIdd/ipc/CPipeServer.cpp b/idd/LGIdd/ipc/CPipeServer.cpp index b96fe1c5..268579d1 100644 --- a/idd/LGIdd/ipc/CPipeServer.cpp +++ b/idd/LGIdd/ipc/CPipeServer.cpp @@ -564,14 +564,14 @@ bool CPipeServer::SetCursorPos(int32_t x, int32_t y) } void CPipeServer::SetDisplayMode( - uint32_t width, uint32_t height, uint32_t refreshMilliHz) + uint32_t width, uint32_t height, uint32_t refresh100uHz) { LGPipeMsg msg = {}; msg.size = sizeof(msg); msg.type = LGPipeMsg::SETDISPLAYMODE; msg.displayMode.width = width; msg.displayMode.height = height; - msg.displayMode.refreshMilliHz = refreshMilliHz; + msg.displayMode.refresh100uHz = refresh100uHz; WriteMsg(msg); } diff --git a/idd/LGIdd/ipc/CPipeServer.h b/idd/LGIdd/ipc/CPipeServer.h index 90ee0176..16ab04e5 100644 --- a/idd/LGIdd/ipc/CPipeServer.h +++ b/idd/LGIdd/ipc/CPipeServer.h @@ -111,7 +111,7 @@ class CPipeServer : private IPipeEndpointHandler, bool SetCursorPos(int32_t x, int32_t y); void SetDisplayMode( - uint32_t width, uint32_t height, uint32_t refreshMilliHz); + uint32_t width, uint32_t height, uint32_t refresh100uHz); void SetGPUStatus(bool software); void ResolutionRejected(uint32_t width, uint32_t height, uint32_t requiredSizeMiB); diff --git a/idd/LGIdd/transport/FrameCaps.h b/idd/LGIdd/transport/FrameCaps.h index 62eca7f4..dc96374f 100644 --- a/idd/LGIdd/transport/FrameCaps.h +++ b/idd/LGIdd/transport/FrameCaps.h @@ -26,7 +26,7 @@ struct FrameMode { uint32_t width = 0; uint32_t height = 0; - uint32_t refreshMilliHz = 0; + uint32_t refresh100uHz = 0; }; class FrameCaps diff --git a/idd/LGIdd/transport/lgmp/CLGMPFrameCaps.cpp b/idd/LGIdd/transport/lgmp/CLGMPFrameCaps.cpp index cea95e48..f2ecb569 100644 --- a/idd/LGIdd/transport/lgmp/CLGMPFrameCaps.cpp +++ b/idd/LGIdd/transport/lgmp/CLGMPFrameCaps.cpp @@ -43,7 +43,7 @@ namespace const FrameMode& mode, uint64_t& frameSize) { frameSize = 0; - if (!mode.width || !mode.height || !mode.refreshMilliHz) + if (!mode.width || !mode.height || !mode.refresh100uHz) return false; uint64_t pitch; diff --git a/idd/LGIddHelper/CConfigWindow.cpp b/idd/LGIddHelper/CConfigWindow.cpp index 63636ecc..a04cf88e 100644 --- a/idd/LGIddHelper/CConfigWindow.cpp +++ b/idd/LGIddHelper/CConfigWindow.cpp @@ -254,7 +254,7 @@ void CConfigWindow::onModeListSelectChange() auto &mode = (*m_modes)[index]; m_modeWidth->setNumericValue(mode.width); m_modeHeight->setNumericValue(mode.height); - m_modeRefresh->setValue(LGFormatRefreshRate(mode.refreshMilliHz)); + m_modeRefresh->setValue(LGFormatRefreshRate(mode.refresh100uHz)); m_modePreferred->setChecked(mode.preferred); } EnableWindow(*m_modeUpdate, TRUE); @@ -294,11 +294,11 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd) return 0; } - unsigned refreshMilliHz; + unsigned refresh100uHz; if (!LGParseRefreshRate( - m_modeRefresh->getValue(), refreshMilliHz)) + m_modeRefresh->getValue(), refresh100uHz)) return 0; - mode.refreshMilliHz = refreshMilliHz; + mode.refresh100uHz = refresh100uHz; m_modeBox->clear(); m_modeBox->setSel(updateModeList(index)); @@ -325,10 +325,10 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd) } else if (m_defRefresh && hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh) { - unsigned refreshMilliHz; - if (!LGParseRefreshRate(m_defRefresh->getValue(), refreshMilliHz)) + unsigned refresh100uHz; + if (!LGParseRefreshRate(m_defRefresh->getValue(), refresh100uHz)) return 0; - m_defaultRefresh = refreshMilliHz; + m_defaultRefresh = refresh100uHz; } else if (m_prefNoGPU && hwnd == *m_prefNoGPU && code == BN_CLICKED && m_noGPU) { diff --git a/idd/LGIddHelper/CPipeClient.cpp b/idd/LGIddHelper/CPipeClient.cpp index d0b8200d..934840a9 100644 --- a/idd/LGIddHelper/CPipeClient.cpp +++ b/idd/LGIddHelper/CPipeClient.cpp @@ -24,6 +24,7 @@ #include "CSRWLock.h" #include "CNotifyWindow.h" #include "CRegistrySettings.h" +#include "RefreshRate.h" #include #include @@ -1011,7 +1012,8 @@ void CPipeClient::HandleSetDisplayMode(const LGPipeMsg& msg) dm.dmPelsWidth = msg.displayMode.width; dm.dmPelsHeight = msg.displayMode.height; dm.dmDisplayFrequency = - (msg.displayMode.refreshMilliHz + 500) / 1000; + (msg.displayMode.refresh100uHz + LG_REFRESH_RATE_SCALE / 2) / + LG_REFRESH_RATE_SCALE; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; diff --git a/idd/LGIddHelper/CRegistrySettings.cpp b/idd/LGIddHelper/CRegistrySettings.cpp index 8272c74b..3cc93ab6 100644 --- a/idd/LGIddHelper/CRegistrySettings.cpp +++ b/idd/LGIddHelper/CRegistrySettings.cpp @@ -29,7 +29,7 @@ #define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD" -const DWORD DEFAULT_REFRESH = 120000; +const DWORD DEFAULT_REFRESH = 120 * LG_REFRESH_RATE_SCALE; CRegistrySettings::CRegistrySettings() : hKey(nullptr) {} @@ -65,7 +65,7 @@ static std::basic_string trim(const std::basic_string &s) } static std::wregex displayMode( - L"(\\d+)x(\\d+)@(\\d+(?:\\.\\d{1,3})?)(\\*)?"); + L"(\\d+)x(\\d+)@(\\d+(?:\\.\\d{1,4})?)(\\*)?"); static std::optional parseDisplayMode(const std::wstring &str) { @@ -78,7 +78,7 @@ static std::optional parseDisplayMode(const std::wstring &str) DisplayMode mode; mode.width = std::stoul(match[1]); mode.height = std::stoul(match[2]); - if (!LGParseRefreshRate(match[3], mode.refreshMilliHz)) + if (!LGParseRefreshRate(match[3], mode.refresh100uHz)) return {}; mode.preferred = match[4] == L"*"; return mode; @@ -87,7 +87,7 @@ static std::optional parseDisplayMode(const std::wstring &str) std::vector CRegistrySettings::getDefaultModes() { auto defaultRefresh = getDefaultRefresh(); - const unsigned refreshMilliHz = + const unsigned refresh100uHz = defaultRefresh ? *defaultRefresh : DEFAULT_REFRESH; std::vector result; @@ -96,7 +96,7 @@ std::vector CRegistrySettings::getDefaultModes() DisplayMode mode; mode.width = DefaultDisplayModes[i][0]; mode.height = DefaultDisplayModes[i][1]; - mode.refreshMilliHz = refreshMilliHz; + mode.refresh100uHz = refresh100uHz; mode.preferred = i == DefaultPreferredDisplayMode; result.emplace_back(mode); } @@ -166,7 +166,7 @@ std::wstring DisplayMode::toString() serialized.push_back('x'); serialized.append(std::to_wstring(height)); serialized.push_back('@'); - serialized.append(LGFormatRefreshRate(refreshMilliHz)); + serialized.append(LGFormatRefreshRate(refresh100uHz)); if (preferred) serialized.push_back('*'); return serialized; @@ -192,7 +192,7 @@ std::optional CRegistrySettings::getDefaultRefresh() status = RegQueryValueExW(hKey, L"DefaultRefresh", nullptr, &type, (LPBYTE)&refresh, &size); if (status == ERROR_SUCCESS && refresh >= 24 && refresh <= 1000) - return refresh * 1000; + return refresh * LG_REFRESH_RATE_SCALE; } else if ((type == REG_SZ || type == REG_EXPAND_SZ) && size && size % sizeof(wchar_t) == 0) @@ -202,9 +202,9 @@ std::optional CRegistrySettings::getDefaultRefresh() (LPBYTE)value.data(), &size); if (status == ERROR_SUCCESS) { - unsigned refreshMilliHz; - if (LGParseRefreshRate(value.data(), refreshMilliHz)) - return refreshMilliHz; + unsigned refresh100uHz; + if (LGParseRefreshRate(value.data(), refresh100uHz)) + return refresh100uHz; } } @@ -212,9 +212,9 @@ std::optional CRegistrySettings::getDefaultRefresh() return {}; } -LSTATUS CRegistrySettings::setDefaultRefresh(DWORD refreshMilliHz) +LSTATUS CRegistrySettings::setDefaultRefresh(DWORD refresh100uHz) { - const std::wstring value = LGFormatRefreshRate(refreshMilliHz); + const std::wstring value = LGFormatRefreshRate(refresh100uHz); return RegSetValueExW(hKey, L"DefaultRefresh", 0, REG_SZ, (const BYTE *)value.c_str(), (DWORD)((value.size() + 1) * sizeof(wchar_t))); diff --git a/idd/LGIddHelper/CRegistrySettings.h b/idd/LGIddHelper/CRegistrySettings.h index cc0a2a7d..2b732c3a 100644 --- a/idd/LGIddHelper/CRegistrySettings.h +++ b/idd/LGIddHelper/CRegistrySettings.h @@ -28,7 +28,7 @@ struct DisplayMode { unsigned width; unsigned height; - unsigned refreshMilliHz; + unsigned refresh100uHz; bool preferred; std::wstring toString(); @@ -49,7 +49,7 @@ public: LSTATUS setModes(const std::vector &modes); std::optional getDefaultRefresh(); - LSTATUS setDefaultRefresh(DWORD refreshMilliHz); + LSTATUS setDefaultRefresh(DWORD refresh100uHz); std::optional getNoGPU(); LSTATUS setNoGPU(bool noGPU);