summaryrefslogtreecommitdiffstats
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorGeorge L. Albany <Megacake1234@gmail.com>2024-11-26 19:30:58 +0000
committerGitHub <noreply@github.com>2024-11-26 19:30:58 +0000
commitb06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e (patch)
tree79c2a4c34f2d888ff962d76edf474c518d1abdea /platform/windows/os_windows.cpp
parentc5b1645e60a59c0292c04bece3fdb0715a61afea (diff)
parente58e18261ea7ed3978146ef8d77a900be2601be3 (diff)
downloadredot-engine-b06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e.tar.gz
Merge pull request #885 from Spartan322/merge/d09d82d
Merge commit godotengine/godot@d09d82d
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 7ff14cc1e1..dbd68e56ec 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -819,22 +819,10 @@ double OS_Windows::get_unix_time() const {
}
void OS_Windows::delay_usec(uint32_t p_usec) const {
- constexpr uint32_t tolerance = 1000 + 20;
-
- uint64_t t0 = get_ticks_usec();
- uint64_t target_time = t0 + p_usec;
-
- // Calculate sleep duration with a tolerance for fine-tuning.
- if (p_usec > tolerance) {
- uint32_t coarse_sleep_usec = p_usec - tolerance;
- if (coarse_sleep_usec >= 1000) {
- Sleep(coarse_sleep_usec / 1000);
- }
- }
-
- // Spin-wait until we reach the precise target time.
- while (get_ticks_usec() < target_time) {
- YieldProcessor();
+ if (p_usec < 1000) {
+ Sleep(1);
+ } else {
+ Sleep(p_usec / 1000);
}
}
@@ -1753,7 +1741,7 @@ String OS_Windows::get_stdin_string(int64_t p_buffer_size) {
data.resize(p_buffer_size);
DWORD count = 0;
if (ReadFile(GetStdHandle(STD_INPUT_HANDLE), data.ptrw(), data.size(), &count, nullptr)) {
- return String::utf8((const char *)data.ptr(), count);
+ return String::utf8((const char *)data.ptr(), count).replace("\r\n", "\n").rstrip("\n");
}
return String();