From 9b7685dd5df475cb33f9661c9763c0a7e3bd1e1d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 8 Apr 2024 19:32:30 +0200 Subject: [PATCH] Fixed an issue where the application couldn't be built with an older SDL release than 2.0.14 --- es-core/src/InputManager.cpp | 13 ++++++++++++- es-core/src/InputManager.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 8a9d947ff..aca74d144 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// ES-DE +// ES-DE Frontend // InputManager.cpp // // Low-level input handling. @@ -792,9 +792,15 @@ void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex) std::make_unique(joyID, SDL_GameControllerName(mControllers[joyID]), guid); bool customConfig {loadInputConfig(mInputConfigs[joyID].get())}; + +#if SDL_MAJOR_VERSION > 2 || (SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION > 0) || \ + (SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 && SDL_PATCHLEVEL >= 14) const std::string serialNumber {SDL_GameControllerGetSerial(controller) == nullptr ? "" : SDL_GameControllerGetSerial(controller)}; +#else + const std::string serialNumber; +#endif if (customConfig) { LOG(LogInfo) << "Added controller with custom configuration: \"" @@ -844,9 +850,14 @@ void InputManager::removeControllerByJoystickID(Window* window, SDL_JoystickID j return; } +#if SDL_MAJOR_VERSION > 2 || (SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION > 0) || \ + (SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 && SDL_PATCHLEVEL >= 14) const std::string serialNumber {SDL_GameControllerGetSerial(mControllers[joyID]) == nullptr ? "" : SDL_GameControllerGetSerial(mControllers[joyID])}; +#else + const std::string serialNumber; +#endif LOG(LogInfo) << "Removed controller \"" << SDL_GameControllerName(mControllers[joyID]) << "\" (GUID: " << guid diff --git a/es-core/src/InputManager.h b/es-core/src/InputManager.h index b77667975..cba5d53c4 100644 --- a/es-core/src/InputManager.h +++ b/es-core/src/InputManager.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// ES-DE +// ES-DE Frontend // InputManager.h // // Low-level input handling.