]> Devoid-pointer.net GitWeb - FFBChecker.git/commitdiff
Generalize reporting of invalid effect parameters.
authorMichal Malý <madcatxster@devoid-pointer.net>
Sat, 1 Aug 2015 12:18:58 +0000 (14:18 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sat, 1 Aug 2015 12:18:58 +0000 (14:18 +0200)
15 files changed:
ffbeffect.cpp
ffbeffect.h
ffbnulleffect.h
linuxffbconditioneffect.cpp
linuxffbconstanteffect.cpp
linuxffbeffect.cpp
linuxffbeffect.h
linuxffbperiodiceffect.cpp
linuxffbrampeffect.cpp
linuxffbrumbleeffect.cpp
sdl2ffbconditioneffect.cpp
sdl2ffbconstanteffect.cpp
sdl2ffbeffect.cpp
sdl2ffbperiodiceffect.cpp
sdl2ffbrampeffect.cpp

index 4a693405ef2d139fc9b7a02bd82832f5f443a057..af448c888876d575902f42066624de784f67374d 100644 (file)
@@ -1,5 +1,6 @@
 #include "ffbeffect.h"
 #include "globalsettings.h"
+#include <QtWidgets/QMessageBox>
 
 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();
index 731333877c2974cc2dc81e76f4a1fa6d05e0b1cf..383252ca80058f1b789d0e56949b2a88a08d5b45 100644 (file)
@@ -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<FFBEffectParameters> params) = 0;
+  void reportError(const QString& errorMsg) const;
 
   static const QString PRERR_CAPTION;
 
index 2aa896c347af81ce7549a75b485680e05ad7e4b7..7410a177b18a52984617b47a5a7893943885d946 100644 (file)
@@ -11,6 +11,11 @@ public:
   inline bool setParameters(const std::shared_ptr<FFBEffectParameters> 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<FFBEffectParameters> params) { Q_UNUSED(params); return false; }
 };
 
