rampeffectsettings.cpp \
ffbrampeffectparameters.cpp \
ffbrampeffect.cpp \
- globalsettings.cpp
+ globalsettings.cpp \
+ rumbleeffectsettings.cpp \
+ ffbrumbleeffectparameters.cpp \
+ ffbrumbleeffect.cpp
HEADERS += mainwindow.h \
deviceprober.h \
rampeffectsettings.h \
ffbrampeffectparameters.h \
ffbrampeffect.h \
- globalsettings.h
+ globalsettings.h \
+ rumbleeffectsettings.h \
+ ffbrumbleeffectparameters.h \
+ ffbrumbleeffect.h
FORMS += mainwindow.ui \
constanteffectsettings.ui \
envelopesettings.ui \
periodiceffectsettings.ui \
conditioneffectsettings.ui \
- rampeffectsettings.ui
+ rampeffectsettings.ui \
+ rumbleeffectsettings.ui
QMAKE_CXXFLAGS += -std=c++11 -Wall
QMAKE_CXXFLAGS_DEBUG += -ggdb3
{
Q_OBJECT
public:
- explicit EffectSettings(QWidget* parent = 0);
+ explicit EffectSettings(QWidget* parent = nullptr);
virtual bool fillFromParameters(const std::shared_ptr<FFBEffectParameters> params) = 0;
signals:
if (testBit(FF_SPRING, caps) || testBit(FF_FRICTION, caps) ||
testBit(FF_DAMPER, caps) || testBit(FF_INERTIA, caps))
m_availableEffects.push_back(FFBEffectTypes::CONDITION);
+ if (testBit(FF_RUMBLE, caps))
+ m_availableEffects.push_back(FFBEffectTypes::RUMBLE);
/* Query waveforms for PERIODIC if the device supports it */
if (hasEffect(FFBEffectTypes::PERIODIC)) {
return std::shared_ptr<FFBEffect>(new FFBConditionEffect());
case FFBEffectTypes::RAMP:
return std::shared_ptr<FFBEffect>(new FFBRampEffect());
+ case FFBEffectTypes::RUMBLE:
+ return std::shared_ptr<FFBEffect>(new FFBRumbleEffect());
default:
return nullptr;
}
#include "ffbnulleffect.h"
#include "ffbperiodiceffect.h"
#include "ffbrampeffect.h"
+#include "ffbrumbleeffect.h"
class FFBEffectFactory
{
--- /dev/null
+#include "ffbrumbleeffect.h"
+
+FFBRumbleEffect::FFBRumbleEffect() :
+ FFBEffect(FFBEffectTypes::RUMBLE)
+{
+}
+
+struct ff_effect* FFBRumbleEffect::createFFStruct()
+{
+ struct ff_effect* eff = FFBEffect::createFFStruct(m_params);
+
+ eff->type = FF_RUMBLE;
+
+ eff->u.rumble.strong_magnitude = m_params->strongMagnitude;
+ eff->u.rumble.weak_magnitude = m_params->weakMagnitude;
+
+ return eff;
+}
+
+bool FFBRumbleEffect::setParameters(const std::shared_ptr<FFBEffectParameters> params)
+{
+ try {
+ return setParameters(std::dynamic_pointer_cast<FFBRumbleEffectParameters>(params));
+ } catch (std::bad_cast& ex) {
+ reportError("Invalid effect parameters object " + QString(ex.what()));
+ return false;
+ }
+}
+
+bool FFBRumbleEffect::setParameters(const std::shared_ptr<FFBRumbleEffectParameters> params)
+{
+ if (!checkGenericParameters(params))
+ return false;
+
+ if (!checkBoundsInclusive(params->strongMagnitude, static_cast<quint16>(0), static_cast<quint16>(0xFFFF))) {
+ reportError("Strong magnitude out of bounds");
+ return false;
+ }
+
+ if (!checkBoundsInclusive(params->weakMagnitude, static_cast<quint16>(0), static_cast<quint16>(0xFFFF))) {
+ reportError("Weak magnitude out of bounds");
+ return false;
+ }
+
+ m_params = params;
+ return true;
+}
--- /dev/null
+#ifndef FFBRUMBLEEFFECT_H
+#define FFBRUMBLEEFFECT_H
+
+#include "ffbeffect.h"
+#include "ffbrumbleeffectparameters.h"
+
+class FFBRumbleEffect : public FFBEffect
+{
+public:
+ FFBRumbleEffect();
+ struct ff_effect* createFFStruct();
+ inline const std::shared_ptr<FFBEffectParameters> parameters() const { return m_params; }
+ bool setParameters(const std::shared_ptr<FFBEffectParameters> params);
+ bool setParameters(const std::shared_ptr<FFBRumbleEffectParameters> params);
+
+private:
+ std::shared_ptr<FFBRumbleEffectParameters> m_params;
+};
+
+#endif // FFBRUMBLEEFFECT_H
--- /dev/null
+#include "ffbrumbleeffectparameters.h"
+
+FFBRumbleEffectParameters::FFBRumbleEffectParameters()
+{
+}
+
+bool FFBRumbleEffectParameters::strongMagnitudeFromString(const QString& strong)
+{
+ return magnitudeFromString(strong, strongMagnitude);
+}
+
+bool FFBRumbleEffectParameters::weakMagnitudeFromString(const QString& weak)
+{
+ return magnitudeFromString(weak, weakMagnitude);
+}
+
+bool FFBRumbleEffectParameters::magnitudeFromString(const QString& str, quint16& val)
+{
+ bool ok;
+ val = str.toInt(&ok);
+
+ return ok;
+}
--- /dev/null
+#ifndef FFBRUMBLEEFFECTPARAMETERS_H
+#define FFBRUMBLEEFFECTPARAMETERS_H
+
+#include "ffbeffectparameters.h"
+
+class FFBRumbleEffectParameters : public FFBEffectParameters
+{
+public:
+ FFBRumbleEffectParameters();
+ bool strongMagnitudeFromString(const QString& strong);
+ bool weakMagnitudeFromString(const QString& weak);
+
+ quint16 strongMagnitude;
+ quint16 weakMagnitude;
+
+private:
+ bool magnitudeFromString(const QString& str, quint16& val);
+};
+
+#endif // FFBRUMBLEEFFECTPARAMETERS_H
#define APP_NAME "FFBChecker"
static const int APP_VERSION_MAJOR(0);
-static const int APP_VERSION_MINOR(2);
-static const char APP_VERSION_REL('d');
+static const int APP_VERSION_MINOR(3);
+static const char APP_VERSION_REL('a');
-enum class FFBEffectTypes { NONE, CONSTANT, PERIODIC, RAMP, CONDITION, RUMBLE};
+enum class FFBEffectTypes { NONE, CONSTANT, PERIODIC, RAMP, CONDITION, RUMBLE };
enum class PeriodicWaveforms { NONE, SQUARE, TRIANGLE, SINE, SAW_UP, SAW_DOWN };
enum class ConditionSubtypes { NONE, SPRING, FRICTION, DAMPER, INERTIA };
m_periodicEffSet = new PeriodicEffectSettings();
m_conditionEffSet = new ConditionEffectSettings();
m_rampEffSet = new RampEffectSettings();
+ m_rumbleEffSet = new RumbleEffectSettings();
ui->qstw_effectSpecifics->addWidget(m_conditionEffSet);
ui->qstw_effectSpecifics->addWidget(m_constantEffSet);
ui->qstw_effectSpecifics->addWidget(m_periodicEffSet);
ui->qstw_effectSpecifics->addWidget(m_rampEffSet);
+ ui->qstw_effectSpecifics->addWidget(m_rumbleEffSet);
if (GlobalSettings::GS()->doSanityChecks)
ui->ql_noChecksWarning->setHidden(true);
return m_conditionEffSet;
case FFBEffectTypes::RAMP:
return m_rampEffSet;
+ case FFBEffectTypes::RUMBLE:
+ return m_rumbleEffSet;
default:
abort();
}
params = iParams;
break;
}
+ case FFBEffectTypes::RUMBLE: {
+ std::shared_ptr<FFBRumbleEffectParameters> iParams(new FFBRumbleEffectParameters());
+ if (!readGeneralEffectParameters(iParams))
+ return false;
+
+ if (!iParams->strongMagnitudeFromString(m_rumbleEffSet->strongMagnitude())) {
+ QMessageBox::warning(this, res_inputFormatErrCap, "Invalid data in field \"Strong magnitude\"");
+ return false;
+ }
+ if (!iParams->weakMagnitudeFromString(m_rumbleEffSet->weakMagnitude())) {
+ QMessageBox::warning(this, res_inputFormatErrCap, "Invalid data in field \"Weak magnitude\"");
+ return false;
+ }
+
+ params = iParams;
+ break;
+ }
default:
qDebug() << "Unhandled type of effect";
return false;
#include "ffbdevice.h"
#include "ffbperiodiceffectparameters.h"
#include "ffbrampeffectparameters.h"
+#include "ffbrumbleeffectparameters.h"
#include "periodiceffectsettings.h"
#include "rampeffectsettings.h"
+#include "rumbleeffectsettings.h"
#include <memory>
#include <QMainWindow>
ConstantEffectSettings* m_constantEffSet;
PeriodicEffectSettings* m_periodicEffSet;
RampEffectSettings* m_rampEffSet;
+ RumbleEffectSettings* m_rumbleEffSet;
std::shared_ptr<DeviceProber> m_prober;
Ui::MainWindow* ui;
#include "effectsettings.h"
#include "envelopesettings.h"
-#include"ffbrampeffectparameters.h"
+#include "ffbrampeffectparameters.h"
namespace Ui {
class RampEffectSettings;
--- /dev/null
+#include "rumbleeffectsettings.h"
+#include "ui_rumbleeffectsettings.h"
+
+RumbleEffectSettings::RumbleEffectSettings(QWidget* parent) :
+ EffectSettings(parent),
+ ui(new Ui::RumbleEffectSettings)
+{
+ ui->setupUi(this);
+}
+
+bool RumbleEffectSettings::fillFromParameters(const std::shared_ptr<FFBEffectParameters> params)
+{
+ try {
+ const std::shared_ptr<FFBRumbleEffectParameters> ruParams = std::dynamic_pointer_cast<FFBRumbleEffectParameters>(params);
+
+ ui->qle_strongMag->setText(QString::number(ruParams->strongMagnitude));
+ ui->qle_weakMag->setText(QString::number(ruParams->weakMagnitude));
+ return true;
+ } catch (std::bad_cast& ex) {
+ qCritical(ex.what());
+ return false;
+ }
+ return false;
+}
+
+QString RumbleEffectSettings::strongMagnitude() const
+{
+ return ui->qle_strongMag->text();
+}
+
+QString RumbleEffectSettings::weakMagnitude() const
+{
+ return ui->qle_weakMag->text();
+}
+
+RumbleEffectSettings::~RumbleEffectSettings()
+{
+ delete ui;
+}
--- /dev/null
+#ifndef RUMBLEEFFECTSETTINGS_H
+#define RUMBLEEFFECTSETTINGS_H
+
+#include "effectsettings.h"
+#include "envelopesettings.h"
+#include "ffbrumbleeffectparameters.h"
+
+namespace Ui {
+class RumbleEffectSettings;
+}
+
+class RumbleEffectSettings : public EffectSettings
+{
+ Q_OBJECT
+
+public:
+ explicit RumbleEffectSettings(QWidget* parent = nullptr);
+ ~RumbleEffectSettings();
+ bool fillFromParameters(const std::shared_ptr<FFBEffectParameters> params);
+ QString strongMagnitude() const;
+ QString weakMagnitude() const;
+
+private:
+ Ui::RumbleEffectSettings *ui;
+};
+
+#endif // RUMBLEEFFECTSETTINGS_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RumbleEffectSettings</class>
+ <widget class="QWidget" name="RumbleEffectSettings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>338</width>
+ <height>234</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="ql_strongMag">
+ <property name="text">
+ <string>Strong magnitude:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="ql_weakMag">
+ <property name="text">
+ <string>Weak magnitude:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="qle_strongMag">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="qle_weakMag">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>