From 58b8ac748e6c2b73864342c6b7fa4dad5d6efc91 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 28 Oct 2014 02:48:02 +0100 Subject: switch input axis for freepie-udp Issue: #90 Requested-by: @KyokushinPL --- ftnoir_tracker_freepie-udp/freepie-udp-controls.ui | 147 +++++++++++++++++---- .../ftnoir_tracker_freepie-udp.cpp | 24 +++- .../ftnoir_tracker_freepie-udp.h | 7 +- .../ftnoir_tracker_freepie-udp_dialog.cpp | 3 + 4 files changed, 147 insertions(+), 34 deletions(-) (limited to 'ftnoir_tracker_freepie-udp') diff --git a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui index 48290bf2..c0b1de8a 100644 --- a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui +++ b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui @@ -9,48 +9,141 @@ 0 0 - 198 - 71 + 302 + 231 - UDP tracker settings + Tracker settings ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - + + + + + QFrame::NoFrame - - UDP port + + QFrame::Raised + + + + + + 0 + 0 + + + + UDP port + + + + + + + 0 + + + 65535 + + + + - - - - 0 - - - 65535 + + + + Axis order + + + + + output yaw + + + + + + + + input yaw + + + + + input pitch + + + + + input roll + + + + + + + + + input yaw + + + + + input pitch + + + + + input roll + + + + + + + + output pitch + + + + + + + + input yaw + + + + + input pitch + + + + + input roll + + + + + + + + output roll + + + + - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp index eff1103b..6807419b 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -14,6 +14,16 @@ TrackerImpl::~TrackerImpl() wait(); } +template +static const t bound(t datum, t least, t max) +{ + if (datum < least) + return least; + if (datum > max) + return max; + return datum; +} + void TrackerImpl::run() { #pragma pack(push, 1) struct { @@ -29,10 +39,12 @@ void TrackerImpl::run() { Mask = flag_Raw | flag_Orient }; - while (1) { - if (should_quit) - break; - + while (!should_quit) { + int order[] = { + bound(s.idx_x, 0, 2), + bound(s.idx_y, 0, 2), + bound(s.idx_z, 0, 2) + }; float orient[3]; bool filled = false; @@ -67,7 +79,9 @@ void TrackerImpl::run() { QMutexLocker foo(&mtx); static constexpr double d2r = 57.295781; for (int i = 0; i < 3; i++) - pose[Yaw + i] = d2r * orient[i]; + { + pose[Yaw + i] = d2r * orient[order[i]]; + } } usleep(4000); } diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h index 0cec952f..2dfb4e8f 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h @@ -15,10 +15,13 @@ using namespace options; struct settings { pbundle b; - value port; + value port, idx_x, idx_y, idx_z; settings() : b(bundle("freepie-udp-tracker")), - port(b, "port", 4237) + port(b, "port", 4237), + idx_x(b, "axis-index-x", 0), + idx_y(b, "axis-index-y", 1), + idx_z(b, "axis-index-z", 2) {} }; diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp index ec95da90..4840a56b 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp @@ -9,6 +9,9 @@ TrackerDialog::TrackerDialog() connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); tie_setting(s.port, ui.port); + tie_setting(s.idx_x, ui.input_x); + tie_setting(s.idx_y, ui.input_y); + tie_setting(s.idx_z, ui.input_z); } void TrackerDialog::doOK() { -- cgit v1.2.3