diff --git a/build/premake/extern_libs4.lua b/build/premake/extern_libs4.lua index 747d678ede..ad5111fda5 100644 --- a/build/premake/extern_libs4.lua +++ b/build/premake/extern_libs4.lua @@ -584,7 +584,7 @@ extern_lib_defs = { if os.is("windows") then includedirs { libraries_dir .. "sdl2/include/SDL" } elseif not _OPTIONS["android"] then - -- Support SDL*_CONFIG for overriding the default PATH-based sdl*-config + -- Support SDL2_CONFIG for overriding the default PATH-based sdl2-config sdl_config_path = os.getenv("SDL2_CONFIG") if not sdl_config_path then sdl_config_path = "sdl2-config" diff --git a/build/premake/premake4.lua b/build/premake/premake4.lua index 6c0c346ed4..d56fe07884 100644 --- a/build/premake/premake4.lua +++ b/build/premake/premake4.lua @@ -7,7 +7,6 @@ newoption { trigger = "icc", description = "Use Intel C++ Compiler (Linux only; newoption { trigger = "jenkins-tests", description = "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output" } newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" } newoption { trigger = "outpath", description = "Location for generated project files" } -newoption { trigger = "sdl1", description = "Build using deprecated SDL 1.2" } newoption { trigger = "with-system-mozjs31", description = "Search standard paths for libmozjs31, instead of using bundled copy" } newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" } newoption { trigger = "without-audio", description = "Disable use of OpenAL/Ogg/Vorbis APIs" } diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index df987659c6..d03db285db 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -611,9 +611,9 @@ void CConsole::SaveHistory() static bool isUnprintableChar(SDL_Keysym key) { - switch (key.sym) - { - // We want to allow some, which are handled specially + switch (key.sym) + { + // We want to allow some, which are handled specially case SDLK_RETURN: case SDLK_TAB: case SDLK_BACKSPACE: case SDLK_DELETE: case SDLK_HOME: case SDLK_END: @@ -622,10 +622,10 @@ static bool isUnprintableChar(SDL_Keysym key) case SDLK_PAGEUP: case SDLK_PAGEDOWN: return false; - // Ignore the others + // Ignore the others default: return true; - } + } } InReaction conInputHandler(const SDL_Event_* ev) diff --git a/source/ps/Hotkey.cpp b/source/ps/Hotkey.cpp index 6dc3a3d194..bdace58958 100644 --- a/source/ps/Hotkey.cpp +++ b/source/ps/Hotkey.cpp @@ -30,11 +30,9 @@ static bool unified[UNIFIED_LAST - UNIFIED_SHIFT]; -#define SDLKEY SDL_Keycode - struct SKey { - SDLKEY code; // keycode or MOUSE_ or UNIFIED_ value + SDL_Keycode code; // keycode or MOUSE_ or UNIFIED_ value bool negated; // whether the key must be pressed (false) or unpressed (true) }; @@ -81,7 +79,7 @@ static void LoadConfigBindings() continue; } - SKey key = { (SDLKEY)mapping, false }; + SKey key = { (SDL_Keycode)mapping, false }; keyCombination.push_back(key); } @@ -144,7 +142,7 @@ bool isNegated(const SKey& key) else if ((int)key.code > UNIFIED_LAST && g_mouse_buttons[key.code - UNIFIED_LAST] == key.negated) return false; // Modifier keycodes are between the normal keys and the mouse 'keys' - else if ((int)key.code < UNIFIED_LAST && (int)key.code > CUSTOM_SDL_KEYCODE && unified[key.code - UNIFIED_SHIFT] == key.negated) + else if ((int)key.code < UNIFIED_LAST && (int)key.code > SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES) && unified[key.code - UNIFIED_SHIFT] == key.negated) return false; else return true; @@ -214,25 +212,25 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev) phantom.ev.type = ((ev->ev.type == SDL_KEYDOWN) || (ev->ev.type == SDL_MOUSEBUTTONDOWN)) ? SDL_KEYDOWN : SDL_KEYUP; if ((keycode == SDLK_LSHIFT) || (keycode == SDLK_RSHIFT)) { - phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SHIFT; + phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_SHIFT; unified[0] = (phantom.ev.type == SDL_KEYDOWN); HotkeyInputHandler(&phantom); } else if ((keycode == SDLK_LCTRL) || (keycode == SDLK_RCTRL)) { - phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_CTRL; + phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_CTRL; unified[1] = (phantom.ev.type == SDL_KEYDOWN); HotkeyInputHandler(&phantom); } else if ((keycode == SDLK_LALT) || (keycode == SDLK_RALT)) { - phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_ALT; + phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_ALT; unified[2] = (phantom.ev.type == SDL_KEYDOWN); HotkeyInputHandler(&phantom); } else if ((keycode == SDLK_LGUI) || (keycode == SDLK_RGUI)) { - phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SUPER; + phantom.ev.key.keysym.sym = (SDL_Keycode)UNIFIED_SUPER; unified[3] = (phantom.ev.type == SDL_KEYDOWN); HotkeyInputHandler(&phantom); } @@ -246,7 +244,7 @@ InReaction HotkeyInputHandler(const SDL_Event_* ev) bool consoleCapture = false; - if (g_Console->IsActive() && keycode < CUSTOM_SDL_KEYCODE) + if (g_Console->IsActive() && keycode < SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES)) consoleCapture = true; // Here's an interesting bit: diff --git a/source/ps/KeyName.h b/source/ps/KeyName.h index 9718fcafff..6fe3aee1d4 100644 --- a/source/ps/KeyName.h +++ b/source/ps/KeyName.h @@ -27,12 +27,10 @@ extern void InitKeyNameMap(); extern CStr8 FindKeyName(int keycode); extern int FindKeyCode(const CStr8& keyname); -// Pick a code which is greater than any keycodes used by SDL itself -# define CUSTOM_SDL_KEYCODE SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES) - enum { // Start sequential IDs in the right place - EXTRA_KEYS_BASE = CUSTOM_SDL_KEYCODE, + // Pick a code which is greater than any keycodes used by SDL itself + EXTRA_KEYS_BASE = SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES), // 'Keycodes' for the unified modifier keys UNIFIED_SHIFT, UNIFIED_CTRL,