mirror of
https://github.com/esuo1198/TaikoArcadeLoader.git
synced 2026-10-02 03:37:57 +03:00
optimize bnusio_GetAnalogIn
add High Resolution Timer move chs_voice to testmode remove garmc dirty logs fix pollasync keyboard & mouse wheel
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#include "constants.h"
|
||||
#include "helpers.h"
|
||||
#include "patches.h"
|
||||
|
||||
extern "C" NTSTATUS NTAPI NtSetTimerResolution(
|
||||
IN ULONG DesiredResolution,
|
||||
IN BOOLEAN SetResolution,
|
||||
OUT PULONG CurrentResolution
|
||||
);
|
||||
|
||||
extern "C" NTSTATUS NTAPI NtQueryTimerResolution(
|
||||
OUT PULONG CurrentResolution,
|
||||
OUT PULONG MinimumResolution,
|
||||
OUT PULONG MaximumResolution
|
||||
);
|
||||
|
||||
namespace patches::Timer {
|
||||
ULONG currentResolution = 0;
|
||||
ULONG minimumResolution = 0;
|
||||
ULONG maximumResolution = 0;
|
||||
|
||||
void
|
||||
Release () {
|
||||
NtSetTimerResolution(currentResolution, FALSE, ¤tResolution);
|
||||
}
|
||||
|
||||
void
|
||||
Init () {
|
||||
NTSTATUS queryStatus = NtQueryTimerResolution(¤tResolution, &minimumResolution, &maximumResolution);
|
||||
if (queryStatus == 0) {
|
||||
bool setHighResolutionTimer = currentResolution > maximumResolution;
|
||||
LogMessage (LogLevel::INFO, "Timer Resolution current: {}ms maximum: {}ms", currentResolution / 10000.0, maximumResolution / 10000.0);
|
||||
|
||||
if (setHighResolutionTimer) {
|
||||
NTSTATUS status = NtSetTimerResolution(maximumResolution, TRUE, ¤tResolution);
|
||||
if (status == 0) {
|
||||
LogMessage (LogLevel::INFO, "Successfully change Timer resolution to {}ms", maximumResolution / 10000.0);
|
||||
} else {
|
||||
LogMessage (LogLevel::ERROR, "Failed to change Timer resolution, status={}", status);
|
||||
}
|
||||
atexit (Release);
|
||||
}
|
||||
} else LogMessage (LogLevel::ERROR, "Failed to query Timer resolution, status={}", queryStatus);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user