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
+1 -1
View File
@@ -32,7 +32,7 @@ option(SEMIHOSTING "Enable debugger semihosting" OFF)
option(JITTER_MEASURE "Enable ADC jitter measurement" OFF)
option(WATCHDOG "Enable hardware Watchdog" ON)
option(ASTERISK "Enable asterisk icon (test only firmware)" OFF)
if(SDL_FOUND)
if(SDL2_FOUND)
option(SIMU_AUDIO "Enable simulator audio." ON)
endif()
option(LUA "Enable LUA support" ON)
+1 -1
View File
@@ -22,9 +22,9 @@
#pragma once
#include <stdlib.h>
#include "debounce.h"
#include "definitions.h"
#include "opentx_types.h"
#include "debounce.h"
#include "opentx_helpers.h"
#include "touch.h"
+9 -6
View File
@@ -19,6 +19,11 @@
* GNU General Public License for more details.
*/
#if defined(SIMU_AUDIO)
#include <SDL.h>
#undef main
#endif
#include "fx.h"
#include "FXExpression.h"
#include "FXPNGImage.h"
@@ -29,11 +34,6 @@
#include <ctype.h>
#include "targets/simu/simulcd.h"
#if defined(SIMU_AUDIO)
#include <SDL.h>
#undef main
#endif
#if LCD_W > 212
#define LCD_ZOOM 1
#else
@@ -94,11 +94,14 @@ FXDEFMAP(OpenTxSim) OpenTxSimMap[] = {
FXIMPLEMENT(OpenTxSim, FXMainWindow, OpenTxSimMap, ARRAYNUMBER(OpenTxSimMap))
OpenTxSim::OpenTxSim(FXApp* a):
FXMainWindow(a, "OpenTX Simu", nullptr, nullptr, DECOR_ALL, 20, 90, 0, 0)
FXMainWindow(a, "EdgeTX Simu", nullptr, nullptr, DECOR_ALL, 20, 90, 0, 0)
{
bmp = new FXPPMImage(getApp(), nullptr, IMAGE_OWNED|IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP, W2, H2);
#if defined(SIMU_AUDIO)
#if defined(_WIN32) || defined(_WIN64)
putenv("SDL_AUDIODRIVER=directsound");
#endif
SDL_Init(SDL_INIT_AUDIO);
#endif
+7 -4
View File
@@ -19,9 +19,12 @@ set(SIMU_DRIVERS
)
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()
if(SIMU_LUA_COMPILER)
@@ -76,7 +79,7 @@ if(Qt5Widgets_FOUND)
target_compile_options(${SIMULATOR_TARGET} PRIVATE ${SIMU_SRC_OPTIONS})
target_compile_definitions(${SIMULATOR_TARGET} PUBLIC ${APP_COMMON_DEFINES})
target_link_libraries(${SIMULATOR_TARGET} ${SDL_LIBRARY} Qt5::Core)
target_link_libraries(${SIMULATOR_TARGET} ${SDL2_LIBRARIES} Qt5::Core)
# Remove debug symbols on release builds
if(NOT CLANG)
@@ -162,7 +165,7 @@ if(FOX_FOUND)
${RADIO_SRC_DIR}/simu.cpp)
target_include_directories(simu PUBLIC ${FOX_INCLUDE_DIR} )
target_link_libraries(simu ${FOX_LIBRARY} pthread ${SDL_LIBRARY})
target_link_libraries(simu ${FOX_LIBRARY} pthread ${SDL2_LIBRARIES})
target_compile_options(simu PRIVATE -DSIMU)
endif()
+4 -4
View File
@@ -21,6 +21,10 @@
#define SIMPGMSPC_USE_QT 0
#if defined(SIMU_AUDIO)
#include <SDL.h>
#endif
#include "opentx.h"
#include "simulcd.h"
@@ -33,10 +37,6 @@
#include <sys/time.h>
#endif
#if defined(SIMU_AUDIO)
#include <SDL.h>
#endif
int g_snapshot_idx = 0;
uint8_t simu_start_mode = 0;
+3 -3
View File
@@ -34,9 +34,9 @@ if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
target_link_libraries(gtests-radio-lib PRIVATE ${WIN_LINK_LIBRARIES})
endif(WIN32)
if(SDL_FOUND AND SIMU_AUDIO)
target_include_directories(gtests-radio-lib PUBLIC ${SDL_INCLUDE_DIR})
target_link_libraries(gtests-radio-lib PRIVATE ${SDL_LIBRARY})
if(SDL2_FOUND)
target_include_directories(gtests-radio-lib PUBLIC ${SDL2_INCLUDE_DIR})
target_link_libraries(gtests-radio-lib PRIVATE ${SDL2_LIBRARIES})
endif()