From 2229536858acf1b995ee23bb85196a870473d573 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 26 Sep 2014 23:57:41 +0200 Subject: freepie: try fix apk interop Maybe @KyokushinPL gets it to work now Issue: #48 --- .../ftnoir_tracker_freepie-udp.cpp | 28 ++++++++++++++++++---- .../ftnoir_tracker_freepie-udp.h | 3 ++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp index ea44133c..9fd9b08f 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -1,7 +1,6 @@ #include "ftnoir_tracker_freepie-udp.h" #include "facetracknoir/plugin-support.h" -#include #include TrackerImpl::TrackerImpl() : pose { 0,0,0, 0,0,0 }, should_quit(false) @@ -34,6 +33,15 @@ void TrackerImpl::run() { }; while (1) { + struct check { + union { + std::uint16_t half; + unsigned char bytes[2]; + }; + bool convertp; + check() : bytes { 255, 0 }, convertp(half > 255) {} + } crapola; + if (should_quit) break; { @@ -45,13 +53,14 @@ void TrackerImpl::run() { int sz = sock.readDatagram(reinterpret_cast(&data), sizeof(data)); int flags = data.flags & F::Mask; - - static constexpr int minsz = offsetof(decltype(data), raw_rot) + sizeof(decltype(data)::raw_rot); + + using t = decltype(data); + static constexpr int minsz = offsetof(t, raw_rot) + sizeof(t::raw_rot); const bool flags_came_out_wrong = minsz > sz; - + if (flags_came_out_wrong) flags &= ~F::flag_Raw; - + switch (flags) { case flag_Raw: @@ -66,6 +75,15 @@ void TrackerImpl::run() { } if (orient) { + if (crapola.convertp) + { + constexpr int sz = sizeof(float[6]); + const int len = sz / 2; + unsigned char* alias = reinterpret_cast(orient); + for (int i = 0; i < sz; i++) + alias[i] = alias[sz-i]; + } + QMutexLocker foo(&mtx); for (int i = 0; i < 3; i++) pose[Yaw + i] = orient[i]; diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h index 23f3ace9..de32e64b 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h @@ -5,9 +5,10 @@ * copyright notice and this permission notice appear in all copies. */ -#include "ui_freepie-udp-controls.h" +#include #include #include +#include "ui_freepie-udp-controls.h" #include "facetracknoir/plugin-api.hpp" #include "facetracknoir/options.h" using namespace options; -- cgit v1.2.3