ffbconditioneffect.cpp \
rampeffectsettings.cpp \
ffbrampeffectparameters.cpp \
- ffbrampeffect.cpp
+ ffbrampeffect.cpp \
+ globalsettings.cpp
HEADERS += mainwindow.h \
deviceprober.h \
ffbconditioneffect.h \
rampeffectsettings.h \
ffbrampeffectparameters.h \
- ffbrampeffect.h
+ ffbrampeffect.h \
+ globalsettings.h
FORMS += mainwindow.ui \
constanteffectsettings.ui \
#include "ffbconditioneffect.h"
+#include "globalsettings.h"
FFBConditionEffect::FFBConditionEffect() :
FFBEffect(FFBEffectTypes::CONDITION)
if (!checkGenericParameters(params))
return false;
- if (!checkBoundsInclusive(params->center[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) {
- reportError("Center X out of bounds,");
- return false;
- }
- if (!checkBoundsInclusive(params->center[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) {
- reportError("Center Y out of bounds,");
- return false;
- }
-
- if (!checkBoundsInclusive(params->deadband[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) {
- reportError("Deadband X out of bounds.");
- return false;
- }
- if (!checkBoundsInclusive(params->deadband[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) {
- reportError("Deadband Y out of bounds.");
- return false;
- }
-
- if (!checkBoundsInclusive(params->leftCoeff[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) {
- reportError("Left coefficient X out of bounds.");
- return false;
- }
- if (!checkBoundsInclusive(params->leftCoeff[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) {
- reportError("Left coefficient Y out of bounds.");
- return false;
- }
-
- if (!checkBoundsInclusive(params->rightCoeff[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) {
- reportError("Right coefficient X out of bounds.");
- return false;
- }
- if (!checkBoundsInclusive(params->rightCoeff[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) {
- reportError("Right coefficient Y out of bounds.");
- return false;
- }
-
- if (!checkBoundsInclusive(params->leftSat[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) {
- reportError("Left saturation X out of bounds.");
- return false;
- }
- if (!checkBoundsInclusive(params->leftSat[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) {
- reportError("Left saturation Y out of bounds.");
- return false;
- }
-
- if (!checkBoundsInclusive(params->rightSat[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) {
- reportError("Right saturation X out of bounds.");
- return false;
- }
- if (!checkBoundsInclusive(params->rightSat[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) {
- reportError("Right saturation Y out of bounds.");
- return false;
- }
-
- if (params->subtype == ConditionSubtypes::NONE) {
- reportError("Invalid subtype");
- return false;
+ if (GlobalSettings::GS()->doSanityChecks) {
+ if (!checkBoundsInclusive(params->center[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) {
+ reportError("Center X out of bounds,");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->center[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) {
+ reportError("Center Y out of bounds,");
+ return false;
+ }
+
+ if (!checkBoundsInclusive(params->deadband[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) {
+ reportError("Deadband X out of bounds.");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->deadband[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) {
+ reportError("Deadband Y out of bounds.");
+ return false;
+ }
+
+ if (!checkBoundsInclusive(params->leftCoeff[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) {
+ reportError("Left coefficient X out of bounds.");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->leftCoeff[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) {
+ reportError("Left coefficient Y out of bounds.");
+ return false;
+ }
+
+ if (!checkBoundsInclusive(params->rightCoeff[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) {
+ reportError("Right coefficient X out of bounds.");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->rightCoeff[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) {
+ reportError("Right coefficient Y out of bounds.");
+ return false;
+ }
+
+ if (!checkBoundsInclusive(params->leftSat[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) {
+ reportError("Left saturation X out of bounds.");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->leftSat[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) {
+ reportError("Left saturation Y out of bounds.");
+ return false;
+ }
+
+ if (!checkBoundsInclusive(params->rightSat[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) {
+ reportError("Right saturation X out of bounds.");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->rightSat[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) {
+ reportError("Right saturation Y out of bounds.");
+ return false;
+ }
+
+ if (params->subtype == ConditionSubtypes::NONE) {
+ reportError("Invalid subtype");
+ return false;
+ }
}
m_params = params;
#include "ffbconstanteffect.h"
+#include "globalsettings.h"
FFBConstantEffect::FFBConstantEffect() :
FFBEffect(FFBEffectTypes::CONSTANT)
if (!checkGenericParameters(params))
return false;
- if (!checkBoundsInclusive(params->attackLength, 0, 0xFFFF))
- return false;
- if (!checkBoundsInclusive(params->attackLevel, 0, 0xFFFF))
- return false;
- if (!checkBoundsInclusive(params->fadeLevel, 0, 0xFFFF))
- return false;
- if (!checkBoundsInclusive(params->fadeLevel, 0, 0xFFFF))
- return false;
+ if (GlobalSettings::GS()->doSanityChecks) {
+ if (!checkBoundsInclusive(params->attackLength, 0, 0xFFFF)){
+ reportError("Attack length out of bounds");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->attackLevel, 0, 0xFFFF)) {
+ reportError("Attack level out of bounds");
+ return false;
+ } if (!checkBoundsInclusive(params->fadeLength, 0, 0xFFFF)) {
+ reportError("Fade length out of bounds");
+ return false;
+ }
+ if (!checkBoundsInclusive(params->fadeLevel, 0, 0xFFFF)) {
+ reportError("Fade level out of bounds");
+ return false;
+ }
- if (!checkBoundsInclusive(params->level, -0x7FFF, 0x7FFF)) {
- reportError("Level out of bounds.");
- return false;
+ if (!checkBoundsInclusive(params->level, -0x7FFF, 0x7FFF)) {
+ reportError("Level out of bounds.");
+ return false;
+ }
}
m_params = params;
#include "ffbeffect.h"
+#include "globalsettings.h"
#include <QtWidgets/QMessageBox>
FFBEffect::FFBEffect(FFBEffectTypes type)
bool FFBEffect::checkGenericParameters(const std::shared_ptr<FFBEffectParameters> params)
{
+ if (!GlobalSettings::GS()->doSanityChecks)
+ return true;
+
if (!checkBoundsInclusive(params->direction, 0, 0xFFFF)) {
reportError("Direction out of bounds.");
return false;
#include "ffbperiodiceffect.h"
+#include "globalsettings.h"
#include <QDebug>
FFBPeriodicEffect::FFBPeriodicEffect() :
if (!checkGenericParameters(params))
return false;
- if (!checkBoundsInclusive(params->attackLength, 0, 0xFFFF)) {
- reportError("Attack length out of bounds.");
- return false;
- }
+ if (GlobalSettings::GS()->doSanityChecks) {
+ if (!checkBoundsInclusive(params->attackLength, 0, 0xFFFF)) {
+ reportError("Attack length out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->attackLevel, 0, 0xFFFF)) {
- reportError("Attack level out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->attackLevel, 0, 0xFFFF)) {
+ reportError("Attack level out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->fadeLength, 0, 0xFFFF)) {
- reportError("Fade length out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->fadeLength, 0, 0xFFFF)) {
+ reportError("Fade length out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->fadeLevel, 0, 0xFFFF)) {
- reportError("Fade level out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->fadeLevel, 0, 0xFFFF)) {
+ reportError("Fade level out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->magnitude, -0x7FFF, 0x7FFF)) {
- reportError("Magnitude out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->magnitude, -0x7FFF, 0x7FFF)) {
+ reportError("Magnitude out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->offset, -0x7FFF, 0x7FFF)) {
- reportError("Offset out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->offset, -0x7FFF, 0x7FFF)) {
+ reportError("Offset out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->period, 0, 0xFFFF)) {
- reportError("Period out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->period, 0, 0xFFFF)) {
+ reportError("Period out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->phase, 0, 0xFFFF)) {
- reportError("Phase out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->phase, 0, 0xFFFF)) {
+ reportError("Phase out of bounds.");
+ return false;
+ }
- if (params->waveform == PeriodicWaveforms::NONE) {
- reportError("Invalid waveform type.");
- return false;
+ if (params->waveform == PeriodicWaveforms::NONE) {
+ reportError("Invalid waveform type.");
+ return false;
+ }
}
m_params = params;
#include "ffbrampeffect.h"
+#include "globalsettings.h"
FFBRampEffect::FFBRampEffect() :
FFBEffect(FFBEffectTypes::RAMP)
if (!checkGenericParameters(params))
return false;
- if (!checkBoundsInclusive(params->attackLength, 0, 0xFFFF)) {
- reportError("Attack length out of bounds.");
- return false;
- }
+ if (GlobalSettings::GS()->doSanityChecks) {
+ if (!checkBoundsInclusive(params->attackLength, 0, 0xFFFF)) {
+ reportError("Attack length out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->attackLevel, 0, 0xFFFF)) {
- reportError("Attack level out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->attackLevel, 0, 0xFFFF)) {
+ reportError("Attack level out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->fadeLength, 0, 0xFFFF)) {
- reportError("Fade length out of bounds.");
- return false;
- }
+ if (!checkBoundsInclusive(params->fadeLength, 0, 0xFFFF)) {
+ reportError("Fade length out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->endLevel, -0x7FFF, 0x7FFF)) {
- reportError("End level out of bounds");
- return false;
- }
+ if (!checkBoundsInclusive(params->fadeLevel, 0, 0xFFFF)) {
+ reportError("Fade level out of bounds.");
+ return false;
+ }
- if (!checkBoundsInclusive(params->startLevel, -0x7FFF, 0x7FFF)) {
- reportError("Start level out of bounds");
+ if (!checkBoundsInclusive(params->endLevel, -0x7FFF, 0x7FFF)) {
+ reportError("End level out of bounds");
return false;
+ }
+
+ if (!checkBoundsInclusive(params->startLevel, -0x7FFF, 0x7FFF)) {
+ reportError("Start level out of bounds");
+ return false;
+ }
}
m_params = params;
--- /dev/null
+#include "globalsettings.h"
+
+GlobalSettings* GlobalSettings::s_instance(nullptr);
+
+void GlobalSettings::init(bool doSanityChecks)
+{
+ if (s_instance == nullptr) {
+ s_instance = new GlobalSettings;
+
+ s_instance->doSanityChecks = doSanityChecks;
+ }
+}
+
+const GlobalSettings* GlobalSettings::GS() {
+ return s_instance;
+}
+
+GlobalSettings::GlobalSettings()
+{}
+
+GlobalSettings::~GlobalSettings()
+{
+ delete s_instance;
+ s_instance = nullptr;
+}
--- /dev/null
+#ifndef GLOBALSETTINGS_H
+#define GLOBALSETTINGS_H
+
+class GlobalSettings {
+public:
+ static void init(bool doSanityChecks);
+ static const GlobalSettings* GS();
+ explicit GlobalSettings();
+ ~GlobalSettings();
+
+ bool doSanityChecks;
+
+private:
+ static GlobalSettings* s_instance;
+};
+
+#endif // GLOBALSETTINGS_H
#include "deviceprober.h"
+#include "globalsettings.h"
#include "mainwindow.h"
#include <QtWidgets/QApplication>
+#include <QDebug>
+
+const QString NO_CHECKS_ARG("--no-checks");
+
int main(int argc, char** argv)
{
QApplication myApp(argc, argv);
const QString VERSION_STRING = QString(APP_NAME) + " " + QString::number(APP_VERSION_MAJOR) + "." + QString::number(APP_VERSION_MINOR) +
QString(APP_VERSION_REL);
+
+ /* Setup global settings */
+ {
+ bool doSanityChecks;
+ QStringList cmdArgs = QCoreApplication::arguments();
+ if (cmdArgs.contains(NO_CHECKS_ARG)) {
+ doSanityChecks = false;
+ qDebug() << "Disabling effect parameters sanity checks";
+ } else
+ doSanityChecks = true;
+
+ GlobalSettings::init(doSanityChecks);
+ }
+
std::shared_ptr<DeviceProber> prober(new DeviceProber);
MainWindow* mWin = new MainWindow(prober, VERSION_STRING);
+#include "globalsettings.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets/QMessageBox>
ui->qstw_effectSpecifics->addWidget(m_periodicEffSet);
ui->qstw_effectSpecifics->addWidget(m_rampEffSet);
+ if (GlobalSettings::GS()->doSanityChecks)
+ ui->ql_noChecksWarning->setHidden(true);
+
fillDeviceList();
connect(ui->cbox_devices, SIGNAL(activated(const QString&)), this, SLOT(onDeviceSelected(const QString&)));
connect(ui->cbox_effectSlots, SIGNAL(activated(const int)), this, SLOT(onEffectSlotSelected(const int)));
</item>
</layout>
</item>
+ <item>
+ <widget class="QLabel" name="ql_noChecksWarning">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>WARNING: Sanity checks disabled!</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>