From eb65d1006ad9aa10aaf2e67eb583cee8d30ea6a3 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 21 Jun 2018 16:06:53 +0200 Subject: [PATCH] win32: avoid taking 100% CPU time --- src/input.c | 8 ++++++++ src/text.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/input.c b/src/input.c index c2fc7888..b65c6830 100644 --- a/src/input.c +++ b/src/input.c @@ -1171,6 +1171,14 @@ int Get_input(int sleep_time) } return 1; } + if (sleep_time == 0) + sleep_time = 20; // default of 20 ms + // TODO : we should check where Get_input(0) is called + { + UINT_PTR timerId = SetTimer(NULL, 0, sleep_time, NULL); + WaitMessage(); + KillTimer(NULL, timerId); + } #endif return 0; } diff --git a/src/text.c b/src/text.c index 056fb036..95ad597a 100644 --- a/src/text.c +++ b/src/text.c @@ -57,6 +57,10 @@ #define snprintf _snprintf #endif #endif +#if defined(WIN32) +#include +#include +#endif #if defined(USE_SDL) || defined(USE_SDL2) #include