From eeae8033bd4ffb9c27e3af4ad992de073b187f40 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 26 Jun 2020 18:03:55 +0200 Subject: [PATCH] Use SDL2 include files instead of those for SDL version 1. This resolves an irritating issue in the code editor where SDL2-specific functions could't be found. Not entirely sure about the SDL include file logic for other operating systems than Linux so the #ifdef directives may need to be updated further at a later date. --- es-app/src/guis/GuiInfoPopup.cpp | 7 ++++++- es-app/src/guis/GuiMenu.cpp | 8 +++++++- es-app/src/main.cpp | 14 +++++++++++--- es-core/src/AudioManager.cpp | 2 +- es-core/src/AudioManager.h | 7 ++++++- es-core/src/CECInput.cpp | 8 +++++++- es-core/src/InputConfig.cpp | 1 + es-core/src/InputConfig.h | 15 ++++++++++++--- es-core/src/InputManager.cpp | 8 +++++++- es-core/src/InputManager.h | 7 ++++++- es-core/src/Platform.cpp | 7 ++++++- es-core/src/Sound.h | 5 +++++ es-core/src/components/VideoComponent.cpp | 7 ++++++- es-core/src/components/VideoVlcComponent.cpp | 13 ++++++++++--- es-core/src/renderers/Renderer.cpp | 6 +++++- es-core/src/renderers/Renderer_GL21.cpp | 9 +++++++-- es-core/src/renderers/Renderer_GLES10.cpp | 9 +++++++-- 17 files changed, 110 insertions(+), 23 deletions(-) diff --git a/es-app/src/guis/GuiInfoPopup.cpp b/es-app/src/guis/GuiInfoPopup.cpp index e26f57517..5971bc42e 100644 --- a/es-app/src/guis/GuiInfoPopup.cpp +++ b/es-app/src/guis/GuiInfoPopup.cpp @@ -9,7 +9,12 @@ #include "components/ComponentGrid.h" #include "components/NinePatchComponent.h" #include "components/TextComponent.h" -#include + +#ifdef __linux__ +#include +#else +#include "SDL_timer.h" +#endif GuiInfoPopup::GuiInfoPopup( Window* window, diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 14dd12192..982e9ad5a 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -25,9 +25,15 @@ #include "Scripting.h" #include "SystemData.h" #include "VolumeControl.h" -#include + #include +#ifdef __linux__ +#include +#else +#include "SDL_events.h" +#endif + GuiMenu::GuiMenu( Window* window) : GuiComponent(window), diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 153b2e1a0..815586f69 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -30,10 +30,18 @@ #include "Settings.h" #include "SystemData.h" #include "SystemScreenSaver.h" + +#ifdef __linux__ +#include +#include +#include +#else +#include "SDL_events.h" +#include "SDL_main.h" +#include "SDL_timer.h" +#endif + #include -#include -#include -#include #include #include #ifdef WIN32 diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index 44651d6d2..ac1b7ce11 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -7,9 +7,9 @@ #include "AudioManager.h" #include "Log.h" +#include "SDL.h" #include "Settings.h" #include "Sound.h" -#include std::vector> AudioManager::sSoundVector; SDL_AudioSpec AudioManager::sAudioFormat; diff --git a/es-core/src/AudioManager.h b/es-core/src/AudioManager.h index c8d6624e4..68d5849e7 100644 --- a/es-core/src/AudioManager.h +++ b/es-core/src/AudioManager.h @@ -8,7 +8,12 @@ #ifndef ES_CORE_AUDIO_MANAGER_H #define ES_CORE_AUDIO_MANAGER_H -#include +#ifdef __linux__ +#include +#else +#include "SDL_audio.h" +#endif + #include #include diff --git a/es-core/src/CECInput.cpp b/es-core/src/CECInput.cpp index 542f77a5c..66ddc729b 100644 --- a/es-core/src/CECInput.cpp +++ b/es-core/src/CECInput.cpp @@ -12,7 +12,13 @@ #include // Bad bad cecloader. #include #include -#include + +#ifdef __linux__ +#include +#else +#include "SDL_events.h" +#endif // __linux__ + #ifdef _RPI_ extern "C" { #include diff --git a/es-core/src/InputConfig.cpp b/es-core/src/InputConfig.cpp index cda0d07c0..86c262dcb 100644 --- a/es-core/src/InputConfig.cpp +++ b/es-core/src/InputConfig.cpp @@ -7,6 +7,7 @@ #include "InputConfig.h" #include "Log.h" + #include // Some utility functions. diff --git a/es-core/src/InputConfig.h b/es-core/src/InputConfig.h index 5473742eb..cd74f2bba 100644 --- a/es-core/src/InputConfig.h +++ b/es-core/src/InputConfig.h @@ -9,13 +9,17 @@ #define ES_CORE_INPUT_CONFIG_H #include -#include -#include #include #include #include -namespace pugi { class xml_node; } +#ifdef __linux__ +#include +#include +#else +#include "SDL_joystick.h" +#include "SDL_keyboard.h" +#endif #define DEVICE_KEYBOARD -1 #define DEVICE_CEC -2 @@ -29,6 +33,11 @@ enum InputType { TYPE_COUNT }; +namespace pugi +{ + class xml_node; +} + struct Input { public: diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 768f9d9a1..c452ce332 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -14,8 +14,14 @@ #include "Platform.h" #include "Scripting.h" #include "Window.h" + +#ifdef __linux__ +#include +#else +#include "SDL.h" +#endif + #include -#include #include #include diff --git a/es-core/src/InputManager.h b/es-core/src/InputManager.h index 31b5a942e..73addc42c 100644 --- a/es-core/src/InputManager.h +++ b/es-core/src/InputManager.h @@ -10,7 +10,12 @@ #ifndef ES_CORE_INPUT_MANAGER_H #define ES_CORE_INPUT_MANAGER_H -#include +#ifdef __linux__ +#include +#else +#include "SDL_joystick.h" +#endif + #include class InputConfig; diff --git a/es-core/src/Platform.cpp b/es-core/src/Platform.cpp index 89c8d016f..f2aae8e41 100644 --- a/es-core/src/Platform.cpp +++ b/es-core/src/Platform.cpp @@ -6,7 +6,12 @@ #include "Platform.h" -#include +#ifdef __linux__ +#include +#else +#include "SDL_events.h" +#endif + #ifdef WIN32 #include #else diff --git a/es-core/src/Sound.h b/es-core/src/Sound.h index 5a39b69df..e7d973724 100644 --- a/es-core/src/Sound.h +++ b/es-core/src/Sound.h @@ -9,7 +9,12 @@ #ifndef ES_CORE_SOUND_H #define ES_CORE_SOUND_H +#ifdef __linux__ +#include +#else #include "SDL_audio.h" +#endif + #include #include #include diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index af3f4d168..d1824a377 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -5,7 +5,12 @@ #include "PowerSaver.h" #include "ThemeData.h" #include "Window.h" -#include + +#ifdef __linux__ +#include +#else +#include "SDL_timer.h" +#endif #define FADE_TIME_MS 200 diff --git a/es-core/src/components/VideoVlcComponent.cpp b/es-core/src/components/VideoVlcComponent.cpp index 4378cb9e6..93bafdb10 100644 --- a/es-core/src/components/VideoVlcComponent.cpp +++ b/es-core/src/components/VideoVlcComponent.cpp @@ -5,9 +5,16 @@ #include "utils/StringUtil.h" #include "PowerSaver.h" #include "Settings.h" + +#ifdef __linux__ +#include +#include +#else +#include "SDL_mutex.h" +#include "SDL_timer.h" +#endif + #include -#include -#include #ifdef WIN32 #include @@ -261,7 +268,7 @@ void VideoVlcComponent::startVideo() // Asynchronous media parsing libvlc_event_attach(libvlc_media_event_manager(mMedia), libvlc_MediaParsedChanged, VlcMediaParseCallback, 0); parseResult = libvlc_media_parse_with_options(mMedia, libvlc_media_parse_local, -1); - + if (!parseResult) { // Wait for a maximum of 1 second for the media parsing diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index d5e84275b..783c894e7 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -13,7 +13,11 @@ #include "Log.h" #include "Settings.h" -#include +#ifdef __linux__ +#include +#else +#include "SDL.h" +#endif #include namespace Renderer diff --git a/es-core/src/renderers/Renderer_GL21.cpp b/es-core/src/renderers/Renderer_GL21.cpp index 0e00c9b82..4d0223202 100644 --- a/es-core/src/renderers/Renderer_GL21.cpp +++ b/es-core/src/renderers/Renderer_GL21.cpp @@ -11,8 +11,13 @@ #include "Log.h" #include "Settings.h" -#include -#include +#ifdef __linux__ +#include +#include +#else +#include "SDL.h" +#include "SDL_opengl.h" +#endif namespace Renderer { diff --git a/es-core/src/renderers/Renderer_GLES10.cpp b/es-core/src/renderers/Renderer_GLES10.cpp index 675e62df9..96310cfc4 100644 --- a/es-core/src/renderers/Renderer_GLES10.cpp +++ b/es-core/src/renderers/Renderer_GLES10.cpp @@ -11,8 +11,13 @@ #include "Log.h" #include "Settings.h" -#include -#include +#ifdef __linux__ +#include +#include +#else +#include "SDL.h" +#include "SDL_opengl.h" +#endif namespace Renderer {