summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-10-24 21:28:34 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-10-24 21:28:34 +0200
commitf40d7a58d0032289e6c122bbd57bc8b6bed8ebcd (patch)
tree12850e810274f208f7c7643017dfdb5d4995558a
parenta19d4fc2ec4ef759cae00505038c02c684c4106b (diff)
actually finish the joystick impl
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp11
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick.h5
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui14
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp8
4 files changed, 24 insertions, 14 deletions
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
index 73993999..35d3927f 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
@@ -198,6 +198,15 @@ start:
js.rglSlider[1]
};
+ const double max[] = {
+ 100,
+ 100,
+ 100,
+ 180,
+ 90,
+ 180
+ };
+
for (int i = 0; i < 6; i++)
{
auto idx = axes[i] - 1;
@@ -206,7 +215,7 @@ start:
data[i] = 0;
}
else {
- data[i] = values[i] / (double) AXIS_MAX;
+ data[i] = values[i] * max[i] / (double) AXIS_MAX;
}
}
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h
index 0d27a752..72471f3f 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h
@@ -70,11 +70,10 @@ public:
tracker = NULL;
}
QList<GUID> guids;
-private:
Ui::UIJoystickControls ui;
- void loadSettings();
+ void loadSettings();
void save();
- bool settingsDirty;
+ bool settingsDirty;
FTNoIR_Tracker* tracker;
private slots:
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui
index 038e5925..a19a3cad 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>188</width>
+ <width>216</width>
<height>259</height>
</rect>
</property>
@@ -398,12 +398,12 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QSpinBox" name="spinBox">
- <property name="prefix">
- <string>Joy </string>
- </property>
- <property name="maximum">
- <number>32</number>
+ <widget class="QComboBox" name="joylist">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
</widget>
</item>
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp
index 5be36879..80431b99 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp
@@ -6,12 +6,13 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance
auto self = ( TrackerControls* )pContext;
self->guids.push_back(pdidInstance->guidInstance);
+ self->ui.joylist->addItem(QString(pdidInstance->tszInstanceName));
return DIENUM_CONTINUE;
}
TrackerControls::TrackerControls() :
-QWidget()
+ QWidget(), tracker(nullptr), settingsDirty(false)
{
ui.setupUi( this );
@@ -19,7 +20,7 @@ QWidget()
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.spinBox, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.joylist, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
connect(ui.comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
connect(ui.comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
@@ -118,7 +119,7 @@ void TrackerControls::loadSettings() {
{
boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt());
}
- ui.spinBox->setValue(iniFile.value("joyid", -1).toInt());
+ ui.joylist->setCurrentIndex(iniFile.value("joyid", -1).toInt());
iniFile.endGroup ();
settingsDirty = false;
@@ -144,6 +145,7 @@ void TrackerControls::save() {
{
iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex());
}
+ iniFile.setValue("joyid", ui.joylist->currentIndex());
iniFile.endGroup ();
if(tracker)