chore: cleanup SDL2 definitions (#6467)
This commit is contained in:
+1
-1
@@ -142,7 +142,7 @@ if(NATIVE_BUILD)
|
|||||||
include(NativeTargets)
|
include(NativeTargets)
|
||||||
else()
|
else()
|
||||||
# Prevent CMake warnings
|
# Prevent CMake warnings
|
||||||
set(IGNORE "${SDL2_LIBRARY_PATH}" "${LIBUSB1_ROOT_DIR}" "${OPENSSL_ROOT_DIR}")
|
set(IGNORE "${LIBUSB1_ROOT_DIR}" "${OPENSSL_ROOT_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(${RADIO_SRC_DIR})
|
add_subdirectory(${RADIO_SRC_DIR})
|
||||||
|
|||||||
@@ -24,3 +24,5 @@ target_include_directories(imgui PUBLIC
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/imgui
|
${CMAKE_CURRENT_BINARY_DIR}/imgui
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/imgui/backends
|
${CMAKE_CURRENT_BINARY_DIR}/imgui/backends
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(imgui PUBLIC SDL2::SDL2)
|
||||||
|
|||||||
@@ -5,21 +5,9 @@ if(NOT DISABLE_COMPANION)
|
|||||||
include(QtDefs)
|
include(QtDefs)
|
||||||
endif(NOT DISABLE_COMPANION)
|
endif(NOT DISABLE_COMPANION)
|
||||||
|
|
||||||
# this prevents FindSDL from appending SDLmain lib to the results, which we don't want
|
find_package(SDL2 QUIET COMPONENTS SDL2 CONFIG)
|
||||||
set(SDL2_BUILDING_LIBRARY YES)
|
if(TARGET SDL2::SDL2)
|
||||||
find_package("SDL2")
|
message(STATUS "SDL2 found")
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
|
||||||
# find_package("SDL2") does not set a variable holding the path to the location of the SDL2 shared library
|
|
||||||
find_file(SDL2_LIB_PATH
|
|
||||||
NAMES
|
|
||||||
libSDL2.so
|
|
||||||
SDL2.dll
|
|
||||||
SDL2.dylib
|
|
||||||
HINTS
|
|
||||||
"/usr/lib/x86_64-linux-gnu"
|
|
||||||
${SDL2_LIBRARY_PATH})
|
|
||||||
message(STATUS "SDL2 Lib: ${SDL2_LIB_PATH} Libs: ${SDL2_LIBRARIES}; Headers: ${SDL2_INCLUDE_DIRS}")
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "SDL not found! Simulator audio, and joystick inputs, will not work.")
|
message(STATUS "SDL not found! Simulator audio, and joystick inputs, will not work.")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -44,12 +44,9 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
if(TARGET SDL2::SDL2)
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
add_definitions(-DUSE_SDL)
|
||||||
add_definitions(-DJOYSTICKS -DSIMU_AUDIO)
|
set(SDL2_LIBRARIES SDL2::SDL2)
|
||||||
if(TARGET SDL2::SDL2)
|
|
||||||
set(SDL2_LIBRARIES SDL2::SDL2)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(${APP_COMMON_DEFINES}) # set in top-level CMakeLists
|
add_definitions(${APP_COMMON_DEFINES}) # set in top-level CMakeLists
|
||||||
@@ -267,10 +264,21 @@ if(WIN32)
|
|||||||
set(icon_RC images/winicons/icon.rc)
|
set(icon_RC images/winicons/icon.rc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${COMPANION_NAME}
|
add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE}
|
||||||
MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS} ${companion_HDRS} ${icon_RC})
|
${companion_SRCS}
|
||||||
target_link_libraries(${COMPANION_NAME}
|
${companion_HDRS}
|
||||||
PRIVATE ${CPN_COMMON_LIB} generaledit modeledit qcustomplot miniz updates)
|
${icon_RC}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${COMPANION_NAME} PRIVATE
|
||||||
|
${CPN_COMMON_LIB}
|
||||||
|
${SDL2_LIBRARIES}
|
||||||
|
generaledit
|
||||||
|
modeledit
|
||||||
|
qcustomplot
|
||||||
|
miniz
|
||||||
|
updates
|
||||||
|
)
|
||||||
|
|
||||||
PrintTargetReport("${COMPANION_NAME}")
|
PrintTargetReport("${COMPANION_NAME}")
|
||||||
|
|
||||||
@@ -278,10 +286,15 @@ PrintTargetReport("${COMPANION_NAME}")
|
|||||||
|
|
||||||
set(simu_SRCS simulator.cpp )
|
set(simu_SRCS simulator.cpp )
|
||||||
|
|
||||||
add_executable(${SIMULATOR_NAME}
|
add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE}
|
||||||
MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${simu_SRCS} ${icon_RC})
|
${simu_SRCS}
|
||||||
target_link_libraries(${SIMULATOR_NAME}
|
${icon_RC}
|
||||||
PRIVATE ${CPN_COMMON_LIB})
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${SIMULATOR_NAME} PRIVATE
|
||||||
|
${CPN_COMMON_LIB}
|
||||||
|
${SDL2_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
||||||
@@ -450,10 +463,14 @@ elseif(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
endif(OPENSSL_FOUND)
|
endif(OPENSSL_FOUND)
|
||||||
|
|
||||||
if(SDL2_FOUND AND DEFINED SDL2_LIB_PATH)
|
if(TARGET SDL2::SDL2)
|
||||||
install(FILES "${SDL2_LIB_PATH}"
|
# Get the SDL2 DLL location
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
|
get_target_property(SDL2_DLL_PATH SDL2::SDL2 IMPORTED_LOCATION)
|
||||||
COMPONENT Runtime)
|
if(SDL2_DLL_PATH)
|
||||||
|
install(FILES "${SDL2_DLL_PATH}"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
|
||||||
|
COMPONENT Runtime)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#if defined(JOYSTICKS)
|
#if defined(USE_SDL)
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
#include "joystickdialog.h"
|
#include "joystickdialog.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -57,7 +57,7 @@ AppPreferencesDialog::AppPreferencesDialog(QWidget * parent, UpdateFactories * f
|
|||||||
connect(ui->opt_appDebugLog, &QCheckBox::toggled, this, &AppPreferencesDialog::toggleAppLogSettings);
|
connect(ui->opt_appDebugLog, &QCheckBox::toggled, this, &AppPreferencesDialog::toggleAppLogSettings);
|
||||||
connect(ui->opt_fwTraceLog, &QCheckBox::toggled, this, &AppPreferencesDialog::toggleAppLogSettings);
|
connect(ui->opt_fwTraceLog, &QCheckBox::toggled, this, &AppPreferencesDialog::toggleAppLogSettings);
|
||||||
|
|
||||||
#if !defined(JOYSTICKS)
|
#if !defined(USE_SDL)
|
||||||
ui->joystickCB->hide();
|
ui->joystickCB->hide();
|
||||||
ui->joystickCB->setDisabled(true);
|
ui->joystickCB->setDisabled(true);
|
||||||
ui->joystickcalButton->hide();
|
ui->joystickcalButton->hide();
|
||||||
@@ -296,7 +296,7 @@ void AppPreferencesDialog::initSettings()
|
|||||||
ui->chkSimuScrollButtons->setChecked(g.simuScrollButtons());
|
ui->chkSimuScrollButtons->setChecked(g.simuScrollButtons());
|
||||||
ui->joystickWarningCB->setChecked(g.disableJoystickWarning());
|
ui->joystickWarningCB->setChecked(g.disableJoystickWarning());
|
||||||
|
|
||||||
#if defined(JOYSTICKS)
|
#if defined(USE_SDL)
|
||||||
ui->joystickChkB->setChecked(g.jsSupport());
|
ui->joystickChkB->setChecked(g.jsSupport());
|
||||||
if (ui->joystickChkB->isChecked()) {
|
if (ui->joystickChkB->isChecked()) {
|
||||||
QStringList joystickNames;
|
QStringList joystickNames;
|
||||||
@@ -627,7 +627,7 @@ void AppPreferencesDialog::on_btnClearPos_clicked()
|
|||||||
g.profile[g.sessionId()].simulatorOptions(opts);
|
g.profile[g.sessionId()].simulatorOptions(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(JOYSTICKS)
|
#if defined(USE_SDL)
|
||||||
void AppPreferencesDialog::on_joystickChkB_clicked() {
|
void AppPreferencesDialog::on_joystickChkB_clicked() {
|
||||||
if (ui->joystickChkB->isChecked()) {
|
if (ui->joystickChkB->isChecked()) {
|
||||||
QStringList joystickNames;
|
QStringList joystickNames;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class AppPreferencesDialog : public QDialog
|
|||||||
void on_btn_appLogsDir_clicked();
|
void on_btn_appLogsDir_clicked();
|
||||||
void on_btnClearPos_clicked();
|
void on_btnClearPos_clicked();
|
||||||
|
|
||||||
#if defined(JOYSTICKS)
|
#if defined(USE_SDL)
|
||||||
void on_joystickChkB_clicked();
|
void on_joystickChkB_clicked();
|
||||||
void on_joystickcalButton_clicked();
|
void on_joystickcalButton_clicked();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,7 +25,8 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
|
||||||
|
#if defined(USE_SDL)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#undef main
|
#undef main
|
||||||
#endif
|
#endif
|
||||||
@@ -216,18 +217,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Translations::installTranslators();
|
Translations::installTranslators();
|
||||||
|
|
||||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
#if defined(USE_SDL)
|
||||||
uint32_t sdlFlags = 0;
|
|
||||||
#ifdef JOYSTICKS
|
|
||||||
sdlFlags |= SDL_INIT_JOYSTICK;
|
|
||||||
#endif
|
|
||||||
#ifdef SIMU_AUDIO
|
|
||||||
sdlFlags |= SDL_INIT_AUDIO;
|
|
||||||
#endif
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
putenv("SDL_AUDIODRIVER=directsound");
|
putenv("SDL_AUDIODRIVER=directsound");
|
||||||
#endif
|
#endif
|
||||||
if (SDL_Init(sdlFlags) < 0) {
|
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0) {
|
||||||
fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
|
fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -269,7 +263,7 @@ int main(int argc, char *argv[])
|
|||||||
unregisterStorageFactories();
|
unregisterStorageFactories();
|
||||||
gBoardFactories->unregisterBoardFactories();
|
gBoardFactories->unregisterBoardFactories();
|
||||||
|
|
||||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
#if defined(USE_SDL)
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,8 @@ set(${PROJECT_NAME}_NAMES
|
|||||||
simulateduiwidgetGeneric
|
simulateduiwidgetGeneric
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
if(TARGET SDL2::SDL2)
|
||||||
set(${PROJECT_NAME}_NAMES
|
list(APPEND ${PROJECT_NAME}_NAMES
|
||||||
${${PROJECT_NAME}_NAMES}
|
|
||||||
joystick
|
joystick
|
||||||
joystickdialog
|
joystickdialog
|
||||||
)
|
)
|
||||||
@@ -61,6 +60,10 @@ target_link_libraries(${PROJECT_NAME}
|
|||||||
Qt::Svg
|
Qt::Svg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(TARGET SDL2::SDL2)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME}
|
target_include_directories(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${CMAKE_SOURCE_DIR}"
|
"${CMAKE_SOURCE_DIR}"
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "simulatorinterface.h"
|
#include "simulatorinterface.h"
|
||||||
#include "telemetrysimu.h"
|
#include "telemetrysimu.h"
|
||||||
#include "trainersimu.h"
|
#include "trainersimu.h"
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
#include "joystickdialog.h"
|
#include "joystickdialog.h"
|
||||||
#endif
|
#endif
|
||||||
#include "serialportsdialog.h"
|
#include "serialportsdialog.h"
|
||||||
@@ -128,7 +128,7 @@ SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & simula
|
|||||||
ui->actionReloadLua->setDisabled(true);
|
ui->actionReloadLua->setDisabled(true);
|
||||||
if(!m_simulator->getCapability(SimulatorInterface::CAP_TELEM_FRSKY_SPORT))
|
if(!m_simulator->getCapability(SimulatorInterface::CAP_TELEM_FRSKY_SPORT))
|
||||||
m_telemetryDockWidget->toggleViewAction()->setDisabled(true);
|
m_telemetryDockWidget->toggleViewAction()->setDisabled(true);
|
||||||
#ifndef JOYSTICKS
|
#ifndef USE_SDL
|
||||||
ui->actionJoystickSettings->setDisabled(true);
|
ui->actionJoystickSettings->setDisabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ void SimulatorMainWindow::toggleRadioDocked(bool dock)
|
|||||||
|
|
||||||
void SimulatorMainWindow::openJoystickDialog(bool)
|
void SimulatorMainWindow::openJoystickDialog(bool)
|
||||||
{
|
{
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
joystickDialog * jd = new joystickDialog(this);
|
joystickDialog * jd = new joystickDialog(this);
|
||||||
if (jd->exec() == QDialog::Accepted && m_simulatorWidget)
|
if (jd->exec() == QDialog::Accepted && m_simulatorWidget)
|
||||||
m_simulatorWidget->setupJoysticks();
|
m_simulatorWidget->setupJoysticks();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#include "simulateduiwidget.h"
|
#include "simulateduiwidget.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "virtualjoystickwidget.h"
|
#include "virtualjoystickwidget.h"
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
#include "joystickdialog.h"
|
#include "joystickdialog.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -126,7 +126,7 @@ SimulatorWidget::~SimulatorWidget()
|
|||||||
delete radioUiWidget;
|
delete radioUiWidget;
|
||||||
delete vJoyLeft;
|
delete vJoyLeft;
|
||||||
delete vJoyRight;
|
delete vJoyRight;
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
delete joystick;
|
delete joystick;
|
||||||
#endif
|
#endif
|
||||||
firmware = nullptr;
|
firmware = nullptr;
|
||||||
@@ -607,7 +607,7 @@ void SimulatorWidget::setupRadioWidgets()
|
|||||||
|
|
||||||
void SimulatorWidget::setupJoysticks()
|
void SimulatorWidget::setupJoysticks()
|
||||||
{
|
{
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
bool joysticksEnabled = false;
|
bool joysticksEnabled = false;
|
||||||
|
|
||||||
if (g.jsSupport()) {
|
if (g.jsSupport()) {
|
||||||
@@ -806,7 +806,7 @@ void SimulatorWidget::onRadioWidgetValueChange(const RadioWidget::RadioWidgetTyp
|
|||||||
|
|
||||||
void SimulatorWidget::onjoystickAxisValueChanged(int axis, int value)
|
void SimulatorWidget::onjoystickAxisValueChanged(int axis, int value)
|
||||||
{
|
{
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
static const int ttlSticks = 4;
|
static const int ttlSticks = 4;
|
||||||
const int ttlKnobs = Boards::getCapability(m_board, Board::Pots);
|
const int ttlKnobs = Boards::getCapability(m_board, Board::Pots);
|
||||||
const int ttlFaders = Boards::getCapability(m_board, Board::Sliders);
|
const int ttlFaders = Boards::getCapability(m_board, Board::Sliders);
|
||||||
@@ -855,7 +855,7 @@ void SimulatorWidget::onjoystickAxisValueChanged(int axis, int value)
|
|||||||
|
|
||||||
void SimulatorWidget::onjoystickButtonValueChanged(int button, bool state)
|
void SimulatorWidget::onjoystickButtonValueChanged(int button, bool state)
|
||||||
{
|
{
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
|
|
||||||
if (!joystick || button >= MAX_JS_BUTTONS)
|
if (!joystick || button >= MAX_JS_BUTTONS)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Firmware;
|
|||||||
class SimulatorInterface;
|
class SimulatorInterface;
|
||||||
class SimulatedUIWidget;
|
class SimulatedUIWidget;
|
||||||
class VirtualJoystickWidget;
|
class VirtualJoystickWidget;
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
class Joystick;
|
class Joystick;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class SimulatorWidget : public QWidget
|
|||||||
bool deleteTempRadioData = false;
|
bool deleteTempRadioData = false;
|
||||||
bool saveTempRadioData = false;
|
bool saveTempRadioData = false;
|
||||||
|
|
||||||
#ifdef JOYSTICKS
|
#ifdef USE_SDL
|
||||||
Joystick * joystick = nullptr;
|
Joystick * joystick = nullptr;
|
||||||
int switchDirection[MAX_JS_BUTTONS];
|
int switchDirection[MAX_JS_BUTTONS];
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
|
||||||
|
#if defined(USE_SDL)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#undef main
|
#undef main
|
||||||
#endif
|
#endif
|
||||||
@@ -278,18 +279,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Translations::installTranslators();
|
Translations::installTranslators();
|
||||||
|
|
||||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
#if defined(USE_SDL)
|
||||||
uint32_t sdlFlags = 0;
|
|
||||||
#ifdef JOYSTICKS
|
|
||||||
sdlFlags |= SDL_INIT_JOYSTICK;
|
|
||||||
#endif
|
|
||||||
#ifdef SIMU_AUDIO
|
|
||||||
sdlFlags |= SDL_INIT_AUDIO;
|
|
||||||
#endif
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
putenv("SDL_AUDIODRIVER=directsound");
|
putenv("SDL_AUDIODRIVER=directsound");
|
||||||
#endif
|
#endif
|
||||||
if (SDL_Init(sdlFlags) < 0) {
|
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0) {
|
||||||
showMessage(QApplication::translate("SimulatorMain", "WARNING: couldn't initialize SDL:\n%1").arg(SDL_GetError()), QMessageBox::Warning);
|
showMessage(QApplication::translate("SimulatorMain", "WARNING: couldn't initialize SDL:\n%1").arg(SDL_GetError()), QMessageBox::Warning);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -403,7 +397,7 @@ int finish(int exitCode)
|
|||||||
unregisterStorageFactories();
|
unregisterStorageFactories();
|
||||||
gBoardFactories->unregisterBoardFactories();
|
gBoardFactories->unregisterBoardFactories();
|
||||||
|
|
||||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
#if defined(USE_SDL)
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -706,11 +706,6 @@ bool AudioQueue::isPlaying(uint8_t id)
|
|||||||
|
|
||||||
void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t flags, int8_t freqIncr, int8_t fragmentVolume)
|
void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t flags, int8_t freqIncr, int8_t fragmentVolume)
|
||||||
{
|
{
|
||||||
#if defined(SIMU) && !defined(SIMU_AUDIO)
|
|
||||||
#warning "NO audio"
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_audio_lock();
|
_audio_lock();
|
||||||
|
|
||||||
freq = limit<uint16_t>(BEEP_MIN_FREQ, freq, BEEP_MAX_FREQ);
|
freq = limit<uint16_t>(BEEP_MIN_FREQ, freq, BEEP_MAX_FREQ);
|
||||||
@@ -772,14 +767,6 @@ void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id, int8
|
|||||||
|
|
||||||
void AudioQueue::stopPlay(uint8_t id)
|
void AudioQueue::stopPlay(uint8_t id)
|
||||||
{
|
{
|
||||||
#if defined(SIMU)
|
|
||||||
TRACE("stopPlay(id=%d)", id);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SIMU) && !defined(SIMU_AUDIO)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_audio_lock();
|
_audio_lock();
|
||||||
|
|
||||||
fragmentsFifo.removePromptById(id);
|
fragmentsFifo.removePromptById(id);
|
||||||
|
|||||||
+1
-4
@@ -88,7 +88,7 @@ constexpr uint8_t AUDIO_FILENAME_MAXLEN = (AUDIO_LUA_FILENAME_MAXLEN > AUDIO_MOD
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SIMU) && defined(SIMU_AUDIO)
|
#if defined(SIMU)
|
||||||
#define AUDIO_BUFFER_COUNT (10) // simulator needs more buffers for smooth audio
|
#define AUDIO_BUFFER_COUNT (10) // simulator needs more buffers for smooth audio
|
||||||
#elif defined(AUDIO_SPI)
|
#elif defined(AUDIO_SPI)
|
||||||
#define AUDIO_BUFFER_COUNT (2) // smaller than Taranis since there is also a buffer on the ADC chip
|
#define AUDIO_BUFFER_COUNT (2) // smaller than Taranis since there is also a buffer on the ADC chip
|
||||||
@@ -421,9 +421,6 @@ class AudioFragmentFifo
|
|||||||
|
|
||||||
class AudioQueue {
|
class AudioQueue {
|
||||||
|
|
||||||
#if defined(SIMU_AUDIO)
|
|
||||||
friend void fillAudioBuffer(void *, uint8_t *, int);
|
|
||||||
#endif
|
|
||||||
#if defined(CLI)
|
#if defined(CLI)
|
||||||
friend void printAudioVars();
|
friend void printAudioVars();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ set(SIMU_DRIVERS ${SIMU_DRIVERS}
|
|||||||
)
|
)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
|
||||||
target_compile_options(radiolib_native PUBLIC -DSIMU_AUDIO)
|
|
||||||
if(TARGET SDL2::SDL2)
|
|
||||||
set(SDL2_LIBRARIES SDL2::SDL2)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SIMU_LUA_COMPILER)
|
if(SIMU_LUA_COMPILER)
|
||||||
add_definitions(-DLUA_COMPILER)
|
add_definitions(-DLUA_COMPILER)
|
||||||
endif()
|
endif()
|
||||||
@@ -99,7 +91,9 @@ if(Qt6Widgets_FOUND)
|
|||||||
list(APPEND SIMULATOR_SRC ${SIMU_SRC} opentxsimulator.cpp)
|
list(APPEND SIMULATOR_SRC ${SIMU_SRC} opentxsimulator.cpp)
|
||||||
|
|
||||||
add_library(${SIMULATOR_TARGET} SHARED ${SIMULATOR_SRC})
|
add_library(${SIMULATOR_TARGET} SHARED ${SIMULATOR_SRC})
|
||||||
if(SDL2_FOUND)
|
|
||||||
|
if(TARGET SDL2::SDL2)
|
||||||
|
set(SDL2_LIBRARIES SDL2::SDL2)
|
||||||
target_sources(${SIMULATOR_TARGET} PRIVATE simuaudio.cpp)
|
target_sources(${SIMULATOR_TARGET} PRIVATE simuaudio.cpp)
|
||||||
else()
|
else()
|
||||||
target_sources(${SIMULATOR_TARGET} PRIVATE no_audio.cpp)
|
target_sources(${SIMULATOR_TARGET} PRIVATE no_audio.cpp)
|
||||||
@@ -170,28 +164,26 @@ endif()
|
|||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
|
||||||
|
|
||||||
add_executable(simu
|
if(TARGET SDL2:SDL2)
|
||||||
EXCLUDE_FROM_ALL
|
add_executable(simu
|
||||||
${SIMU_SRC}
|
EXCLUDE_FROM_ALL
|
||||||
simuaudio.cpp
|
${SIMU_SRC}
|
||||||
display.cpp
|
simuaudio.cpp
|
||||||
widgets.cpp
|
display.cpp
|
||||||
knobs.cpp
|
widgets.cpp
|
||||||
sdl_simu.cpp
|
knobs.cpp
|
||||||
)
|
sdl_simu.cpp
|
||||||
|
)
|
||||||
|
|
||||||
include(FetchImgui)
|
include(FetchImgui)
|
||||||
target_compile_options(simu PUBLIC -DSIMU)
|
target_compile_options(simu PUBLIC -DSIMU)
|
||||||
|
|
||||||
add_png_target(image_assets "assets/images/*.png")
|
add_png_target(image_assets "assets/images/*.png")
|
||||||
add_dependencies(simu image_assets)
|
add_dependencies(simu image_assets)
|
||||||
|
|
||||||
set(STB_DIR ${RADIO_SRC_DIR}/thirdparty/stb)
|
set(STB_DIR ${RADIO_SRC_DIR}/thirdparty/stb)
|
||||||
target_include_directories(simu PUBLIC ${STB_DIR})
|
target_include_directories(simu PUBLIC ${STB_DIR})
|
||||||
target_link_libraries(simu PUBLIC imgui)
|
target_link_libraries(simu PUBLIC imgui)
|
||||||
|
endif()
|
||||||
target_link_libraries(simu PUBLIC
|
|
||||||
${SDL2_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
PrintTargetReport("simu/libsimulator")
|
PrintTargetReport("simu/libsimulator")
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#define SIMU_AUDIO_FMT AUDIO_S16SYS
|
#define AUDIO_FMT AUDIO_S16SYS
|
||||||
|
|
||||||
static SDL_AudioDeviceID _sdl_audio_device = 0;
|
static SDL_AudioDeviceID _sdl_audio_device = 0;
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ void simuQueueAudio(const uint8_t* data, uint32_t len)
|
|||||||
{
|
{
|
||||||
#if !defined(SOFTWARE_VOLUME)
|
#if !defined(SOFTWARE_VOLUME)
|
||||||
int volume = (simuAudioGetVolume() * SDL_MIX_MAXVOLUME ) / VOLUME_LEVEL_MAX;
|
int volume = (simuAudioGetVolume() * SDL_MIX_MAXVOLUME ) / VOLUME_LEVEL_MAX;
|
||||||
SDL_MixAudioFormat((uint8_t*)data, data, SIMU_AUDIO_FMT, len, volume);
|
SDL_MixAudioFormat((uint8_t*)data, data, AUDIO_FMT, len, volume);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_QueueAudio(_sdl_audio_device, data, len);
|
SDL_QueueAudio(_sdl_audio_device, data, len);
|
||||||
@@ -43,7 +43,7 @@ bool simuAudioInit()
|
|||||||
{
|
{
|
||||||
SDL_AudioSpec wanted = {
|
SDL_AudioSpec wanted = {
|
||||||
.freq = AUDIO_SAMPLE_RATE,
|
.freq = AUDIO_SAMPLE_RATE,
|
||||||
.format = SIMU_AUDIO_FMT,
|
.format = AUDIO_FMT,
|
||||||
.channels = 1,
|
.channels = 1,
|
||||||
.silence = 0,
|
.silence = 0,
|
||||||
.samples = 1024,
|
.samples = 1024,
|
||||||
|
|||||||
@@ -25,12 +25,6 @@ fi
|
|||||||
COMMON_OPTIONS="${COMMON_OPTIONS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_MESSAGE_LOG_LEVEL=WARNING -Wno-dev -DGVARS=YES -DHELI=YES -DLUA=YES"
|
COMMON_OPTIONS="${COMMON_OPTIONS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_MESSAGE_LOG_LEVEL=WARNING -Wno-dev -DGVARS=YES -DHELI=YES -DLUA=YES"
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
COMMON_OPTIONS="${COMMON_OPTIONS} -DCMAKE_OSX_DEPLOYMENT_TARGET='10.15'"
|
COMMON_OPTIONS="${COMMON_OPTIONS} -DCMAKE_OSX_DEPLOYMENT_TARGET='10.15'"
|
||||||
elif [ "$(uname)" != "Linux" ]; then # Assume Windows and MSYS2
|
|
||||||
if [ "${MSYSTEM,,}" == "mingw32" ]; then # MSYS 32bit detected
|
|
||||||
COMMON_OPTIONS="${COMMON_OPTIONS} -DSDL2_LIBRARY_PATH=/mingw32/bin/"
|
|
||||||
else # fallback to 64bit
|
|
||||||
COMMON_OPTIONS="${COMMON_OPTIONS} -DSDL2_LIBRARY_PATH=/mingw64/bin/"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate EDGETX_VERSION_SUFFIX if not already set
|
# Generate EDGETX_VERSION_SUFFIX if not already set
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=== Step $((STEP++)): Running CMake for ${RADIO_TYPE} as an example ==="
|
echo "=== Step $((STEP++)): Running CMake for ${RADIO_TYPE} as an example ==="
|
||||||
cmake -G "MSYS Makefiles" -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/6.9.0/mingw_64 -DSDL2_LIBRARY_PATH=/mingw64/bin/ ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release ../
|
cmake -G "MSYS Makefiles" -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/6.9.0/mingw_64 ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release ../
|
||||||
check_command $? "cmake -G MSYS Makefiles -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/6.9.0/mingw_64 -DSDL2_LIBRARY_PATH=/mingw64/bin/ ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release ../"
|
check_command $? "cmake -G MSYS Makefiles -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/6.9.0/mingw_64 -DSDL2_LIBRARY_PATH=/mingw64/bin/ ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release ../"
|
||||||
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
|
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
|
||||||
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
|
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
|
||||||
|
|||||||
Reference in New Issue
Block a user