From 8d285b9886b4569e6db01c7eb98a1913f81cd5bb Mon Sep 17 00:00:00 2001 From: Matlo Date: Tue, 22 Jul 2014 10:02:57 +0200 Subject: [PATCH] #262 --- shared/event/src/windows/timer.c | 29 +++++++++++++++---- .../event/src/windows/winmm/windows_wminput.c | 6 ++-- shared/event/test/GE_test.c | 2 ++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/shared/event/src/windows/timer.c b/shared/event/src/windows/timer.c index ac4feca4..0386a1db 100644 --- a/shared/event/src/windows/timer.c +++ b/shared/event/src/windows/timer.c @@ -20,17 +20,36 @@ HANDLE timer_start(int usec) timeBeginPeriod(1); hTimer = CreateWaitableTimer(NULL, FALSE, NULL); - LARGE_INTEGER li = { .QuadPart = 0 }; - SetWaitableTimer(hTimer, &li, usec / 1000, NULL, NULL, FALSE); + if(hTimer) + { + LARGE_INTEGER li = { .QuadPart = -(usec*10) }; + if(!SetWaitableTimer(hTimer, &li, usec / 1000, NULL, NULL, FALSE)) + { + fprintf(stderr, "SetWaitableTimer failed.\n"); + hTimer = NULL; + } + } + else + { + fprintf(stderr, "CreateWaitableTimer failed.\n"); + } + if(!hTimer) + { + timeEndPeriod(0); + } + return hTimer; } int timer_close(int unused) { - CloseHandle(hTimer); - - timeEndPeriod(0); + if(hTimer) + { + CloseHandle(hTimer); + + timeEndPeriod(0); + } return 1; } diff --git a/shared/event/src/windows/winmm/windows_wminput.c b/shared/event/src/windows/winmm/windows_wminput.c index 94ca2f94..e6e5bcb5 100644 --- a/shared/event/src/windows/winmm/windows_wminput.c +++ b/shared/event/src/windows/winmm/windows_wminput.c @@ -542,9 +542,11 @@ void wminput_handler_buff() } /* - * For some reason GetRawInputBuffer does not work when winmm and SDL-1.2.14 are used together... + * For some reason GetRawInputBuffer does not work in Windows 8: + * it seems there remain WM_INPUT messages in the queue, which + * make the MsgWaitForMultipleInput always return immediately. */ -int buff = 1; +int buff = 0; static LRESULT CALLBACK RawWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { diff --git a/shared/event/test/GE_test.c b/shared/event/test/GE_test.c index 5c3d09d0..c55ef9e5 100644 --- a/shared/event/test/GE_test.c +++ b/shared/event/test/GE_test.c @@ -50,6 +50,8 @@ int main(int argc, char* argv[]) //do something periodically } + GE_TimerClose(); + GE_quit(); printf("Exiting\n");