]> Devoid-pointer.net GitWeb - FFBChecker.git/commitdiff
Fix condition effect parameters creation.
authorMichal Malý <madcatxster@prifuk.cz>
Tue, 10 Dec 2013 12:32:40 +0000 (13:32 +0100)
committerMichal Malý <madcatxster@prifuk.cz>
Tue, 10 Dec 2013 12:32:40 +0000 (13:32 +0100)
conditioneffectsettings.cpp
conditioneffectsettings.ui
ffbconditioneffect.cpp
ffbconditioneffectparameters.h
globals.h
mainwindow.cpp

index 15b458a618d1bf50a4f69ddaaba7768e791d1a98..8ec9540021f72f6c73973ec08e02d6cf2b9d683c 100644 (file)
@@ -8,6 +8,7 @@ ConditionEffectSettings::ConditionEffectSettings(QWidget* parent) :
 {
   ui->setupUi(this);
   connect(ui->cbox_axis, SIGNAL(currentIndexChanged(int)), this, SLOT(axisChanged(const int)));
+  axisChanged(ui->cbox_axis->currentIndex());
 }
 
 void ConditionEffectSettings::axisChanged(const int idx)
@@ -45,13 +46,14 @@ bool ConditionEffectSettings::fillFromParameters(const std::shared_ptr<FFBCondit
   ui->qle_leftCoeffX->setText(QString::number(cdParams->leftCoeff[FFBConditionEffectParameters::Axis::X]));
   ui->qle_rightCoeffX->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::X]));
   ui->qle_leftSatX->setText(QString::number(cdParams->leftSat[FFBConditionEffectParameters::Axis::X]));
-  ui->qle_rightSatX->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::X]));
+  ui->qle_rightSatX->setText(QString::number(cdParams->rightSat[FFBConditionEffectParameters::Axis::X]));
+
   ui->qle_centerY->setText(QString::number(cdParams->center[FFBConditionEffectParameters::Axis::Y]));
   ui->qle_deadbandY->setText(QString::number(cdParams->deadband[FFBConditionEffectParameters::Axis::Y]));
   ui->qle_leftCoeffY->setText(QString::number(cdParams->leftCoeff[FFBConditionEffectParameters::Axis::Y]));
   ui->qle_rightCoeffY->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::Y]));
   ui->qle_leftSatY->setText(QString::number(cdParams->leftSat[FFBConditionEffectParameters::Axis::Y]));
-  ui->qle_rightSatY->setText(QString::number(cdParams->rightCoeff[FFBConditionEffectParameters::Axis::Y]));
+  ui->qle_rightSatY->setText(QString::number(cdParams->rightSat[FFBConditionEffectParameters::Axis::Y]));
   return true;
 }
 
index 16c13442aa4e04bbfa2b691b8fd117d4a34fd683..2cf03036c3e730d486b4fcb978a65ca1f7866a64 100644 (file)
         </sizepolicy>
        </property>
        <property name="currentIndex">
-        <number>1</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="leftSatX">
         <layout class="QVBoxLayout" name="verticalLayout_2">
         </sizepolicy>
        </property>
        <property name="currentIndex">
-        <number>1</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="rightSatX">
         <layout class="QVBoxLayout" name="verticalLayout_4">
         </sizepolicy>
        </property>
        <property name="currentIndex">
-        <number>1</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="leftCoeffX">
         <layout class="QVBoxLayout" name="verticalLayout_6">
         </sizepolicy>
        </property>
        <property name="currentIndex">
-        <number>1</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="rightCoeffX">
         <layout class="QVBoxLayout" name="verticalLayout_8">
         </sizepolicy>
        </property>
        <property name="currentIndex">
-        <number>1</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="deadbandX">
         <layout class="QVBoxLayout" name="verticalLayout_10">
index a0dbf4f8c6aac558744c61714dd7836f2841a45f..56961c2cbb6e6478f545a8c383837c29f029710e 100644 (file)
@@ -49,7 +49,6 @@ bool FFBConditionEffect::setParameters(const std::shared_ptr<FFBEffectParameters
 {
   try {
     return setParameters(std::dynamic_pointer_cast<FFBConditionEffectParameters>(params));
-    //return setParameters(cdParams);
   } catch (const std::bad_cast& ex) {
     qCritical(ex.what());
     return false;
index 9e163352a9cae1b0845a5cb373139551d0ecfcde..d37b117ccfa48e3127f87b98b0708b398d6bfcda 100644 (file)
@@ -7,10 +7,7 @@
 class FFBConditionEffectParameters : public FFBEffectParameters
 {
 public:
-  enum class Axis : quint8 { NONE = 0, X = 1, Y = 2 };
-  struct Axis_less {
-    bool operator()(Axis a, Axis b) const { return quint8(a) == quint8(b); }
-  };
+  enum class Axis : quint8 { NONE, X, Y };
 
   FFBConditionEffectParameters();
   bool centerFromString(const QString& center, Axis a);
@@ -21,19 +18,14 @@ public:
   bool rightSatFromString(const QString& rightSat, Axis a);
   inline void subtypeFromIdx(const ConditionSubtypes subtype) { this->subtype = subtype; }
 
-  std::map<Axis, int, Axis_less> center;
-  std::map<Axis, int, Axis_less> deadband;
-  std::map<Axis, int, Axis_less> leftCoeff;
-  std::map<Axis, int, Axis_less> rightCoeff;
-  std::map<Axis, int, Axis_less> leftSat;
-  std::map<Axis, int, Axis_less> rightSat;
+  std::map<Axis, int> center;
+  std::map<Axis, int> deadband;
+  std::map<Axis, int> leftCoeff;
+  std::map<Axis, int> rightCoeff;
+  std::map<Axis, int> leftSat;
+  std::map<Axis, int> rightSat;
   ConditionSubtypes subtype;
 private:
-  inline bool qstringToInt(int& val, const QString& str) {
-    bool ok = false;
-    val = str.toInt(&ok);
-    return ok;
-  }
 };
 
 #endif // FFBCONDITIONEFFECTPARAMETERS_H
index 17604684bd1f676692c404789068fb8015997199..9dff3a3f337861846ddeff491564cfec0fa90811 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(2);
-static const char APP_VERSION_REL('b');
+static const char APP_VERSION_REL('c');
 
 enum class FFBEffectTypes { NONE, CONSTANT, PERIODIC, RAMP, CONDITION, RUMBLE};
 enum class PeriodicWaveforms { NONE, SQUARE, TRIANGLE, SINE, SAW_UP, SAW_DOWN };
index f5ae49c2974fdf85d14ef8a5d427505597c3569c..2869120c14353ebc485ace91cbf89a67ca416df3 100644 (file)
@@ -254,6 +254,7 @@ bool MainWindow::readEffectParameters(std::shared_ptr<FFBEffectParameters>& para
       std::shared_ptr<FFBConditionEffectParameters> iParams = std::shared_ptr<FFBConditionEffectParameters>(new FFBConditionEffectParameters);
       if (!readGeneralEffectParameters(iParams))
         return false;
+
       if (!iParams->centerFromString(m_conditionEffSet->centerX(), FFBConditionEffectParameters::Axis::X)) {
         QMessageBox::warning(this, res_inputFormatErrCap, "Invalid data in field \"Center\"");
         return false;