From: Michal MalĂ˝ Date: Sat, 1 Aug 2015 12:18:58 +0000 (+0200) Subject: Generalize reporting of invalid effect parameters. X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=45bcd1c37617ea2e7dc2edd082646bf00fdcb951;p=FFBChecker.git Generalize reporting of invalid effect parameters. --- diff --git a/ffbeffect.cpp b/ffbeffect.cpp index 4a69340..af448c8 100644 --- a/ffbeffect.cpp +++ b/ffbeffect.cpp @@ -1,5 +1,6 @@ #include "ffbeffect.h" #include "globalsettings.h" +#include const QString FFBEffect::PRERR_CAPTION("Invalid FFB parameter"); @@ -9,6 +10,11 @@ FFBEffect::FFBEffect(FFBEffectTypes type) m_type = type; } +void FFBEffect::reportError(const QString& errorMsg) const +{ + QMessageBox::warning(nullptr, PRERR_CAPTION, errorMsg); +} + bool FFBEffect::operator==(const FFBEffect& other) const { return this->type() == other.type(); diff --git a/ffbeffect.h b/ffbeffect.h index 7313338..383252c 100644 --- a/ffbeffect.h +++ b/ffbeffect.h @@ -20,7 +20,9 @@ public: virtual bool operator!=(const FFBEffect&) const; protected: + virtual bool checkEnvelopeParameters(const int attackLength, const int attackLevel, const int fadeLength, const int fadeLevel) = 0; virtual bool checkGenericParameters(const std::shared_ptr params) = 0; + void reportError(const QString& errorMsg) const; static const QString PRERR_CAPTION; diff --git a/ffbnulleffect.h b/ffbnulleffect.h index 2aa896c..7410a17 100644 --- a/ffbnulleffect.h +++ b/ffbnulleffect.h @@ -11,6 +11,11 @@ public: inline bool setParameters(const std::shared_ptr params) { (void)(params); return false; } protected: + bool checkEnvelopeParameters(const int attackLength, const int attackLevel, const int fadeLength, const int fadeLevel) + { + Q_UNUSED(attackLength); Q_UNUSED(attackLevel); Q_UNUSED(fadeLength); Q_UNUSED(fadeLevel); + return false; + } bool checkGenericParameters(const std::shared_ptr params) { Q_UNUSED(params); return false; } }; diff --git a/linuxffbconditioneffect.cpp b/linuxffbconditioneffect.cpp index 9b3d5fd..dfe6ebf 100644 --- a/linuxffbconditioneffect.cpp +++ b/linuxffbconditioneffect.cpp @@ -58,68 +58,69 @@ bool LinuxFFBConditionEffect::setParameters(const std::shared_ptr params) { + if (!GlobalSettings::GS()->doSanityChecks) + return true; + if (!checkGenericParameters(params)) 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->center[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) { + reportError("Center X must be within <-32767; 32767>"); + return false; + } + if (!checkBoundsInclusive(params->center[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) { + reportError("Center Y must be within <-32767; 32767>"); + 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->deadband[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) { + reportError("Deadband X must be within <0; 65535>"); + return false; + } + if (!checkBoundsInclusive(params->deadband[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) { + reportError("Deadband Ymust be within <0; 65535>"); + 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->leftCoeff[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) { + reportError("Left coefficient X must be within <-32767; 32767>"); + return false; + } + if (!checkBoundsInclusive(params->leftCoeff[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) { + reportError("Left coefficient Y must be within <-32767; 32767>"); + 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->rightCoeff[FFBConditionEffectParameters::Axis::X], -0x7FFF, 0x7FFF)) { + reportError("Right coefficient X must be within <-32767; 32767>"); + return false; + } + if (!checkBoundsInclusive(params->rightCoeff[FFBConditionEffectParameters::Axis::Y], -0x7FFF, 0x7FFF)) { + reportError("Right coefficient Y must be within <-32767; 32767>"); + 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->leftSat[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) { + reportError("Left saturation X must be within <0; 65535>"); + return false; + } + if (!checkBoundsInclusive(params->leftSat[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) { + reportError("Left saturation Y must be within <0; 65535>"); + 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 (!checkBoundsInclusive(params->rightSat[FFBConditionEffectParameters::Axis::X], 0, 0xFFFF)) { + reportError("Right saturation X must be within <0; 65535>"); + return false; + } + if (!checkBoundsInclusive(params->rightSat[FFBConditionEffectParameters::Axis::Y], 0, 0xFFFF)) { + reportError("Right saturation Y must be within <0; 65535>"); + return false; + } - if (params->subtype == ConditionSubtypes::NONE) { - reportError("Invalid subtype"); - return false; - } + if (params->subtype == ConditionSubtypes::NONE) { + reportError("Invalid subtype"); + return false; } m_params = params; diff --git a/linuxffbconstanteffect.cpp b/linuxffbconstanteffect.cpp index 347d96f..2720575 100644 --- a/linuxffbconstanteffect.cpp +++ b/linuxffbconstanteffect.cpp @@ -34,30 +34,18 @@ bool LinuxFFBConstantEffect::setParameters(const std::shared_ptr params) { + if (!GlobalSettings::GS()->doSanityChecks) + return true; + if (!checkGenericParameters(params)) return false; - if (GlobalSettings::GS()->doSanityChecks) { - if (!checkBoundsInclusive(params->attackLength, 0, 0x7FFF)){ - reportError("Attack length out of bounds"); - return false; - } - if (!checkBoundsInclusive(params->attackLevel, 0, 0x7FFF)) { - reportError("Attack level out of bounds"); - return false; - } if (!checkBoundsInclusive(params->fadeLength, 0, 0x7FFF)) { - reportError("Fade length out of bounds"); - return false; - } - if (!checkBoundsInclusive(params->fadeLevel, 0, 0x7FFF)) { - reportError("Fade level out of bounds"); - return false; - } + if (!checkEnvelopeParameters(params->attackLength, params->attackLevel, params->fadeLength, params->fadeLevel)) + 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; diff --git a/linuxffbeffect.cpp b/linuxffbeffect.cpp index 75a1b11..6d9e4d3 100644 --- a/linuxffbeffect.cpp +++ b/linuxffbeffect.cpp @@ -1,6 +1,5 @@ #include "linuxffbeffect.h" #include "globalsettings.h" -#include LinuxFFBEffect::LinuxFFBEffect(FFBEffectTypes type) : FFBEffect(type) @@ -21,9 +20,32 @@ struct ff_effect* LinuxFFBEffect::createFFStruct(const std::shared_ptrdoSanityChecks) + return true; + + if (!checkBoundsInclusive(attackLength, 0, 0x7FFF)) { + reportError("Attack length must be within <0; 32767>"); + return false; + } + + if (!checkBoundsInclusive(attackLevel, 0, 0x7FFF)) { + reportError("Attack level must be within <0; 32767>"); + return false; + } + + if (!checkBoundsInclusive(fadeLength, 0, 0x7FFF)) { + reportError("Fade length must be within <0; 32767>"); + return false; + } + + if (!checkBoundsInclusive(fadeLevel, 0, 0x7FFF)) { + reportError("Fade level must be within <0; 32767>"); + return false; + } + + return true; } bool LinuxFFBEffect::checkGenericParameters(const std::shared_ptr params) @@ -37,17 +59,17 @@ bool LinuxFFBEffect::checkGenericParameters(const std::shared_ptrdirection, 0, 0xFFFF)) { - reportError("Direction out of bounds."); + reportError("Direction must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->replayDelay, 0, 0x7FFF)) { - reportError("Replay delay out of bounds."); + reportError("Replay delay must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->replayLength, static_cast(0), static_cast(0x7FFF))) { - reportError("Replay length out of bounds."); + reportError("Replay length must be within <0; 32767>"); return false; } diff --git a/linuxffbeffect.h b/linuxffbeffect.h index 3f83094..5bd70aa 100644 --- a/linuxffbeffect.h +++ b/linuxffbeffect.h @@ -13,8 +13,8 @@ public: protected: struct ff_effect* createFFStruct(const std::shared_ptr params); + bool checkEnvelopeParameters(const int attackLength, const int attackLevel, const int fadeLength, const int fadeLevel); bool checkGenericParameters(const std::shared_ptr params); - void reportError(const QString& errorMsg) const; private: diff --git a/linuxffbperiodiceffect.cpp b/linuxffbperiodiceffect.cpp index 4602c9f..2bf51cc 100644 --- a/linuxffbperiodiceffect.cpp +++ b/linuxffbperiodiceffect.cpp @@ -60,54 +60,38 @@ bool LinuxFFBPeriodicEffect::setParameters(const std::shared_ptr params) { + if (!GlobalSettings::GS()->doSanityChecks) + return true; + if (!checkGenericParameters(params)) return false; - if (GlobalSettings::GS()->doSanityChecks) { - if (!checkBoundsInclusive(params->attackLength, 0, 0x7FFF)) { - reportError("Attack length out of bounds."); - return false; - } - - if (!checkBoundsInclusive(params->attackLevel, 0, 0x7FFF)) { - reportError("Attack level out of bounds."); - return false; - } - - if (!checkBoundsInclusive(params->fadeLength, 0, 0x7FFF)) { - reportError("Fade length out of bounds."); - return false; - } - - if (!checkBoundsInclusive(params->fadeLevel, 0, 0x7FFF)) { - reportError("Fade level out of bounds."); - return false; - } + if (!checkEnvelopeParameters(params->attackLength, params->attackLevel, params->fadeLength, params->fadeLevel)) + return false; - if (!checkBoundsInclusive(params->magnitude, -0x7FFF, 0x7FFF)) { - reportError("Magnitude out of bounds."); - return false; - } + if (!checkBoundsInclusive(params->magnitude, -0x7FFF, 0x7FFF)) { + reportError("Magnitude must be within <-32767; 32767>"); + return false; + } - if (!checkBoundsInclusive(params->offset, -0x7FFF, 0x7FFF)) { - reportError("Offset out of bounds."); - return false; - } + if (!checkBoundsInclusive(params->offset, -0x7FFF, 0x7FFF)) { + reportError("Offset must be within <32767; 32767>"); + return false; + } - if (!checkBoundsInclusive(params->period, 0, 0x7FFF)) { - reportError("Period out of bounds."); - return false; - } + if (!checkBoundsInclusive(params->period, 0, 0x7FFF)) { + reportError("Period must be within <0; 32767>"); + return false; + } - if (!checkBoundsInclusive(params->phase, 0, 0x7FFF)) { - reportError("Phase out of bounds."); - return false; - } + if (!checkBoundsInclusive(params->phase, 0, 0x7FFF)) { + reportError("Phase must be within <0; 32767>"); + 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; diff --git a/linuxffbrampeffect.cpp b/linuxffbrampeffect.cpp index f93cd51..87dcaab 100644 --- a/linuxffbrampeffect.cpp +++ b/linuxffbrampeffect.cpp @@ -38,39 +38,23 @@ bool LinuxFFBRampEffect::setParameters(const std::shared_ptr params) { + if (!GlobalSettings::GS()->doSanityChecks) + return true; + if (!checkGenericParameters(params)) return false; - if (GlobalSettings::GS()->doSanityChecks) { - if (!checkBoundsInclusive(params->attackLength, 0, 0x7FFF)) { - reportError("Attack length out of bounds."); - return false; - } - - if (!checkBoundsInclusive(params->attackLevel, 0, 0x7FFF)) { - reportError("Attack level out of bounds."); - return false; - } - - if (!checkBoundsInclusive(params->fadeLength, 0, 0x7FFF)) { - reportError("Fade length out of bounds."); - return false; - } - - if (!checkBoundsInclusive(params->fadeLevel, 0, 0x7FFF)) { - reportError("Fade level out of bounds."); - return false; - } + if (!checkEnvelopeParameters(params->attackLength, params->attackLevel, params->fadeLength, params->fadeLevel)) + return false; - if (!checkBoundsInclusive(params->endLevel, -0x7FFF, 0x7FFF)) { - reportError("End level out of bounds"); - return false; - } + if (!checkBoundsInclusive(params->endLevel, -0x7FFF, 0x7FFF)) { + reportError("End level must be within <-32767; 32767>"); + return false; + } - if (!checkBoundsInclusive(params->startLevel, -0x7FFF, 0x7FFF)) { - reportError("Start level out of bounds"); - return false; - } + if (!checkBoundsInclusive(params->startLevel, -0x7FFF, 0x7FFF)) { + reportError("Start level must be within <-32767; 32767>"); + return false; } m_params = params; diff --git a/linuxffbrumbleeffect.cpp b/linuxffbrumbleeffect.cpp index e6f58f4..9ada1d7 100644 --- a/linuxffbrumbleeffect.cpp +++ b/linuxffbrumbleeffect.cpp @@ -33,12 +33,12 @@ bool LinuxFFBRumbleEffect::setParameters(const std::shared_ptrstrongMagnitude, 0, 0xFFFF)) { - reportError("Strong magnitude out of bounds"); + reportError("Strong magnitude must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->weakMagnitude, 0, 0xFFFF)) { - reportError("Weak magnitude out of bounds"); + reportError("Weak magnitude must be within <0; 65535>"); return false; } diff --git a/sdl2ffbconditioneffect.cpp b/sdl2ffbconditioneffect.cpp index d76f56b..1702fbd 100644 --- a/sdl2ffbconditioneffect.cpp +++ b/sdl2ffbconditioneffect.cpp @@ -1,6 +1,5 @@ #include "sdl2ffbconditioneffect.h" #include "globalsettings.h" -#include SDL2FFBConditionEffect::SDL2FFBConditionEffect() : SDL2FFBEffect(FFBEffectTypes::CONDITION) @@ -73,62 +72,62 @@ bool SDL2FFBConditionEffect::setParameters(std::shared_ptrleftSat.at(FFBConditionEffectParameters::Axis::X), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Left X saturation must be within <0; 65535>"); + reportError("Left X saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->leftSat.at(FFBConditionEffectParameters::Axis::Y), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Left Y saturation must be within <0; 65535>"); + reportError("Left Y saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->rightSat.at(FFBConditionEffectParameters::Axis::X), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Right X saturation must be within <0; 65535>"); + reportError("Right X saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->rightSat.at(FFBConditionEffectParameters::Axis::Y), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Right Y saturation must be within <0; 65535>"); + reportError("Right Y saturation must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->leftCoeff.at(FFBConditionEffectParameters::Axis::X), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Left X coefficient must be within <-32767; 32767>"); + reportError("Left X coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->leftCoeff.at(FFBConditionEffectParameters::Axis::Y), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Left Y coefficient must be within <-32767; 32767>"); + reportError("Left Y coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->rightCoeff.at(FFBConditionEffectParameters::Axis::X), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Right X coefficient must be within <-32767; 32767>"); + reportError("Right X coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->rightCoeff.at(FFBConditionEffectParameters::Axis::Y), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Right Y coefficient must be within <-32767; 32767>"); + reportError("Right Y coefficient must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->deadband.at(FFBConditionEffectParameters::Axis::X), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Deadband X must be within <0; 65535>"); + reportError("Deadband X must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->deadband.at(FFBConditionEffectParameters::Axis::Y), 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Deadband Y must be within <0; 65535>"); + reportError("Deadband Y must be within <0; 65535>"); return false; } if (!checkBoundsInclusive(params->center.at(FFBConditionEffectParameters::Axis::X), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Center X must be within <-32767; 32767>"); + reportError("Center X must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->center.at(FFBConditionEffectParameters::Axis::Y), -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Center Y must be within <-32767; 32767>"); + reportError("Center Y must be within <-32767; 32767>"); return false; } diff --git a/sdl2ffbconstanteffect.cpp b/sdl2ffbconstanteffect.cpp index e913468..dc82be5 100644 --- a/sdl2ffbconstanteffect.cpp +++ b/sdl2ffbconstanteffect.cpp @@ -1,6 +1,5 @@ #include "sdl2ffbconstanteffect.h" #include "globalsettings.h" -#include SDL2FFBConstantEffect::SDL2FFBConstantEffect() : SDL2FFBEffect(FFBEffectTypes::CONSTANT) @@ -55,7 +54,7 @@ bool SDL2FFBConstantEffect::setParameters(const std::shared_ptrlevel, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Level parameters must be within <-32767; 32767>"); + reportError("Level parameters must be within <-32767; 32767>"); return false; } diff --git a/sdl2ffbeffect.cpp b/sdl2ffbeffect.cpp index c18955e..d3b04a2 100644 --- a/sdl2ffbeffect.cpp +++ b/sdl2ffbeffect.cpp @@ -1,6 +1,5 @@ #include "sdl2ffbeffect.h" #include "globalsettings.h" -#include SDL_HapticEffect* SDL2FFBEffect::createFFstruct() { @@ -19,22 +18,22 @@ bool SDL2FFBEffect::checkEnvelopeParameters(const int attackLength, const int at return true; if (!checkBoundsInclusive(attackLength, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Attack length must be within <0; 32767>"); + reportError("Attack length must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(attackLevel, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Attack level must be within <0; 32767>"); + reportError("Attack level must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(fadeLength, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Fade length must be within <0; 32767>"); + reportError("Fade length must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(fadeLevel, 0, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Fade level must be within <0; 32767>"); + reportError("Fade level must be within <0; 32767>"); return false; } @@ -47,17 +46,17 @@ bool SDL2FFBEffect::checkGenericParameters(const std::shared_ptrdirection, 0, 36000)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Direction must be within <0; 36000)"); + reportError("Direction must be within <0; 36000)"); return false; } if (!checkBoundsInclusive(params->replayLength, static_cast(0), static_cast(0x7FFF))) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Replay length must be within <0; 32767>"); + reportError("Replay length must be within <0; 32767>"); return false; } if (!checkBoundsInclusive(params->replayDelay, 0, 0xFFFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Replay delay must be within <0; 65535>"); + reportError("Replay delay must be within <0; 65535>"); return false; } diff --git a/sdl2ffbperiodiceffect.cpp b/sdl2ffbperiodiceffect.cpp index 1c1f100..73409cf 100644 --- a/sdl2ffbperiodiceffect.cpp +++ b/sdl2ffbperiodiceffect.cpp @@ -1,6 +1,5 @@ #include "sdl2ffbperiodiceffect.h" #include "globalsettings.h" -#include SDL2FFBPeriodicEffect::SDL2FFBPeriodicEffect() : SDL2FFBEffect(FFBEffectTypes::PERIODIC) @@ -75,28 +74,28 @@ bool SDL2FFBPeriodicEffect::setParameters(const std::shared_ptrperiod, 0, 36000)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Period must be within <0; 36000>"); + reportError("Period must be within <0; 36000>"); return false; } if (!checkBoundsInclusive(params->magnitude, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Magnitude must be within <-32767; 32767>"); + reportError("Magnitude must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->offset, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Offset must be within <-32767; 32767>"); + reportError("Offset must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->phase, 0, 36000)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Phase must be withing <0; 36000>"); + reportError("Phase must be withing <0; 36000>"); return false; } if (params->waveform == PeriodicWaveforms::NONE || params->waveform == PeriodicWaveforms::SQUARE) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Unsupported waveform"); + reportError("Invalid or unsupported waveform"); return false; } diff --git a/sdl2ffbrampeffect.cpp b/sdl2ffbrampeffect.cpp index 279b4ca..d5b4517 100644 --- a/sdl2ffbrampeffect.cpp +++ b/sdl2ffbrampeffect.cpp @@ -1,6 +1,5 @@ #include "sdl2ffbrampeffect.h" #include "globalsettings.h" -#include SDL2FFBRampEffect::SDL2FFBRampEffect() : SDL2FFBEffect(FFBEffectTypes::RAMP) @@ -58,12 +57,12 @@ bool SDL2FFBRampEffect::setParameters(const std::shared_ptrstartLevel, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "Start level must be within <-32767; 32767>"); + reportError("Start level must be within <-32767; 32767>"); return false; } if (!checkBoundsInclusive(params->endLevel, -0x7FFF, 0x7FFF)) { - QMessageBox::warning(nullptr, PRERR_CAPTION, "End level must be within <-32767; 32767>"); + reportError("End level must be within <-32767; 32767>"); return false; }