From 6407881cffdfbf85b4f5674f3daec2a195dd05bc Mon Sep 17 00:00:00 2001 From: Kevin Doyon Date: Fri, 19 Apr 2013 14:40:34 -0400 Subject: [PATCH] Fix SDL2 compile-errors, made it work on Win64 .. when compiled with MSVC2012 --- neo/CMakeLists.txt | 1 + neo/sys/events.cpp | 18 ++++++++++-------- neo/sys/win32/win_main.cpp | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index bb8b292b..1b1a40ee 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -213,6 +213,7 @@ elseif(MSVC) add_definitions(/wd4714) # 'function' marked as __forceinline not inlined add_definitions(/wd4996) # 'function': was declared deprecated add_definitions(/wd4068) # unknown pragma + add_definitions(-D_ALLOW_KEYWORD_MACROS) # because of the "#define private public" and "#define protected public" in TypeInfo.cpp set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG /Od /Zi /MDd") set(CMAKE_C_FLAGS_RELEASE "/Ox /Oy /MD") set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Ox /Oy /Zi /MD") diff --git a/neo/sys/events.cpp b/neo/sys/events.cpp index c75abb61..acb41ebc 100644 --- a/neo/sys/events.cpp +++ b/neo/sys/events.cpp @@ -424,15 +424,17 @@ sysEvent_t Sys_GetEvent() { #if SDL_VERSION_ATLEAST(2, 0, 0) case SDL_WINDOWEVENT: switch (ev.window.event) { - case SDL_WINDOWEVENT_FOCUS_GAINED: - // unset modifier, in case alt-tab was used to leave window and ALT is still set - // as that can cause fullscreen-toggling when pressing enter... - SDL_Keymod currentmod = SDL_GetModState(); - int newmod = KMOD_NONE; - if (currentmod & KMOD_CAPS) // preserve capslock - newmod |= KMOD_CAPS; + case SDL_WINDOWEVENT_FOCUS_GAINED: { + // unset modifier, in case alt-tab was used to leave window and ALT is still set + // as that can cause fullscreen-toggling when pressing enter... + SDL_Keymod currentmod = SDL_GetModState(); + + int newmod = KMOD_NONE; + if (currentmod & KMOD_CAPS) // preserve capslock + newmod |= KMOD_CAPS; - SDL_SetModState((SDL_Keymod)newmod); + SDL_SetModState((SDL_Keymod)newmod); + } // new context because visual studio complains about newmod and currentmod not initialized because of the case SDL_WINDOWEVENT_FOCUS_LOST GLimp_GrabInput(GRAB_ENABLE | GRAB_REENABLE | GRAB_HIDECURSOR); break; diff --git a/neo/sys/win32/win_main.cpp b/neo/sys/win32/win_main.cpp index d0145ddc..c7c113cb 100644 --- a/neo/sys/win32/win_main.cpp +++ b/neo/sys/win32/win_main.cpp @@ -393,7 +393,7 @@ Sys_ListFiles int Sys_ListFiles( const char *directory, const char *extension, idStrList &list ) { idStr search; struct _finddata_t findinfo; - int findhandle; + intptr_t findhandle; int flag; if ( !extension) {