diff --git a/CI/build-ubuntu.sh b/CI/build-ubuntu.sh index 498840ef..b12731bb 100755 --- a/CI/build-ubuntu.sh +++ b/CI/build-ubuntu.sh @@ -2,5 +2,5 @@ set -ex mkdir build && cd build -cmake -DCMAKE_INSTALL_PREFIX=/usr -DUSE_UBUNTU_FIX=true .. +cmake -DisAzure=true -DCMAKE_INSTALL_PREFIX=/usr -DUSE_UBUNTU_FIX=true .. make -j4 diff --git a/CI/install-dependencies-macos.sh b/CI/install-dependencies-macos.sh index 6ce0b2c8..f8313a4e 100755 --- a/CI/install-dependencies-macos.sh +++ b/CI/install-dependencies-macos.sh @@ -8,20 +8,7 @@ if [ "${OSTYPE}" != "Darwin" ]; then echo "[obs-midi - Error] macOS install dependencies script can be run on Darwin-type OS only." exit 1 fi -HAS_PORT=$(type port 2>/dev/null) -if [ "${HAS_PORT}" = "" ]; then - echo "[obs-midi - Error] Mac Ports not installed, Building and installing macports" - curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.6.2.tar.bz2 - tar xf MacPorts-2.6.2.tar.bz2 - cd MacPorts-2.6.2/ - ./configure - make - sudo make install - export PATH=/usr/local/git/bin:/usr/local/bin:$PATH -fi -sudo port -v selfupdate -sudo port install jack HAS_BREW=$(type brew 2>/dev/null) if [ "${HAS_BREW}" = "" ]; then diff --git a/CI/prepare-obs-windows.cmd b/CI/prepare-obs-windows.cmd index 961fbe17..2fba5db1 100755 --- a/CI/prepare-obs-windows.cmd +++ b/CI/prepare-obs-windows.cmd @@ -34,4 +34,4 @@ cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QT echo: echo: -dir "%OBSPath%\libobs" \ No newline at end of file +dir "%OBSPath%\libobs" diff --git a/CI/prepare-windows.cmd b/CI/prepare-windows.cmd index 09057149..e748c149 100755 --- a/CI/prepare-windows.cmd +++ b/CI/prepare-windows.cmd @@ -2,6 +2,6 @@ mkdir build32 mkdir build64 cd build32 -cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR32%" -DLibObs_DIR="%OBSPath%\build32\libobs" -DLIBOBS_INCLUDE_DIR="%OBSPath%\libobs" -DLIBOBS_LIB="%OBSPath%\build32\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBSPath%\build32\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" .. +cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0 -DisAzure=true -DQTDIR="%QTDIR32%" -DLibObs_DIR="%OBSPath%\build32\libobs" -DLIBOBS_INCLUDE_DIR="%OBSPath%\libobs" -DLIBOBS_LIB="%OBSPath%\build32\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBSPath%\build32\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" .. cd ..\build64 -cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR64%" -DLibObs_DIR="%OBSPath%\build64\libobs" -DLIBOBS_INCLUDE_DIR="%OBSPath%\libobs" -DLIBOBS_LIB="%OBSPath%\build64\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBSPath%\build64\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" .. +cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DisAzure=true -DQTDIR="%QTDIR64%" -DLibObs_DIR="%OBSPath%\build64\libobs" -DLIBOBS_INCLUDE_DIR="%OBSPath%\libobs" -DLIBOBS_LIB="%OBSPath%\build64\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBSPath%\build64\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a7e4e14..20529ca6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,20 +42,24 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_definitions(-DASIO_STANDALONE) - -if (WIN32 OR APPLE) +if (${isAzure}) + if (WIN32 OR APPLE) + include(external/FindLibObs.cmake) + endif() + find_package(LibObs REQUIRED) +endif() +if (APPLE) include(external/FindLibObs.cmake) + find_package(LibObs REQUIRED) endif() -find_package(LibObs REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Widgets) include_directories( -"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api" - + "${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api" SYSTEM - ${Qt5Core_INCLUDES} - ${Qt5Widgets_INCLUDES} + ${Qt5Core_INCLUDES} + ${Qt5Widgets_INCLUDES} "${CMAKE_SOURCE_DIR}/UI") set(obs-midi_SOURCES @@ -89,113 +93,133 @@ add_library(obs-midi MODULE ${obs-midi_SOURCES} ${obs-midi_HEADERS}) -target_link_libraries(obs-midi - "${OBS_FRONTEND_LIB}" - ${obs-midi_DEPS} - Qt5::Core - Qt5::Widgets - libobs) - - - -# --- Windows-specific build settings and tasks --- -if(WIN32) - if(NOT DEFINED OBS_FRONTEND_LIB) - set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library") - message(FATAL_ERROR "Could not find OBS Frontend API's library !") - endif() - - if(MSVC) - # Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL) - add_definitions(/MP /d2FH4-) - endif() +if(WIN32 OR LINUX) + if (${isAzure}) - - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ARCH_NAME "64bit") - set(OBS_BUILDDIR_ARCH "build64") + target_link_libraries(obs-midi + "${OBS_FRONTEND_LIB}" + ${obs-midi_DEPS} + Qt5::Core + Qt5::Widgets + libobs) else() - set(ARCH_NAME "32bit") - set(OBS_BUILDDIR_ARCH "build32") - endif() + target_link_libraries(obs-midi + obs-frontend-api + ${obs-midi_DEPS} + Qt5::Core + Qt5::Widgets + libobs) + endif() +else() + target_link_libraries(obs-midi + "${OBS_FRONTEND_LIB}" + ${obs-midi_DEPS} + Qt5::Core + Qt5::Widgets + libobs) +endif() +if (${isAzure}) +# --- Windows-specific build settings and tasks --- + message(WARNING "IS AZURE") + if(WIN32) + if(NOT DEFINED OBS_FRONTEND_LIB) + set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library") + message(FATAL_ERROR "Could not find OBS Frontend API's library !") + endif() + + if(MSVC) + # Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL) + add_definitions(/MP /d2FH4-) + endif() + + + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ARCH_NAME "64bit") + set(OBS_BUILDDIR_ARCH "build64") + else() + set(ARCH_NAME "32bit") + set(OBS_BUILDDIR_ARCH "build32") + endif() + + include_directories( + "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/UI" + ) + + target_link_libraries(obs-midi + "${OBS_FRONTEND_LIB}") + + # --- Release package helper --- + # The "release" folder has a structure similar OBS' one on Windows + set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release") + add_custom_command(TARGET obs-midi POST_BUILD + # If config is Release, package release files + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E make_directory + "${RELEASE_DIR}/data/obs-plugins/obs-midi" + "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") + + COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy_directory + "${PROJECT_SOURCE_DIR}/data" + "${RELEASE_DIR}/data/obs-plugins/obs-midi") - include_directories( - "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/UI" - ) + COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy + "$" + "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") + + # In Release mode, copy Qt image format plugins + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E copy + "${QTDIR}/plugins/imageformats/qjpeg.dll" + "${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats/qjpeg.dll") + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E copy + "${QTDIR}/plugins/imageformats/qjpeg.dll" + "${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats/qjpeg.dll") + + # If config is RelWithDebInfo, package release files + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E make_directory + "${RELEASE_DIR}/data/obs-plugins/obs-midi" + "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") + + COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy_directory + "${PROJECT_SOURCE_DIR}/data" + "${RELEASE_DIR}/data/obs-plugins/obs-midi") - target_link_libraries(obs-midi - "${OBS_FRONTEND_LIB}") - - # --- Release package helper --- - # The "release" folder has a structure similar OBS' one on Windows - set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release") - add_custom_command(TARGET obs-midi POST_BUILD - # If config is Release, package release files - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E make_directory - "${RELEASE_DIR}/data/obs-plugins/obs-midi" - "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") - - COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy_directory - "${PROJECT_SOURCE_DIR}/data" - "${RELEASE_DIR}/data/obs-plugins/obs-midi") - - COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy - "$" - "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") - - # In Release mode, copy Qt image format plugins - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E copy - "${QTDIR}/plugins/imageformats/qjpeg.dll" - "${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats/qjpeg.dll") - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E copy - "${QTDIR}/plugins/imageformats/qjpeg.dll" - "${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats/qjpeg.dll") - - # If config is RelWithDebInfo, package release files - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E make_directory - "${RELEASE_DIR}/data/obs-plugins/obs-midi" - "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") - - COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy_directory - "${PROJECT_SOURCE_DIR}/data" - "${RELEASE_DIR}/data/obs-plugins/obs-midi") - - COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy - "$" - "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") - - COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy - "$" - "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") - - # Copy to obs-studio dev environment for immediate testing - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E copy + COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy "$" - "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/obs-plugins/${ARCH_NAME}") + "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E copy + COMMAND if $==1 ("${CMAKE_COMMAND}" -E copy "$" - "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/obs-plugins/${ARCH_NAME}") - - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E make_directory - "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/data/obs-plugins/obs-midi") - - COMMAND if $==1 ( - "${CMAKE_COMMAND}" -E copy_directory - "${PROJECT_SOURCE_DIR}/data" - "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/data/obs-plugins/obs-midi") - ) - # --- End of sub-section --- + "${RELEASE_DIR}/obs-plugins/${ARCH_NAME}") + + # Copy to obs-studio dev environment for immediate testing + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E copy + "$" + "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/obs-plugins/${ARCH_NAME}") + + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E copy + "$" + "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/obs-plugins/${ARCH_NAME}") + + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E make_directory + "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/data/obs-plugins/obs-midi") + + COMMAND if $==1 ( + "${CMAKE_COMMAND}" -E copy_directory + "${PROJECT_SOURCE_DIR}/data" + "${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$/data/obs-plugins/obs-midi") + ) + # --- End of sub-section --- + endif() + # --- End of section --- endif() -# --- End of section --- +# -- End of if AZURE # --- Linux-specific build settings and tasks --- if(UNIX AND NOT APPLE) @@ -221,7 +245,6 @@ endif() # -- OS X specific build settings and tasks -- if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default") - set(CMAKE_SKIP_RPATH TRUE) set_target_properties(obs-midi PROPERTIES PREFIX "") target_link_libraries(obs-midi "${OBS_FRONTEND_LIB}") diff --git a/README.md b/README.md index bbaa5eb1..f0173845 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,17 @@ Use MIDI devices to trigger events in OBS and visa versa. * Select your controller, hit configure, Toggle a button and fader, remap it to an action and hit save! + Currently runs on Windows and Linux, and is untested on MAC + # Build instructions In your obs-studio/plugins folder 1. ```git clone --recursive https://github.com/Alzy/obs-midi.git``` 2. Append to CMakeLists.txt * ```add_subdirectory(obs-midi)``` - Go back to your obs Build directory - ## windows + Go back to your OBS Build directory + ## Windows 1. run ```cmake-gui.exe``` 2. click ```configure``` 3. click ```generate``` diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 389c9404..23244882 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,6 +41,7 @@ jobs: QTDIR32: '$(QtBaseDir)\5.10.1\msvc2017' QTDIR64: '$(QtBaseDir)\5.10.1\msvc2017_64' OBSPath: 'D:\obs-studio' + isAzure: 'true' steps: - checkout: self submodules: true @@ -79,6 +80,7 @@ jobs: QTDIR32: $(QTDIR32) QTDIR64: $(QTDIR64) OBSPath: $(OBSPath) + isAzure: $(isAzure) - task: MSBuild@1 displayName: 'Build OBS Studio 32-bit' @@ -99,6 +101,7 @@ jobs: QTDIR32: $(QTDIR32) QTDIR64: $(QTDIR64) OBSPath: $(OBSPath) + isAzure: $(isAzure) - task: MSBuild@1 displayName: 'Build obs-midi 32-bit' @@ -128,6 +131,7 @@ jobs: BUILD_REASON: $(Build.Reason) BRANCH_SHORT_NAME: $(Build.SourceBranchName) BRANCH_FULL_NAME: $(Build.SourceBranch) + isAzure: true steps: - checkout: self submodules: true @@ -137,6 +141,8 @@ jobs: - script: ./CI/build-ubuntu.sh displayName: 'Build obs-midi' + env: + isAzure: $(isAzure) - script: ./CI/package-ubuntu.sh displayName: 'Package obs-midi' @@ -149,6 +155,8 @@ jobs: - job: 'Build_macOS' pool: vmImage: 'macos-10.14' + variables: + isAzure: true steps: - checkout: self submodules: true @@ -161,7 +169,8 @@ jobs: - script: ./CI/build-macos.sh displayName: 'Build obs-midi' - + env: + isAzure: $(isAzure) - script: ./CI/package-macos.sh displayName: 'Package obs-midi' env: diff --git a/src/config.cpp b/src/config.cpp index 5f05c8ba..5b8a0268 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -16,7 +16,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ +#if __has_include() + #include +#else +#include +#endif #include #include diff --git a/src/config.h b/src/config.h index 266cba71..528bccdc 100644 --- a/src/config.h +++ b/src/config.h @@ -18,7 +18,11 @@ with this program. If not, see #pragma once +#if __has_include() #include +#else +#include +#endif #include #include #include diff --git a/src/device-manager.h b/src/device-manager.h index 36e390d1..41c1f1d3 100644 --- a/src/device-manager.h +++ b/src/device-manager.h @@ -18,7 +18,12 @@ with this program. If not, see #pragma once +#if __has_include() #include +#else +#include +#endif + #include #include #include diff --git a/src/events.cpp b/src/events.cpp index 2adc8086..afb3d77b 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -20,11 +20,8 @@ #include #include #include - #include - #include "events.h" - #include "obs-midi.h" #include "config.h" #include "utils.h" diff --git a/src/events.h b/src/events.h index 77a1f722..4589d9f1 100644 --- a/src/events.h +++ b/src/events.h @@ -20,7 +20,11 @@ with this program. If not, see #pragma once #include +#if __has_include() #include +#else +#include +#endif #include #include "obs-midi.h" #include "device-manager.h" diff --git a/src/forms/configwindow.cpp b/src/forms/configwindow.cpp index 944d1cff..3eb158d9 100644 --- a/src/forms/configwindow.cpp +++ b/src/forms/configwindow.cpp @@ -5,7 +5,11 @@ #include "ui_configwindow.h" #include #include +#if __has_include() #include +#else +#include +#endif #include "../obs-midi.h" #include "../config.h" #include "../device-manager.h" @@ -406,6 +410,7 @@ void ConfigWindow::deleterow() } } catch (const std::exception &e) { + blog(1, "Delete Row Failure - %s", e.what()); return; } }; diff --git a/src/forms/settings-dialog.cpp b/src/forms/settings-dialog.cpp index 66c1c8f3..f52475d2 100644 --- a/src/forms/settings-dialog.cpp +++ b/src/forms/settings-dialog.cpp @@ -13,7 +13,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ +#if __has_include() #include +#else +#include +#endif #include #include #include @@ -77,7 +81,6 @@ void SettingsDialog::SetAvailableDevices() loadingdevices = false; auto midiDevices = GetDeviceManager()->GetPortsList(); - this->ui->list_midi_dev->clear(); this->ui->check_enabled->setEnabled(false); this->ui->btn_configure->setEnabled(false); @@ -97,16 +100,16 @@ void SettingsDialog::SetAvailableDevices() if (starting) { -# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) //define something for Windows (32-bit and 64-bit, this part is common) this->ui->outbox->setCurrentIndex(1); - #elif __linux__ +#elif __linux__ this->ui->outbox->setCurrentIndex(0); - // linux - #elif __unix__ // all unices not caught above +// linux +#elif __unix__ // all unices not caught above this->ui->outbox->setCurrentIndex(0); - // Unix - #endif +// Unix +#endif if (midiDevices.size() != 0) { desconnect = connect( ui->outbox, SIGNAL(currentTextChanged(QString)), @@ -148,23 +151,21 @@ int SettingsDialog::on_check_enabled_stateChanged(bool state) if (state == true) { - auto selectedDeviceName =ui->list_midi_dev->currentItem() - ->text() - .toStdString(); - auto selectedOutDeviceName =ui->outbox->currentText().toStdString(); + auto selectedDeviceName = + ui->list_midi_dev->currentItem()->text().toStdString(); + auto selectedOutDeviceName = + ui->outbox->currentText().toStdString(); auto device = GetDeviceManager()->GetMidiDeviceByName( selectedDeviceName.c_str()); - blog(LOG_INFO, "Item enabled: %s", + blog(LOG_INFO, "Item enabled: %s", selectedDeviceName.c_str()); + int devicePort = GetDeviceManager()->GetPortNumberByDeviceName( selectedDeviceName.c_str()); - int devicePort = - GetDeviceManager()->GetPortNumberByDeviceName( - selectedDeviceName.c_str()); int deviceOutPort = GetDeviceManager()->GetOutPortNumberByDeviceName( selectedOutDeviceName.c_str()); if (device == NULL) { - GetDeviceManager()->RegisterMidiDevice( - devicePort, deviceOutPort); + GetDeviceManager()->RegisterMidiDevice(devicePort, + deviceOutPort); device = GetDeviceManager()->GetMidiDeviceByName( selectedDeviceName.c_str()); device->OpenPort(devicePort); @@ -173,11 +174,7 @@ int SettingsDialog::on_check_enabled_stateChanged(bool state) device->OpenPort(devicePort); device->OpenOutPort(deviceOutPort); - } - - - } //ui->outbox->setCurrentText(QString::fromStdString(device->GetOutName())); @@ -193,7 +190,8 @@ void SettingsDialog::on_item_select(QString curitem) { auto texting = curitem.toStdString(); // Pull info on if device is enabled, if so set true if not set false - auto device = GetDeviceManager()->GetMidiDeviceByName(curitem.toStdString().c_str()); + auto device = GetDeviceManager()->GetMidiDeviceByName( + curitem.toStdString().c_str()); if (device != NULL && device->isEnabled()) { ui->check_enabled->setChecked(true); ui->btn_configure->setEnabled(true); @@ -210,8 +208,10 @@ void SettingsDialog::on_item_select(QString curitem) ui->bidirectional->setEnabled(false); } } -int SettingsDialog::on_bid_enabled_stateChanged(bool state) { - auto device = GetDeviceManager()->GetMidiDeviceByName(ui->list_midi_dev->currentItem()->text().toStdString().c_str()); +int SettingsDialog::on_bid_enabled_stateChanged(bool state) +{ + auto device = GetDeviceManager()->GetMidiDeviceByName( + ui->list_midi_dev->currentItem()->text().toStdString().c_str()); if (state) { return 1; device->setBidirectional(state); @@ -224,7 +224,7 @@ int SettingsDialog::on_bid_enabled_stateChanged(bool state) { GetConfig()->Load(); } - SettingsDialog::~SettingsDialog() +SettingsDialog::~SettingsDialog() { loadingdevices = false; diff --git a/src/midi-agent.cpp b/src/midi-agent.cpp index ec68297f..177446b8 100644 --- a/src/midi-agent.cpp +++ b/src/midi-agent.cpp @@ -15,7 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ +#if __has_include() #include +#include "rtmidi17/rtmidi17.hpp" +#else +#include +#include "RtMidi17/rtmidi17.hpp" +#endif #include //#include #include @@ -27,7 +33,7 @@ with this program. If not, see #include "obs-midi.h" #include "config.h" #include "obs-controller.h" -#include "rtmidi17/rtmidi17.hpp" + #include "device-manager.h" using namespace std; @@ -262,7 +268,6 @@ void MidiAgent::OpenPort(int inport) } catch (const rtmidi::midi_exception &error) { - blog(1, "unable to open port %i -- &s", inport, error.what()); } } @@ -273,7 +278,8 @@ void MidiAgent::OpenOutPort(int outport) midiout->open_port(outport); } catch (const rtmidi::midi_exception &error) { - blog(1, " Opening out port -- %i -- exception -- %s ", outport,error.what()); + blog(1, " Opening out port -- %i -- exception -- %s ", outport, + error.what()); } outname = midiout->get_port_name(outport); enabled = true; @@ -305,17 +311,19 @@ void MidiAgent::SetOutName(string oname) { if (outname != oname) { midiout->close_port(); - OpenOutPort(GetDeviceManager()->GetOutPortNumberByDeviceName(oname.c_str())); + OpenOutPort(GetDeviceManager()->GetOutPortNumberByDeviceName( + oname.c_str())); } outname = oname; } -bool MidiAgent::setBidirectional(bool state) { +bool MidiAgent::setBidirectional(bool state) +{ bidirectional = state; if (!state) { midiout->close_port(); } else { - if (midiout->is_port_open() ) { + if (midiout->is_port_open()) { midiout->close_port(); } OpenOutPort(GetDeviceManager()->GetOutPortNumberByDeviceName( @@ -544,15 +552,16 @@ void MidiAgent::NewObsEvent(QString eventType, QString eventData) obs_data_get_string(data, "previousName"); for (unsigned i = 0; i < self->midiHooks.size(); i++) { if (self->midiHooks.at(i)->param1 == from) { - self->midiHooks.at(i)->param1 = obs_data_get_string(data, "newName"); + self->midiHooks.at(i)->param1 = + obs_data_get_string(data, + "newName"); self->GetData(); - } } } else if (eventType == QString("Exiting")) { closing = true; - }else if (eventType == QString("SourceDestroyed")) { + } else if (eventType == QString("SourceDestroyed")) { if (!closing) { std::string from = obs_data_get_string(data, "sourceName"); diff --git a/src/midi-agent.h b/src/midi-agent.h index 343f1897..93a14e0d 100644 --- a/src/midi-agent.h +++ b/src/midi-agent.h @@ -17,12 +17,17 @@ with this program. If not, see #pragma once +#if __has_include() #include +#include "rtmidi17/rtmidi17.hpp" +#else +#include +#include "RtMidi17/rtmidi17.hpp" +#endif #include #include #include #include -#include "rtmidi17/rtmidi17.hpp" #include #include #include @@ -141,6 +146,6 @@ public slots: bool enabled; bool connected; bool bidirectional; - bool closing=false; + bool closing = false; vector midiHooks; }; diff --git a/src/obs-midi.cpp b/src/obs-midi.cpp index d27ffdf3..1106738a 100644 --- a/src/obs-midi.cpp +++ b/src/obs-midi.cpp @@ -1,7 +1,13 @@ #include #include +#if __has_include() #include +#include "rtmidi17/rtmidi17.hpp" +#else +#include +#include "RtMidi17/rtmidi17.hpp" +#endif #include #include #include @@ -9,7 +15,6 @@ #include #include "obs-midi.h" -#include "rtmidi17/rtmidi17.hpp" #include "forms/settings-dialog.h" #include #include @@ -98,7 +103,8 @@ eventsPtr GetEventsSystem() return _eventsSystem; } -void reloadEvents() { +void reloadEvents() +{ _eventsSystem.reset(); _eventsSystem = eventsPtr(new events(_deviceManager)); // Setup event handler to start the server once OBS is ready @@ -110,5 +116,4 @@ void reloadEvents() { }; obs_frontend_add_event_callback( eventCallback, (void *)(obs_frontend_event_cb)eventCallback); - } diff --git a/src/utils.cpp b/src/utils.cpp index 6bf035ab..5fa97e83 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -23,7 +23,11 @@ with this program. If not, see #include #include +#if __has_include() #include +#else +#include +#endif #include #include @@ -68,7 +72,7 @@ bool Utils::inrange(int low, int high, int x) } int Utils::get_midi_note_or_control(rtmidi::message mess) { - int bytetopullfrom; + int bytetopullfrom=-1; switch (mess.get_message_type()) { case rtmidi::message_type::INVALID: break; @@ -112,13 +116,12 @@ int Utils::get_midi_note_or_control(rtmidi::message mess) case rtmidi::message_type:: SYSTEM_RESET : bytetopullfrom = 0;break; ****************************************************/ } - auto ret = mess.bytes.at(bytetopullfrom); return mess[bytetopullfrom]; } int Utils::get_midi_value(rtmidi::message mess) { - int bytetopullfrom; + int bytetopullfrom=-1; switch (mess.get_message_type()) { case rtmidi::message_type::INVALID: break; @@ -165,7 +168,7 @@ int Utils::get_midi_value(rtmidi::message mess) case rtmidi::message_type:: SYSTEM_RESET : bytetopullfrom = 0;break; */ } - auto ret = mess.bytes.at(bytetopullfrom); + return mess[bytetopullfrom]; } diff --git a/src/utils.h b/src/utils.h index 9e99909a..a53dc507 100644 --- a/src/utils.h +++ b/src/utils.h @@ -17,7 +17,11 @@ with this program. If not, see */ #pragma once - +#if __has_include() +#include "rtmidi17/rtmidi17.hpp" +#else +#include "RtMidi17/rtmidi17.hpp" +#endif #include #include #include @@ -28,7 +32,7 @@ with this program. If not, see #include #include #include -#include "rtmidi17/rtmidi17.hpp" + #include #include #include