Set timer resolution to 0.5ms on Windows
This commit is contained in:
parent
8b5717470a
commit
1555dae1c8
1 changed files with 31 additions and 0 deletions
31
main.cpp
31
main.cpp
|
|
@ -38,6 +38,33 @@ enum
|
|||
RET_FLAG_START_MINIMIZED = 8,
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* InitializeTimerResolution (Win32) *
|
||||
* *
|
||||
* On Windows, the default timer resolution is 15.6ms. For higher accuracy delays, *
|
||||
* the timer resolution should be set to a shorter interval. The shortest interval *
|
||||
* that can be set is 0.5ms. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
#ifdef _WIN32
|
||||
typedef unsigned int NTSTATUS;
|
||||
typedef NTSTATUS (*NTSETTIMERRESOLUTION)(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution);
|
||||
|
||||
void InitializeTimerResolution()
|
||||
{
|
||||
NTSETTIMERRESOLUTION NtSetTimerResolution;
|
||||
HMODULE NtDllHandle;
|
||||
ULONG CurrentResolution;
|
||||
|
||||
NtDllHandle = LoadLibrary("ntdll.dll");
|
||||
|
||||
NtSetTimerResolution = (NTSETTIMERRESOLUTION)GetProcAddress(NtDllHandle, "NtSetTimerResolution");
|
||||
|
||||
NtSetTimerResolution(5000, TRUE, &CurrentResolution);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* AttemptLocalConnection *
|
||||
|
|
@ -90,6 +117,10 @@ bool AttemptLocalConnection()
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef _WIN32
|
||||
//InitializeTimerResolution();
|
||||
#endif
|
||||
|
||||
ProfileManager profile_manager(rgb_controllers);
|
||||
NetworkServer server(rgb_controllers);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue