disable Vsync checkbox in case we are in borderelss or windowed mode to avoid unnecessary input lag

This commit is contained in:
FunkyFr3sh 2024-08-10 08:07:15 +02:00
parent b1c74f1628
commit 6f540a9603
3 changed files with 35 additions and 10 deletions

View file

@ -9,6 +9,7 @@
#include <SysUtils.hpp>
#include <Registry.hpp>
#include <System.Hash.hpp>
#include <VersionHelpers.h>
#include "ConfigFormUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
@ -1197,6 +1198,11 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
delete ini;
VsyncChk->Enabled = VsyncAllowed();
if (!VsyncChk->Enabled) {
VsyncChk->State = tssOff;
}
Initialized = true;
}
@ -1618,8 +1624,31 @@ bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValu
return s == "true" || s == "yes" || s == "1";
}
bool TConfigForm::VsyncAllowed()
{
if (GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) {
return true;
}
if (!IsWindows8OrGreater()) {
return true;
}
if (NonexclusiveChk->State == tssOff &&
(PresentationCbx->ItemIndex == 0 || PresentationCbx->ItemIndex == 1)) {
return true;
}
return false;
}
void __fastcall TConfigForm::PresentationCbxChange(TObject *Sender)
{
VsyncChk->Enabled = VsyncAllowed();
if (!VsyncChk->Enabled) {
VsyncChk->State = tssOff;
}
SaveSettings();
}
@ -1728,6 +1757,11 @@ void __fastcall TConfigForm::SinglecpuChkClick(TObject *Sender)
void __fastcall TConfigForm::NonexclusiveChkClick(TObject *Sender)
{
VsyncChk->Enabled = VsyncAllowed();
if (!VsyncChk->Enabled) {
VsyncChk->State = tssOff;
}
SaveSettings();
}