project(FFBChecker)
-add_definitions("-std=c++11 -Wall -Wextra")
+find_package(Qt5Widgets)
-if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
- add_definitions("-ggdb -g3")
-endif()
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ # Linux-specific definitions
+ set(PLATFORM_LINUX 1)
+ add_definitions("-std=c++11 -Wall -Wextra")
+ add_definitions("-DFFBC_PLATFORM_LINUX")
-find_package(Qt5Widgets)
+ if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
+ add_definitions("-ggdb -g3")
+ endif()
-include(FindPkgConfig)
-pkg_search_module(SDL2 sdl2)
-if (SDL2_FOUND)
- add_definitions("-DFFBC_HAVE_SDL2")
+ # Try to utilize SDL2 if it is available
+ include(FindPkgConfig)
+ pkg_search_module(SDL2 sdl2)
+ if (SDL2_FOUND)
+ add_definitions("-DFFBC_HAVE_SDL2")
+ endif()
+elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+ set(PLATFORM_WIN32 1)
+ add_definitions("-DFFBC_PLATFORM_WIN32 -DFFBC_HAVE_SDL2")
+
+ # Enforce SDL2 on Windows
+ set(SDL2_FOUND 1)
+ # Adjust these paths accordingly to your setup
+ set(QT_LIBS_PATH "C://Qt-Static//bin_noicu")
+ set(SDL2_INCLUDE_DIRS "C://Users//Sacrilegium//Hacking//SDL2-2.0.3//include")
+ set(SDL2_LIBRARIES ${SDL2_LIBRARIES} "C://Users//Sacrilegium//Hacking//SDL2-2.0.3//lib//x86//SDL2.lib")
+ # set(SDL2_LIBRARIES ${SDL2_LIBRARIES} "C://Users//Sacrilegium//Hacking//SDL2-2.0.3//lib//x86//SDL2main.lib")
endif()
set(CMAKE_AUTOMOC ON)
conditioneffectsettings.cpp
constanteffectsettings.cpp
effectsettings.cpp
- envelopesettings.cpp
- linuxffbconditioneffect.cpp
- ffbconditioneffectparameters.cpp
- linuxffbconstanteffect.cpp
+ envelopesettings.cpp
+ ffbconditioneffectparameters.cpp
ffbconstanteffectparameters.cpp
ffbdevice.cpp
- ffbeffect.cpp
- linuxffbeffect.cpp
- linuxffbeffectfactory.cpp
+ ffbeffect.cpp
ffbeffectparameters.cpp
ffbenvelopeparameters.cpp
- ffbnulleffect.cpp
- linuxffbperiodiceffect.cpp
- ffbperiodiceffectparameters.cpp
- linuxffbrampeffect.cpp
+ ffbnulleffect.cpp
+ ffbperiodiceffectparameters.cpp
ffbrampeffectparameters.cpp
- linuxffbrumbleeffect.cpp
ffbrumbleeffectparameters.cpp
globalsettings.cpp
- linuxdeviceprober.cpp
- linuxffbdevice.cpp
main.cpp
mainwindow.cpp
periodiceffectsettings.cpp
rampeffectsettings.cpp
rumbleeffectsettings.cpp)
+if (PLATFORM_LINUX)
+ set(FFBChecker_SRCS
+ ${FFBChecker_SRCS}
+ linuxdeviceprober.cpp
+ linuxffbdevice.cpp
+ linuxffbrumbleeffect.cpp
+ linuxffbrampeffect.cpp
+ linuxffbperiodiceffect.cpp
+ linuxffbeffect.cpp
+ linuxffbeffectfactory.cpp
+ linuxffbconstanteffect.cpp
+ linuxffbconditioneffect.cpp)
+endif()
+
if (SDL2_FOUND)
set(FFBChecker_SRCS
${FFBChecker_SRCS}
include_directories(${SDL2_INCLUDE_DIRS})
endif()
+if (PLATFORM_WIN32)
+ include_directories("${QT_LIBS_PATH}//include")
+endif()
+
add_executable(FFBChecker ${FFBChecker_SRCS})
-target_link_libraries(FFBChecker Qt5::Widgets)
+
+if (PLATFORM_LINUX)
+ target_link_libraries(FFBChecker Qt5::Widgets)
+elseif (PLATFORM_WIN32)
+ target_link_libraries(FFBChecker "Ws2_32.lib")
+ target_link_libraries(FFBChecker "imm32.lib")
+ target_link_libraries(FFBChecker "winmm.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//plugins//platforms//qwindows.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//qtpcre.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//qtharfbuzzng.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//qtfreetype.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//Qt5Core.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//Qt5PlatformSupport.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//Qt5Gui.lib")
+ target_link_libraries(FFBChecker "${QT_LIBS_PATH}//lib//Qt5Widgets.lib")
+endif()
if (SDL2_FOUND)
target_link_libraries(FFBChecker ${SDL2_LIBRARIES})
endif()
+
#include "conditioneffectsettings.h"
#include "ui_conditioneffectsettings.h"
-#include <QDebug>
ConditionEffectSettings::ConditionEffectSettings(QWidget* parent) :
EffectSettings(parent),
ui->qstw_leftSat->setCurrentIndex(idx);
ui->qstw_rightCoeff->setCurrentIndex(idx);
ui->qstw_rightSat->setCurrentIndex(idx);
- qDebug() << "Axis changed" << idx;
}
QString ConditionEffectSettings::conditionSubtypeToConditionName(const ConditionSubtypes subtype) const
#include "envelopesettings.h"
#include "ui_envelopesettings.h"
-#include <QDebug>
EnvelopeSettings::EnvelopeSettings(QWidget *parent) :
QWidget(parent),
#include "mainwindow.h"
#include <QtWidgets/QApplication>
-#include <QDebug>
+#ifdef FFBC_PLATFORM_WIN32
+#include <QtCore/QtPlugin>
+Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+#endif
const QString NO_CHECKS_ARG("--no-checks");
{
bool doSanityChecks;
QStringList cmdArgs = QCoreApplication::arguments();
- if (cmdArgs.contains(NO_CHECKS_ARG)) {
+ if (cmdArgs.contains(NO_CHECKS_ARG))
doSanityChecks = false;
- qDebug() << "Disabling effect parameters sanity checks";
- } else
+ else
doSanityChecks = true;
GlobalSettings::init(doSanityChecks);
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets/QMessageBox>
-#include <QDebug>
+#ifdef FFBC_PLATFORM_LINUX
#include "linuxdeviceprober.h"
+#endif
#ifdef FFBC_HAVE_SDL2
#include "sdl2deviceprober.h"
#endif
ui->ql_noChecksWarning->setHidden(true);
/* Fill the list of available interfaces */
+#ifdef FFBC_PLATFORM_LINUX
ui->cbox_interfaces->addItem("Linux API", static_cast<std::underlying_type<DeviceProber::DeviceInterfaces>::type>(DeviceProber::DeviceInterfaces::LINUX));
+#endif
#ifdef FFBC_HAVE_SDL2
if (SDL2DeviceProber::initializeSDL())
ui->cbox_interfaces->addItem("SDL2", static_cast<std::underlying_type<DeviceProber::DeviceInterfaces>::type>(DeviceProber::DeviceInterfaces::SDL2));
#endif
ui->cbox_interfaces->setCurrentIndex(0);
- createDeviceProber(DeviceProber::DeviceInterfaces::LINUX);
+ onInterfaceSelected(0);
fillDeviceList();
connect(ui->cbox_devices, SIGNAL(activated(const int)), this, SLOT(onDeviceSelected(const int)));
}
switch (iface) {
+#ifdef FFBC_PLATFORM_LINUX
case DeviceProber::DeviceInterfaces::LINUX:
prober = std::make_shared<LinuxDeviceProber>();
break;
+#endif
#ifdef FFBC_HAVE_SDL2
case DeviceProber::DeviceInterfaces::SDL2:
prober = std::make_shared<SDL2DeviceProber>();
return;
}
FFBEffectTypes etype = m_activeDevice->effectTypeByEffectIdx(effectIdx);
- qDebug() << static_cast<int>(etype);
if (etype == FFBEffectTypes::NONE) {
- qDebug() << "Empty effect";
setEffectTypeIndexByType(etype);
ui->qstw_effectSpecifics->setCurrentWidget(effectSettingsByType(FFBEffectTypes::CONSTANT));
setEffectStatusText(FFBEffect::FFBEffectStatus::NOT_LOADED);
return;
}
- if (!readEffectParameters(params, etype)) {
- qDebug() << "Cannot read effect params.";
+ if (!readEffectParameters(params, etype))
return;
- }
+
bool ret = m_activeDevice->startEffect(effectSlot, etype, params);
if (ret)
setEffectStatusText(m_activeDevice->effectStatusByIdx(effectSlot));
return;
}
- if (!readEffectParameters(params, etype)) {
- qDebug() << "Cannot read effect params.";
+ if (!readEffectParameters(params, etype))
return;
- }
+
bool ret = m_activeDevice->uploadEffect(effectSlot, etype, params);
if (ret)
setEffectStatusText(m_activeDevice->effectStatusByIdx(effectSlot));
break;
}
default:
- qDebug() << "Unhandled type of effect";
return false;
}
#include "rampeffectsettings.h"
#include "rumbleeffectsettings.h"
#include <memory>
-#include <QMainWindow>
+#include <QtWidgets/QMainWindow>
namespace Ui {
class MainWindow;
return effect;
}
-bool SDL2FFBConditionEffect::setParameters(std::shared_ptr<FFBEffectParameters> params)
+bool SDL2FFBConditionEffect::setParameters(const std::shared_ptr<FFBEffectParameters> params)
{
try {
const std::shared_ptr<FFBConditionEffectParameters> iParams = std::dynamic_pointer_cast<FFBConditionEffectParameters>(params);
}
}
-bool SDL2FFBConditionEffect::setParameters(std::shared_ptr<FFBConditionEffectParameters> params)
+bool SDL2FFBConditionEffect::setParameters(const std::shared_ptr<FFBConditionEffectParameters> params)
{
if (!GlobalSettings::GS()->doSanityChecks)
return true;
SDL2FFBConditionEffect();
virtual SDL_HapticEffect* createFFstruct();
inline const std::shared_ptr<FFBEffectParameters> parameters() const { return m_params; }
- bool setParameters(std::shared_ptr<FFBEffectParameters> params);
+ bool setParameters(const std::shared_ptr<FFBEffectParameters> params);
bool operator==(const FFBEffect& other) const;
private:
- bool setParameters(std::shared_ptr<FFBConditionEffectParameters> params);
+ bool setParameters(const std::shared_ptr<FFBConditionEffectParameters> params);
std::shared_ptr<FFBConditionEffectParameters> m_params;
};
#include "sdl2ffbdevice.h"
#include "sdl2ffbeffectfactory.h"
#include <QtWidgets/QMessageBox>
-#include <QtCore/QDebug>
#define CHECK_EFFECT_IDX(idx) if (idx < 0 || idx > c_maxEffectCount) return false
else
return false;
- if (sdlEff == nullptr) {
- qDebug() << "Unable to create effect";
+ if (sdlEff == nullptr)
return false;
- }
- if (!sdlEff->setParameters(parameters)) {
- qDebug() << "Unable to set effect parameters, some values are probably invalid.";
+ if (!sdlEff->setParameters(parameters))
return false;
- }
/* There is no effect in the selected slot */
if (m_effects[idx]->type() != FFBEffectTypes::NONE) {
/* Effects are not of the same type, delete the previous effect and create a new one */
if (*m_effects[idx] != *sdlEff) {
if (!removeEffect(idx)) {
- qDebug() << "Recreating effect";
- return false;
+ return false;
}
} else {
/* Effects are of the same type, update it */
- qDebug() << "Updating effect";
underlEff = sdlEff->createFFstruct();
- if (underlEff == nullptr) {
- qDebug() << "SDL2: Unable to create effect data";
- return false;
- }
+ if (underlEff == nullptr)
+ return false;
intIdx = SDL_HapticUpdateEffect(c_haptic, std::static_pointer_cast<SDL2FFBEffect>(m_effects[idx])->internalIdx(), underlEff);
if (intIdx < 0) {
- QMessageBox::critical(nullptr, SDL2DEV_ERR_CAPTION, QString("Unable to update the effect:\n%1").arg(SDL_GetError()));
- m_effects[idx]->setStatus(FFBEffect::FFBEffectStatus::UPLOADED);
- return true;
+ QMessageBox::critical(nullptr, SDL2DEV_ERR_CAPTION, QString("Unable to update the effect:\n%1").arg(SDL_GetError()));
+ m_effects[idx]->setStatus(FFBEffect::FFBEffectStatus::UPLOADED);
+ return true;
}
sdlEff->setStatus(m_effects[idx]->status());
}
}
- qDebug() << "Creating new effect";
underlEff = sdlEff->createFFstruct();
- if (underlEff == nullptr) {
- qDebug() << "SDL2: Unable to create effect data";
+ if (underlEff == nullptr)
return false;
- }
intIdx = SDL_HapticNewEffect(c_haptic, underlEff);
if (intIdx < 0) {