From b8e88aac56aa722b3b450ecc2099e986ec8fc4dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Tue, 8 Apr 2014 23:00:43 +0200 Subject: [PATCH] Do not cast rumble magnitudes to quint16 right away This makes checking the bounds possible. --- ffbrumbleeffect.cpp | 4 ++-- ffbrumbleeffectparameters.cpp | 2 +- ffbrumbleeffectparameters.h | 6 +++--- globals.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ffbrumbleeffect.cpp b/ffbrumbleeffect.cpp index 1eee734..8a1ab82 100644 --- a/ffbrumbleeffect.cpp +++ b/ffbrumbleeffect.cpp @@ -32,12 +32,12 @@ bool FFBRumbleEffect::setParameters(const std::shared_ptrstrongMagnitude, static_cast(0), static_cast(0xFFFF))) { + if (!checkBoundsInclusive(params->strongMagnitude, 0, 0xFFFF)) { reportError("Strong magnitude out of bounds"); return false; } - if (!checkBoundsInclusive(params->weakMagnitude, static_cast(0), static_cast(0xFFFF))) { + if (!checkBoundsInclusive(params->weakMagnitude, 0, 0xFFFF)) { reportError("Weak magnitude out of bounds"); return false; } diff --git a/ffbrumbleeffectparameters.cpp b/ffbrumbleeffectparameters.cpp index 5b5cb67..234759d 100644 --- a/ffbrumbleeffectparameters.cpp +++ b/ffbrumbleeffectparameters.cpp @@ -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); diff --git a/ffbrumbleeffectparameters.h b/ffbrumbleeffectparameters.h index f901c8e..6d8a7e3 100644 --- a/ffbrumbleeffectparameters.h +++ b/ffbrumbleeffectparameters.h @@ -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 diff --git a/globals.h b/globals.h index e2e2a63..4b91e7b 100644 --- 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 }; -- 2.43.5