diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-06-06 14:03:36 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-06-06 14:03:36 +0200 |
commit | 69a8c9eba04eb1d955c5c0ebb1df0cd4ea217930 (patch) | |
tree | 93f125816574d5b9c006a5508d52f15d2a01c356 /ftnoir_tracker_udp | |
parent | 793183469d2c02e59ee91a072b8f59153870415c (diff) |
udp tracker: allow for adding +-90/+-180 to each axis
Follows similar code in freepie-udp tracker. Helps with centering on
inertial devices.
Diffstat (limited to 'ftnoir_tracker_udp')
-rw-r--r-- | ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 178 | ||||
-rw-r--r-- | ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 24 | ||||
-rw-r--r-- | ftnoir_tracker_udp/ftnoir_tracker_udp.h | 6 | ||||
-rw-r--r-- | ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 3 |
4 files changed, 189 insertions, 22 deletions
diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index 4a5624cf..cb9362ca 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>216</width> - <height>71</height> + <width>195</width> + <height>224</height> </rect> </property> <property name="windowTitle"> @@ -26,25 +26,170 @@ <property name="autoFillBackground"> <bool>false</bool> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Port</string> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> + <property name="title"> + <string/> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Port</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="spinPortNumber"> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>65535</number> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="spinPortNumber"> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>65535</number> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Add to axis</string> </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>yaw</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="add_yaw"> + <item> + <property name="text"> + <string>0</string> + </property> + </item> + <item> + <property name="text"> + <string>+90</string> + </property> + </item> + <item> + <property name="text"> + <string>-90</string> + </property> + </item> + <item> + <property name="text"> + <string>+180</string> + </property> + </item> + <item> + <property name="text"> + <string>-180</string> + </property> + </item> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>pitch</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>roll</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="add_pitch"> + <item> + <property name="text"> + <string>0</string> + </property> + </item> + <item> + <property name="text"> + <string>+90</string> + </property> + </item> + <item> + <property name="text"> + <string>-90</string> + </property> + </item> + <item> + <property name="text"> + <string>+180</string> + </property> + </item> + <item> + <property name="text"> + <string>-180</string> + </property> + </item> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="add_roll"> + <item> + <property name="text"> + <string>0</string> + </property> + </item> + <item> + <property name="text"> + <string>+90</string> + </property> + </item> + <item> + <property name="text"> + <string>-90</string> + </property> + </item> + <item> + <property name="text"> + <string>+180</string> + </property> + </item> + <item> + <property name="text"> + <string>-180</string> + </property> + </item> + </widget> + </item> + </layout> </widget> </item> - <item row="1" column="1"> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> <widget class="QDialogButtonBox" name="buttonBox"> <property name="standardButtons"> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> @@ -53,9 +198,6 @@ </item> </layout> </widget> - <tabstops> - <tabstop>spinPortNumber</tabstop> - </tabstops> <resources/> <connections/> <slots> diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index c900fb67..ab8c8c86 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -16,9 +16,11 @@ void FTNoIR_Tracker::run() { for (;;) { if (should_quit) break; - QMutexLocker foo(&mutex); - while (sock.hasPendingDatagrams()) { - sock.readDatagram((char * ) last_recv_pose, sizeof(double[6])); + { + QMutexLocker foo(&mutex); + while (sock.hasPendingDatagrams()) { + sock.readDatagram((char * ) last_recv_pose, sizeof(double[6])); + } } msleep(1); } @@ -34,6 +36,22 @@ void FTNoIR_Tracker::data(double *data) QMutexLocker foo(&mutex); for (int i = 0; i < 6; i++) data[i] = last_recv_pose[i]; + + int values[] = { + 0, + 90, + -90, + 180, + -180, + }; + int indices[] = { + s.add_yaw, + s.add_pitch, + s.add_roll, + }; + + for (int i = 0; i < 3; i++) + data[Yaw + i] += values[indices[i]]; } extern "C" OPENTRACK_EXPORT ITracker* GetConstructor() diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 51b5d9ab..160e4352 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -9,9 +9,13 @@ using namespace options; struct settings : opts { value<int> port; + value<int> add_yaw, add_pitch, add_roll; settings() : opts("udp-tracker"), - port(b, "port", 4242) + port(b, "port", 4242), + add_yaw(b, "add-yaw", 0), + add_pitch(b, "add-pitch", 0), + add_roll(b, "add-roll", 0) {} }; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index eb5abcd8..bab88db0 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -9,6 +9,9 @@ TrackerControls::TrackerControls() connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); tie_setting(s.port, ui.spinPortNumber); + tie_setting(s.add_yaw, ui.add_yaw); + tie_setting(s.add_pitch, ui.add_pitch); + tie_setting(s.add_roll, ui.add_roll); } void TrackerControls::doOK() { |