]> Devoid-pointer.net GitWeb - FFBChecker.git/commitdiff
Do not cast rumble magnitudes to quint16 right away
authorMichal Malý <madcatxster@devoid-pointer.net>
Tue, 8 Apr 2014 21:00:43 +0000 (23:00 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Tue, 8 Apr 2014 21:00:43 +0000 (23:00 +0200)
This makes checking the bounds possible.

ffbrumbleeffect.cpp
ffbrumbleeffectparameters.cpp
ffbrumbleeffectparameters.h
globals.h

index 1eee73431c486603403e4cce7b33715f5adcf279..8a1ab82eed38139082712c0fa3a9c1bef6f4208d 100644 (file)
@@ -32,12 +32,12 @@ bool FFBRumbleEffect::setParameters(const std::shared_ptr<FFBRumbleEffectParamet
   if (!checkGenericParameters(params))
     return false;
 
-  if (!checkBoundsInclusive(params->strongMagnitude, static_cast<quint16>(0), static_cast<quint16>(0xFFFF))) {
+  if (!checkBoundsInclusive(params->strongMagnitude, 0, 0xFFFF)) {
     reportError("Strong magnitude out of bounds");
     return false;
   }
 
-  if (!checkBoundsInclusive(params->weakMagnitude, static_cast<quint16>(0), static_cast<quint16>(0xFFFF))) {
+  if (!checkBoundsInclusive(params->weakMagnitude, 0, 0xFFFF)) {
     reportError("Weak magnitude out of bounds");
     return false;
   }
index 5b5cb6788747431b3d91ca18a4c9d6c594c8d073..234759d8674dcf46eda946a37770885dbaa8ee35 100644 (file)
@@ -14,7 +14,7 @@ bool FFBRumbleEffectParameters::weakMagnitudeFromString(const QString& weak)
   return magnitudeFromString(weak, weakMagnitude);
 }
 
-bool FFBRumbleEffectParameters::magnitudeFromString(const QString& str, quint16& val)
+bool FFBRumbleEffectParameters::magnitudeFromString(const QString& str, int& val)
 {
   bool ok;
   val = str.toInt(&ok);
index f901c8e4cbd33395b774b8a18828b50caf1b783c..6d8a7e37e711c160f2b22916c59dd3833f7c1054 100644 (file)
@@ -10,11 +10,11 @@ public:
   bool strongMagnitudeFromString(const QString& strong);
   bool weakMagnitudeFromString(const QString& weak);
 
-  quint16 strongMagnitude;
-  quint16 weakMagnitude;
+  int strongMagnitude;
+  int weakMagnitude;
 
 private:
-  bool magnitudeFromString(const QString& str, quint16& val);
+  bool magnitudeFromString(const QString& str, int& val);
 };
 
 #endif // FFBRUMBLEEFFECTPARAMETERS_H
index e2e2a63b65cc496c47828ee1b16e62a4b87edaff..4b91e7b1f785ea0cd48293b3f1eb121065bed1dd 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -4,7 +4,7 @@
 #define APP_NAME "FFBChecker"
 static const int APP_VERSION_MAJOR(0);
 static const int APP_VERSION_MINOR(3);
-static const char APP_VERSION_REL('a');
+static const char APP_VERSION_REL('b');
 
 enum class FFBEffectTypes { NONE, CONSTANT, PERIODIC, RAMP, CONDITION, RUMBLE };
 enum class PeriodicWaveforms { NONE, SQUARE, TRIANGLE, SINE, SAW_UP, SAW_DOWN };