index 9b3d5fd999b3c86cb1b8cf946aaf56401bf7801c..dfe6ebf0345caf28ece94fa80fa215810ad0f7d0 100644 (file)
@@ -58,68 +58,69 @@ bool LinuxFFBConditionEffect::setParameters(const std::shared_ptr<FFBEffectParam
 
 bool LinuxFFBConditionEffect::setParameters(const std::shared_ptr<FFBConditionEffectParameters> 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;
index 347d96f96836dbd770f744ce995cb80b5e7749f7..27205759b0651b9651ace93a5ffe572ec307f0b0 100644 (file)
@@ -34,30 +34,18 @@ bool LinuxFFBConstantEffect::setParameters(const std::shared_ptr<FFBEffectParame
 
 bool LinuxFFBConstantEffect::setParameters(const std::shared_ptr<FFBConstantEffectParameters> 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;
index 75a1b113cc63b94c0d727aaa177f2898641d6bbf..6d9e4d344a2acd0efc94ae5483021396a4476d27 100644 (file)
@@ -1,6 +1,5 @@
 #include "linuxffbeffect.h"
 #include "globalsettings.h"
-#include <QtWidgets/QMessageBox>
 
 LinuxFFBEffect::LinuxFFBEffect(FFBEffectTypes type) :
   FFBEffect(type)
@@ -21,9 +20,32 @@ struct ff_effect* LinuxFFBEffect::createFFStruct(const std::shared_ptr<FFBEffect
   return eff;
 }
 
-void LinuxFFBEffect::reportError(const QString& errorMsg) const
+bool LinuxFFBEffect::checkEnvelopeParameters(const int attackLength, const int attackLevel, const int fadeLength, const int fadeLevel)
 {
-  QMessageBox::warning(nullptr, "FFB effect error", errorMsg);
+  if (!GlobalSettings::GS()->doSanityChecks)
+    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<FFBEffectParameters> params)
@@ -37,17 +59,17 @@ bool LinuxFFBEffect::checkGenericParameters(const std::shared_ptr<FFBEffectParam
   }
 
   if (!checkBoundsInclusive(params->direction, 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<int64_t>(0), static_cast<int64_t>(0x7FFF))) {
-    reportError("Replay length out of bounds.");
+    reportError("Replay length must be within <0; 32767>");
     return false;
   }
 
index 3f830946b1b0a7cbad396f1a8ce5e730c717e30b..5bd70aae3fc8192e9c0477774586e2acdb5d275b 100644 (file)
@@ -13,8 +13,8 @@ public:
 
 protected:
   struct ff_effect* createFFStruct(const std::shared_ptr<FFBEffectParameters> params);
+  bool checkEnvelopeParameters(const int attackLength, const int attackLevel, const int fadeLength, const int fadeLevel);
   bool checkGenericParameters(const std::shared_ptr<FFBEffectParameters> params);
-  void reportError(const QString& errorMsg) const;
 
 private:
 
index 4602c9f640affb8349e82f5028f20bd698fb6bbf..2bf51ccbe6c54f4fd0b066cbb07fb3f3b5b48324 100644 (file)
@@ -60,54 +60,38 @@ bool LinuxFFBPeriodicEffect::setParameters(const std::shared_ptr<FFBEffectParame
 
 bool LinuxFFBPeriodicEffect::setParameters(const std::shared_ptr<FFBPeriodicEffectParameters> 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;
index f93cd5140fe1df742c12452614bf77012082645d..87dcaab6be5c74d1abf07bb558856a665004f246 100644 (file)
@@ -38,39 +38,23 @@ bool LinuxFFBRampEffect::setParameters(const std::shared_ptr<FFBEffectParameters
 
 bool LinuxFFBRampEffect::setParameters(const std::shared_ptr<FFBRampEffectParameters> 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;
index e6f58f4f589f9ca6f0bbe78896a6c8764feed23d..9ada1d7ca47bad62dbb510dbbe1b28c4cc6c45ca 100644 (file)
@@ -33,12 +33,12 @@ bool LinuxFFBRumbleEffect::setParameters(const std::shared_ptr<FFBRumbleEffectPa
     return false;
 
   if (!checkBoundsInclusive(params->strongMagnitude, 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;
   }
 
index d76f56b8aee4d4c12a586ec43ea8fcd8751d38c0..1702fbddcd481440d6b63d5d221fb73d56849835 100644 (file)
@@ -1,6 +1,5 @@
 #include "sdl2ffbconditioneffect.h"
 #include "globalsettings.h"
-#include <QtWidgets/QMessageBox>
 
 SDL2FFBConditionEffect::SDL2FFBConditionEffect() :
   SDL2FFBEffect(FFBEffectTypes::CONDITION)
@@ -73,62 +72,62 @@ bool SDL2FFBConditionEffect::setParameters(std::shared_ptr<FFBConditionEffectPar
     return false;
 
   if (!checkBoundsInclusive(params->leftSat.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;
   }
 
index e913468e5d3845b91ba77e3684f518bff026f6e1..dc82be5da12f11ec5f709571d84746b5f4b0c7ff 100644 (file)
@@ -1,6 +1,5 @@
 #include "sdl2ffbconstanteffect.h"
 #include "globalsettings.h"
-#include <QtWidgets/QMessageBox>
 
 SDL2FFBConstantEffect::SDL2FFBConstantEffect() :
   SDL2FFBEffect(FFBEffectTypes::CONSTANT)
@@ -55,7 +54,7 @@ bool SDL2FFBConstantEffect::setParameters(const std::shared_ptr<FFBConstantEffec
     return false;
 
   if (!checkBoundsInclusive(m_params->level, -0x7FFF, 0x7FFF)) {
-    QMessageBox::warning(nullptr, PRERR_CAPTION, "Level parameters must be within <-32767; 32767>");
+    reportError("Level parameters must be within <-32767; 32767>");
     return false;
   }
 
index c18955ece145934c99a8db239c57639f6e20c88e..d3b04a214f9b837d48587ec4d1a8f2e6aae55a6f 100644 (file)
@@ -1,6 +1,5 @@
 #include "sdl2ffbeffect.h"
 #include "globalsettings.h"
-#include <QtWidgets/QMessageBox>
 
 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_ptr<FFBEffectParame
     return true;
 
   if (!checkBoundsInclusive(params->direction, 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<int64_t>(0), static_cast<int64_t>(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;
   }
 
index 1c1f1005489fb6b26b4809d9afcec585a30e31a8..73409cfa722e1a003ef5c2b59c837a3d33133c44 100644 (file)
@@ -1,6 +1,5 @@
 #include "sdl2ffbperiodiceffect.h"
 #include "globalsettings.h"
-#include <QtWidgets/QMessageBox>
 
 SDL2FFBPeriodicEffect::SDL2FFBPeriodicEffect() :
   SDL2FFBEffect(FFBEffectTypes::PERIODIC)
@@ -75,28 +74,28 @@ bool SDL2FFBPeriodicEffect::setParameters(const std::shared_ptr<FFBPeriodicEffec
     return false;
 
   if (!checkBoundsInclusive(params->period, 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;
   }
 
index 279b4cae8c72ddcedc2f603a0f834648b8e4d474..d5b4517c6d2d2de96478d3ade7a76cf6289d7bf0 100644 (file)
@@ -1,6 +1,5 @@
 #include "sdl2ffbrampeffect.h"
 #include "globalsettings.h"
-#include <QtWidgets/QMessageBox>
 
 SDL2FFBRampEffect::SDL2FFBRampEffect() :
   SDL2FFBEffect(FFBEffectTypes::RAMP)
@@ -58,12 +57,12 @@ bool SDL2FFBRampEffect::setParameters(const std::shared_ptr<FFBRampEffectParamet
     return false;
 
   if (checkBoundsInclusive(params->startLevel, -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;
   }