chore: Convert simu/simulator/companion to SDL2 (#3085)

* chore(pc): convert simu/simulator/companion to use SDL2

* switch companion builds to SDL2 - OSX is not converted
the linux change is done a bit hacky, it should be done by updating the EdgeTX docker container

* update build system setup scripts

* add compatibility for old and new SDL2 cmake integration

* fix windows installer

* fix simulator audio on windows by using DirectSound vie SDL2

* fix windows audio with SDL2
enable simu for windows builds

* remove workflow changes for linux builds, this needs to be fixed in the build environment

* fix OSX build, thx @pafleraf

* fix windows audio for companion and simulator with SDL2

* select SDL2 branch of the build-docker environment

* Revert "select SDL2 branch of the build-docker environment"

This reverts commit da801609d78e1aed513ad7d9d8ab3ebded2900b9.

* fix tests with SDL2
This commit is contained in:
Malte Langermann
2023-02-22 20:32:51 +10:00
committed by GitHub
parent cbec97d76e
commit 8d91c0ae95
21 changed files with 72 additions and 67 deletions
+12 -9
View File
@@ -48,9 +48,12 @@ if(WIN32)
endif()
endif()
if(SDL_FOUND)
include_directories(${SDL_INCLUDE_DIR})
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIRS})
add_definitions(-DJOYSTICKS)
if(TARGET SDL2::SDL2)
set(SDL2_LIBRARIES SDL2::SDL2)
endif()
endif()
add_definitions(${APP_COMMON_DEFINES}) # set in top-level CMakeLists
@@ -175,7 +178,7 @@ target_link_libraries(common
Qt5::Xml
Qt5::Widgets
${PTHREAD_LIBRARY}
${SDL_LIBRARY}
${SDL2_LIBRARIES}
${WIN_LINK_LIBRARIES}
)
@@ -417,12 +420,12 @@ elseif(WIN32)
# Add installer command to execute windeployqt
message(STATUS "windeployqt command: ${QT_BIN_DIR}/windeployqt.exe ${wdqtopts}")
# SDL dll
if(SDL_FOUND AND EXISTS "${SDL_LIBRARY_PATH}/SDL.dll")
set(SDL_DIR ${SDL_LIBRARY_PATH}) # this is also used by NSIS installer script
install(FILES ${SDL_DIR}/SDL.dll DESTINATION ${INSTALL_DESTINATION})
elseif(SDL_FOUND)
message(WARNING "Installer: SDL.dll not found, set SDL_LIBRARY_PATH manually.")
# SDL2 dll
if(SDL2_FOUND AND EXISTS "${SDL2_LIBRARY_PATH}/SDL2.dll")
set(SDL2_DIR ${SDL2_LIBRARY_PATH}) # this is also used by NSIS installer script
install(FILES ${SDL2_DIR}/SDL2.dll DESTINATION ${INSTALL_DESTINATION})
elseif(SDL2_FOUND)
message(WARNING "Installer: SDL2.dll not found, set SDL2_LIBRARY_PATH manually.")
endif()
if (OPENSSL_FOUND)
+3
View File
@@ -222,6 +222,9 @@ int main(int argc, char *argv[])
#ifdef SIMU_AUDIO
sdlFlags |= SDL_INIT_AUDIO;
#endif
#if defined(_WIN32) || defined(_WIN64)
putenv("SDL_AUDIODRIVER=directsound");
#endif
if (SDL_Init(sdlFlags) < 0) {
fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
}
+1 -1
View File
@@ -93,7 +93,7 @@ set(simulation_HDRS
widgets/virtualjoystickwidget.h
)
if(SDL_FOUND)
if(SDL2_FOUND)
set(simulation_SRCS
${simulation_SRCS}
joystick.cpp
+7 -1
View File
@@ -26,7 +26,13 @@ Joystick::Joystick(QObject *parent, int joystickEventTimeout, bool doAutoRepeat,
if ( SDL_WasInit(SDL_INIT_JOYSTICK) ) {
int i;
for (i = 0; i < SDL_NumJoysticks(); i++)
joystickNames.append(SDL_JoystickName(i));
{
SDL_Joystick* joy = SDL_JoystickOpen(i);
if(joy == nullptr)
continue;
joystickNames.append(SDL_JoystickName(joy));
SDL_JoystickClose(joy);
}
connect(&joystickTimer, SIGNAL(timeout()), this, SLOT(processEvents()));
} else {
fprintf(stderr, "ERROR: couldn't initialize SDL joystick support\n");
+3
View File
@@ -270,6 +270,9 @@ int main(int argc, char *argv[])
#ifdef SIMU_AUDIO
sdlFlags |= SDL_INIT_AUDIO;
#endif
#if defined(_WIN32) || defined(_WIN64)
putenv("SDL_AUDIODRIVER=directsound");
#endif
if (SDL_Init(sdlFlags) < 0) {
showMessage(QApplication::translate("SimulatorMain", "WARNING: couldn't initialize SDL:\n%1").arg(SDL_GetError()), QMessageBox::Warning);
}