From 59144a96bf9e3391a32b9ad8f5240f02acb3f44a Mon Sep 17 00:00:00 2001 From: Ennio Barbaro Date: Thu, 2 Jul 2015 22:08:40 +0200 Subject: Use XPLMRegisterFlightLoopCallback instead of XPLMRegisterDrawCallback --- CMakeLists.txt | 4 ++-- x-plane-plugin/plugin.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ec6dc54..4fb6e8d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,13 +199,13 @@ if(SDK_XPLANE) SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" - COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM210" + COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM200 -DXPLM210" LIBRARY_OUTPUT_NAME "opentrack.xpl" PREFIX "" SUFFIX "") endif() if(APPLE) SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES - COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM210 -framework XPLM -framework XPWidgets" + COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets" LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") endif() if(UNIX AND NOT APPLE) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 3958c895..eed3c774 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -8,9 +8,7 @@ #include #include -#include #include -#include #include #ifndef PLUGIN_API @@ -87,10 +85,11 @@ void PortableLockedShm_unlock(PortableLockedShm* self) flock(self->fd, LOCK_UN); } -int write_head_position( - XPLMDrawingPhase OT_UNUSED(inPhase), - int OT_UNUSED(inIsBefore), - void * OT_UNUSED(inRefcon)) +float write_head_position( + float OT_UNUSED(inElapsedSinceLastCall), + float OT_UNUSED(inElapsedTimeSinceLastFlightLoop), + int OT_UNUSED(inCounter), + void * OT_UNUSED(inRefcon) ) { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); @@ -101,7 +100,7 @@ int write_head_position( XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / 3.141592654); PortableLockedShm_unlock(lck_posix); } - return 1; + return -1.0; } PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDescription ) { @@ -137,11 +136,11 @@ PLUGIN_API void XPluginStop ( void ) { } PLUGIN_API void XPluginEnable ( void ) { - XPLMRegisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); + XPLMRegisterFlightLoopCallback(write_head_position, -1.0, NULL); } PLUGIN_API void XPluginDisable ( void ) { - XPLMUnregisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); + XPLMUnregisterFlightLoopCallback(write_head_position, NULL); } PLUGIN_API void XPluginReceiveMessage( -- cgit v1.2.3 From 1e1e4d6bf51805c30feee39083a1ee79f09f8641 Mon Sep 17 00:00:00 2001 From: Ennio Barbaro Date: Thu, 2 Jul 2015 22:12:55 +0200 Subject: Added enable/disable plugin command. --- x-plane-plugin/plugin.c | 58 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index eed3c774..1643fc9c 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifndef PLUGIN_API #define PLUGIN_API @@ -39,6 +40,9 @@ static PortableLockedShm* lck_posix = NULL; static WineSHM* shm_posix = NULL; static void *view_x, *view_y, *view_z, *view_heading, *view_pitch; static float offset_x, offset_y, offset_z; +static XPLMCommandRef track_toggle = NULL, translation_disable_toggle = NULL; +static int track_disabled = 1; +static int translation_disabled; static void reinit_offset() { offset_x = XPLMGetDataf(view_x); @@ -93,9 +97,12 @@ float write_head_position( { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); - XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3 + offset_x); - XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3 + offset_y); - XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3 + offset_z); + if (!translation_disabled) + { + XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3 + offset_x); + XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3 + offset_y); + XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3 + offset_z); + } XPLMSetDataf(view_heading, shm_posix->data[Yaw] * 180 / 3.141592654); XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / 3.141592654); PortableLockedShm_unlock(lck_posix); @@ -103,13 +110,54 @@ float write_head_position( return -1.0; } +static int TrackToggleHandler( XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void * inRefCon ) +{ + if ( track_disabled ) + { + //Enable + XPLMRegisterFlightLoopCallback(write_head_position, -1.0, NULL); + } + else + { + //Disable + XPLMUnregisterFlightLoopCallback(write_head_position, NULL); + } + track_disabled = !track_disabled; + return 0; +} + +static int TranslationToggleHandler( XPLMCommandRef inCommand, + XPLMCommandPhase inPhase, + void * inRefCon ) +{ + translation_disabled = !translation_disabled; + return 0; +} + PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDescription ) { view_x = XPLMFindDataRef("sim/aircraft/view/acf_peX"); view_y = XPLMFindDataRef("sim/aircraft/view/acf_peY"); view_z = XPLMFindDataRef("sim/aircraft/view/acf_peZ"); view_heading = XPLMFindDataRef("sim/graphics/view/pilots_head_psi"); view_pitch = XPLMFindDataRef("sim/graphics/view/pilots_head_the"); - if (view_x && view_y && view_z && view_heading && view_pitch) { + + track_toggle = XPLMCreateCommand("opentrack/toggle", "Disable/Enable head tracking"); + translation_disable_toggle = XPLMCreateCommand("opentrack/toggle_translation", "Disable/Enable input translation from opentrack"); + + XPLMRegisterCommandHandler( track_toggle, + TrackToggleHandler, + 1, + (void*)0); + + XPLMRegisterCommandHandler( translation_disable_toggle, + TranslationToggleHandler, + 1, + (void*)0); + + + if (view_x && view_y && view_z && view_heading && view_pitch && track_toggle && translation_disable_toggle) { lck_posix = PortableLockedShm_init(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); if (lck_posix->mem == (void*)-1) { fprintf(stderr, "opentrack failed to init SHM!\n"); @@ -137,10 +185,12 @@ PLUGIN_API void XPluginStop ( void ) { PLUGIN_API void XPluginEnable ( void ) { XPLMRegisterFlightLoopCallback(write_head_position, -1.0, NULL); + track_disabled = 0; } PLUGIN_API void XPluginDisable ( void ) { XPLMUnregisterFlightLoopCallback(write_head_position, NULL); + track_disabled = 1; } PLUGIN_API void XPluginReceiveMessage( -- cgit v1.2.3 From 67d5b4a3fe4ea89aed3a7a674958c043eb25079d Mon Sep 17 00:00:00 2001 From: Ennio Barbaro Date: Thu, 2 Jul 2015 23:14:45 +0200 Subject: Reinit the offsets when re-enabling the plugin --- x-plane-plugin/plugin.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 1643fc9c..999f6e15 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -118,6 +118,10 @@ static int TrackToggleHandler( XPLMCommandRef inCommand, { //Enable XPLMRegisterFlightLoopCallback(write_head_position, -1.0, NULL); + + // Reinit the offsets when we re-enable the plugin + if ( !translation_disabled ) + reinit_offset(); } else { @@ -133,6 +137,11 @@ static int TranslationToggleHandler( XPLMCommandRef inCommand, void * inRefCon ) { translation_disabled = !translation_disabled; + if (!translation_disabled) + { + // Reinit the offsets when we re-enable the translations so that we can "move around" + reinit_offset(); + } return 0; } -- cgit v1.2.3 From 44d0136cb4b532c957d6c037ea6a862a1e371cd9 Mon Sep 17 00:00:00 2001 From: Ennio Barbaro Date: Thu, 2 Jul 2015 23:24:52 +0200 Subject: Fixed bug crash if dlopen fails --- opentrack/plugin-support.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index bc07c106..95b4b0a1 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -115,7 +115,8 @@ struct dylib { { fprintf(stderr, "Error, ignoring: %s\n", err); fflush(stderr); - dlclose(handle); + if (handle) + dlclose(handle); handle = nullptr; return true; } @@ -138,6 +139,7 @@ struct dylib { return; } else { (void) _foo::err(handle); + return; } #endif -- cgit v1.2.3 From 54dd13ffc6c16a149a55c75ce3dd3724fc8684b4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jul 2015 07:57:44 +0200 Subject: accela: start with zero gain --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 5a042f81..4546cd78 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -20,7 +20,7 @@ static constexpr double rot_gains[][2] = { { 3, 5 }, { 2, 1.4 }, { 1, .4 }, - { 0, .2 }, + { 0, 0 }, { -1, 0 } }; static constexpr double trans_gains[][2] = { @@ -29,7 +29,7 @@ static constexpr double trans_gains[][2] = { { 3, 20 }, { 2, 5 }, { 1, .7 }, - { 0, .1 }, + { 0, 0 }, { -1, 0 } }; -- cgit v1.2.3 From 340906d3571ba3c75e67d8457de4129381d5a6b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jul 2015 11:58:04 +0200 Subject: try fix MSVC --- CMakeLists.txt | 15 ++++++++++++--- facetracknoir/main.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 4 +++- ftnoir_tracker_aruco/include/exports.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 1 - ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 4 +++- opentrack/export.hpp | 8 +++++++- opentrack/plugin-support.hpp | 2 +- 9 files changed, 29 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fb6e8d2..4389432d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,10 @@ find_package(Qt5 COMPONENTS SerialPort QUIET) include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) +if(MSVC) + add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) +endif() + set(my-qt-deps) if(WIN32) # hack to avoid breakage on buildbot set(my-qt-deps ws2_32) @@ -71,6 +75,9 @@ set(EXTRA-MOCS opentrack/options.hpp) macro(opentrack_module n dir) file(GLOB ${n}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp ${EXTRA-MOCS}) file(GLOB ${n}-res ${dir}/*.rc) + foreach(f ${n}-res) + set_source_files_properties(${f} PROPERTIES LANGUAGE RC) + endforeach() file(GLOB ${n}-ui ${dir}/*.ui) file(GLOB ${n}-rc ${dir}/*.qrc) endmacro() @@ -78,7 +85,7 @@ endmacro() macro(opentrack_qt n) qt5_wrap_cpp(${n}-moc ${${n}-c} OPTIONS --no-notes) QT5_WRAP_UI(${n}-uih ${${n}-ui}) - QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) + QT5_ADD_RESOURCES(${n}-rcc) set(${n}-all ${${n}-c} ${${n}-rc} ${${n}-rcc} ${${n}-uih} ${${n}-moc} ${${n}-res}) endmacro() @@ -97,7 +104,7 @@ macro(opentrack_library n dir) COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" ) else() - set_target_properties(${n} PROPERTIES LINK_FLAGS ${foolib_LINK} COMPILE_FLAGS ${foolib_COMPILE}) + set_target_properties(${n} PROPERTIES LINK_FLAGS "${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") endif() install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endmacro() @@ -348,7 +355,9 @@ if(SDK_RIFT) set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") set(c-flags "-fno-strict-aliasing") else() - set(c-flags "-fno-strict-aliasing") + if(NOT MSVC) + set(c-flags "-fno-strict-aliasing") + endif() endif() opentrack_library(opentrack-tracker-rift ftnoir_tracker_rift LINK ${link-flags} COMPILE ${c-flags}) target_include_directories(opentrack-tracker-rift SYSTEM PUBLIC ${SDK_RIFT}/Include ${SDK_RIFT}/Src) diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index c92f6980..2e08c8ba 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -20,7 +20,7 @@ static void add_program_library_path() { char* p = _pgmptr; { - char path[MAX_PATH]; + char path[MAX_PATH+1]; strcpy(path, p); char* ptr = strrchr(path, '\\'); if (ptr) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 36764edc..b1d84f9b 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -103,7 +103,7 @@ public: actx.lpResourceName = MAKEINTRESOURCEA(resid); actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; #ifdef _MSC_VER -# error "MSVC support removed" +# define PREFIX "" #else # define PREFIX "lib" #endif diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp index b636ffd4..63f75685 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -13,7 +13,9 @@ FTNoIR_Protocol::~FTNoIR_Protocol() } void FTNoIR_Protocol::pose( const double *headpose ) { -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif JOYSTICK_STATE state[2] = { 0 }; state[0].POV = (4 << 12) | (4 << 8) | (4 << 4) | 4; diff --git a/ftnoir_tracker_aruco/include/exports.h b/ftnoir_tracker_aruco/include/exports.h index aaeb94e4..8f7dab8c 100644 --- a/ftnoir_tracker_aruco/include/exports.h +++ b/ftnoir_tracker_aruco/include/exports.h @@ -36,7 +36,7 @@ or implied, of Rafael Muñoz Salinas. #endif -#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined DSO_EXPORTS +#if ((defined WIN32 || defined _WIN32 || defined WINCE) && defined DSO_EXPORTS) || defined(_MSC_VER) #define ARUCO_EXPORTS __declspec(dllexport) #else #define ARUCO_EXPORTS __attribute__ ((visibility ("default"))) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 34c27579..826cecaa 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -10,7 +10,6 @@ Hydra_Tracker::Hydra_Tracker() : should_quit(false) {} -#pragma GCC diagnostic ignored "-Wreorder" #include Hydra_Tracker::~Hydra_Tracker() diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 2dc0ad6b..264166fe 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -41,7 +41,9 @@ FTNoIR_Tracker::~FTNoIR_Tracker() } } -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext ) diff --git a/opentrack/export.hpp b/opentrack/export.hpp index 8c8bdc69..f0983b75 100644 --- a/opentrack/export.hpp +++ b/opentrack/export.hpp @@ -1,7 +1,13 @@ #pragma once + #ifdef _WIN32 # define OPENTRACK_LINKAGE __declspec(dllexport) #else # define OPENTRACK_LINKAGE #endif -#define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE + +#ifndef _MSC_VER +# define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE +#else +# define OPENTRACK_EXPORT OPENTRACK_LINKAGE +#endif \ No newline at end of file diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 95b4b0a1..627bce6a 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -42,7 +42,7 @@ #include #ifdef _MSC_VER -# error "No support for MSVC anymore" +# define OPENTRACK_LIB_PREFIX "" #else # define OPENTRACK_LIB_PREFIX "lib" #endif -- cgit v1.2.3 From 6c23e1ad43f143ee8b694b907432c5801713a7d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 09:46:29 +0200 Subject: fix MSVC, now runs --- CMakeLists.txt | 61 +++++++++++++++++++---- facetracknoir/main.cpp | 10 ++-- ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 4 +- ftnoir_protocol_sc/scserver-acceleration.manifest | 13 ----- ftnoir_protocol_sc/scserver-sp2.manifest | 13 ----- ftnoir_protocol_sc/scserver_acceleration.manifest | 13 +++++ ftnoir_protocol_sc/scserver_sp2.manifest | 13 +++++ ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 7 +++ opentrack/version.C | 5 -- opentrack/version.cc | 9 ++++ 10 files changed, 102 insertions(+), 46 deletions(-) delete mode 100644 ftnoir_protocol_sc/scserver-acceleration.manifest delete mode 100644 ftnoir_protocol_sc/scserver-sp2.manifest create mode 100644 ftnoir_protocol_sc/scserver_acceleration.manifest create mode 100644 ftnoir_protocol_sc/scserver_sp2.manifest delete mode 100644 opentrack/version.C create mode 100644 opentrack/version.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 4389432d..c45163dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ set(my-qt-deps) if(WIN32) # hack to avoid breakage on buildbot set(my-qt-deps ws2_32) endif() -set(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${my-qt-deps}) # note, hatire supports both ftnoir and opentrack # don't remove without being sure as hell -sh 20140922 @@ -69,6 +69,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR APPLE) set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS} ") endif() +set_property(GLOBAL PROPERTY USE_FOLDERS OFF) + # qt broken as usual set(EXTRA-MOCS opentrack/options.hpp) @@ -85,10 +87,17 @@ endmacro() macro(opentrack_qt n) qt5_wrap_cpp(${n}-moc ${${n}-c} OPTIONS --no-notes) QT5_WRAP_UI(${n}-uih ${${n}-ui}) - QT5_ADD_RESOURCES(${n}-rcc) + QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) set(${n}-all ${${n}-c} ${${n}-rc} ${${n}-rcc} ${${n}-uih} ${${n}-moc} ${${n}-res}) endmacro() +set(msvc-subsystem "/VERSION:5.1 /SUBSYSTEM:WINDOWS,5.01") +function(opentrack_compat target) + if(MSVC) + set_target_properties(${target} PROPERTIES LINK_FLAGS "${msvc-subsystem} /DEBUG /OPT:ICF") + endif() +endfunction() + macro(opentrack_library n dir) cmake_parse_arguments(foolib "" "LINK;COMPILE;GNU-LINK;GNU-COMPILE" "" ${ARGN}) if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ") @@ -104,7 +113,11 @@ macro(opentrack_library n dir) COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" ) else() - set_target_properties(${n} PROPERTIES LINK_FLAGS "${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") + set(link-flags) + if(MSVC) + set(link-flags "${msvc-subsystem} /DEBUG /OPT:ICF") + endif() + set_target_properties(${n} PROPERTIES LINK_FLAGS "${link-flags} ${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") endif() install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endmacro() @@ -171,6 +184,7 @@ add_custom_target(tarball DEPENDS ${filename}) opentrack_module(opentrack-api opentrack) opentrack_qt(opentrack-api) add_library(opentrack-api STATIC ${opentrack-api-all}) +opentrack_compat(opentrack-api) target_link_libraries(opentrack-api ${MY_QT_LIBS}) if(NOT WIN32) @@ -221,31 +235,36 @@ if(SDK_XPLANE) endif() add_library(opentrack-compat STATIC ${opentrack-compat-c}) +opentrack_compat(opentrack-compat) # uh... if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() opentrack_module(opentrack-csv csv) add_library(opentrack-csv STATIC ${opentrack-csv-c}) +opentrack_compat(opentrack-csv) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) opentrack_module(opentrack-pose-widget pose-widget) opentrack_qt(opentrack-pose-widget) add_library(opentrack-pose-widget STATIC ${opentrack-pose-widget-all}) +opentrack_compat(opentrack-pose-widget) target_include_directories(opentrack-pose-widget PUBLIC pose-widget/) # else Qt moc breaks target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) opentrack_module(opentrack-spline-widget qfunctionconfigurator) opentrack_qt(opentrack-spline-widget) add_library(opentrack-spline-widget STATIC ${opentrack-spline-widget-all}) +opentrack_compat(opentrack-spline-widget) target_include_directories(opentrack-spline-widget PUBLIC qfunctionconfigurator/) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) -add_library(opentrack-version STATIC opentrack/version.C) +add_library(opentrack-version STATIC opentrack/version.cc) +opentrack_compat(opentrack-version) set_target_properties(opentrack-version PROPERTIES COMPILE_DEFINITIONS - "IN_VERSION_UNIT;OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\"") + "OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\"") opentrack_library(opentrack-filter-accela ftnoir_filter_accela) target_link_libraries(opentrack-filter-accela opentrack-spline-widget) @@ -256,7 +275,12 @@ opentrack_library(opentrack-proto-fgfs ftnoir_protocol_fg) if(SDK_VJOY) opentrack_library(opentrack-proto-vjoy ftnoir_protocol_vjoy GNU-LINK "-Wl,--enable-stdcall-fixup") - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} ${SDK_VJOY}/VJoy.dll) + if(MSVC) + set(ext .lib) + else() + set(ext .dll) + endif() + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} ${SDK_VJOY}/VJoy${ext}) target_include_directories(opentrack-proto-vjoy SYSTEM PUBLIC ${SDK_VJOY}) endif() @@ -272,6 +296,9 @@ if(SDK_FSUIPC) opentrack_library(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) target_link_libraries(opentrack-proto-fsuipc ${SDK_FSUIPC}/FSUIPC_User.lib) target_include_directories(opentrack-proto-fsuipc SYSTEM PUBLIC ${SDK_FSUIPC}) + if(MSVC) + set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBC.lib") + endif() #target_link_directories(${SDK_FSUIPC}) endif() @@ -362,7 +389,14 @@ if(SDK_RIFT) opentrack_library(opentrack-tracker-rift ftnoir_tracker_rift LINK ${link-flags} COMPILE ${c-flags}) target_include_directories(opentrack-tracker-rift SYSTEM PUBLIC ${SDK_RIFT}/Include ${SDK_RIFT}/Src) if(WIN32) - target_link_libraries(opentrack-tracker-rift ${SDK_RIFT}/libLibOVR.a winmm setupapi ws2_32 imagehlp wbemuuid) + if(MSVC) + set(ext lib) + set(p) + else() + set(ext a) + set(p lib) + endif() + target_link_libraries(opentrack-tracker-rift ${SDK_RIFT}/${p}LibOVR.${ext} winmm setupapi ws2_32 imagehlp wbemuuid) else() if(NOT APPLE) target_link_libraries(opentrack-tracker-rift ${SDK_RIFT}/libLibOVR.a udev Xinerama) @@ -376,9 +410,16 @@ if(SDK_HYDRA) opentrack_library(opentrack-tracker-hydra ftnoir_tracker_hydra) target_include_directories(opentrack-tracker-hydra SYSTEM PUBLIC ${SDK_HYDRA}/include ${SDK_HYDRA}/include/sixense_utils) if(WIN32) + if(MSVC) + set(dir lib) + set(ext lib) + else() + set(dir bin) + set(ext dll) + endif() target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" - #"${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" + "${SDK_HYDRA}/${dir}/win32/release_dll/sixense.${ext}" + #"${SDK_HYDRA}/${dir}/win32/release_dll/sixense_utils.${ext}" ) install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" #"${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" @@ -439,7 +480,7 @@ if(UNIX OR APPLE) endif() opentrack_qt(opentrack) add_executable(opentrack ${opentrack-win32-executable} ${opentrack-all}) - +opentrack_compat(opentrack) if(NOT WIN32) set_target_properties(opentrack PROPERTIES SUFFIX ".bin") endif() diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 2e08c8ba..6d29e3b5 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -77,13 +77,17 @@ int main(int argc, char** argv) if (use_profile) MainWindow::set_profile(profile); - MainWindow w; + auto w = std::make_shared(); if (use_profile) - w.startTracker(); + w->startTracker(); - w.show(); + w->show(); app.exec(); + // on MSVC crashes in atexit +#ifdef _MSC_VER + TerminateProcess(GetCurrentProcess(), 0); +#endif return 0; } diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc index 80b6c12c..c89eb9a7 100644 --- a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc +++ b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc @@ -1,4 +1,4 @@ #include 142 RT_MANIFEST scserver.manifest -143 RT_MANIFEST scserver-sp2.manifest -144 RT_MANIFEST scserver-acceleration.manifest \ No newline at end of file +143 RT_MANIFEST scserver_sp2.manifest +144 RT_MANIFEST scserver_acceleration.manifest \ No newline at end of file diff --git a/ftnoir_protocol_sc/scserver-acceleration.manifest b/ftnoir_protocol_sc/scserver-acceleration.manifest deleted file mode 100644 index 06459587..00000000 --- a/ftnoir_protocol_sc/scserver-acceleration.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/ftnoir_protocol_sc/scserver-sp2.manifest b/ftnoir_protocol_sc/scserver-sp2.manifest deleted file mode 100644 index 19b123ba..00000000 --- a/ftnoir_protocol_sc/scserver-sp2.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/ftnoir_protocol_sc/scserver_acceleration.manifest b/ftnoir_protocol_sc/scserver_acceleration.manifest new file mode 100644 index 00000000..06459587 --- /dev/null +++ b/ftnoir_protocol_sc/scserver_acceleration.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ftnoir_protocol_sc/scserver_sp2.manifest b/ftnoir_protocol_sc/scserver_sp2.manifest new file mode 100644 index 00000000..3020d16c --- /dev/null +++ b/ftnoir_protocol_sc/scserver_sp2.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 73496fba..a9e8ed6e 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -96,6 +96,13 @@ typedef struct _JOYSTICK_STATE UINT32 Buttons; // 32 Buttons } JOYSTICK_STATE, * PJOYSTICK_STATE; +#ifndef _MSC_VER EXTERN_C BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); EXTERN_C VOID __stdcall VJoy_Shutdown(); EXTERN_C BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); +#else +#define VJOY_API __declspec(dllimport) +VJOY_API BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); +VJOY_API VOID __stdcall VJoy_Shutdown(); +VJOY_API BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); +#endif diff --git a/opentrack/version.C b/opentrack/version.C deleted file mode 100644 index 0ef4ec14..00000000 --- a/opentrack/version.C +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef IN_VERSION_UNIT -# define IN_CRAPOLA_COMPILE_UNIT -volatile const char* opentrack_version = OPENTRACK_VERSION; -#else -#endif diff --git a/opentrack/version.cc b/opentrack/version.cc new file mode 100644 index 00000000..026ad057 --- /dev/null +++ b/opentrack/version.cc @@ -0,0 +1,9 @@ +#include "opentrack/export.hpp" + +#ifdef __cplusplus +extern "C" +#endif +OPENTRACK_EXPORT +volatile const char* opentrack_version; + +volatile const char* opentrack_version = OPENTRACK_VERSION; -- cgit v1.2.3 From c759dc6f494b45fc4a9b4a7f5dbd4ff9e24e0b43 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 10:17:45 +0200 Subject: fix crash on msvc --- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 4c0913e7..2d113ac5 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -36,6 +36,7 @@ Tracker_PT::~Tracker_PT() delete video_widget; video_widget = NULL; if (video_frame->layout()) delete video_frame->layout(); + camera.stop(); } void Tracker_PT::set_command(Command command) -- cgit v1.2.3 From 06a5c5d3e373b016d8a8917285c9b8a14e85f719 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 10:20:18 +0200 Subject: pt: reintroduce dynamic pose timer --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 106 +++++++++++++++---------- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 1 + ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 4 +- ftnoir_tracker_pt/point_tracker.cpp | 23 ++++-- ftnoir_tracker_pt/point_tracker.h | 7 +- 6 files changed, 89 insertions(+), 54 deletions(-) diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index 39fb0686..17e2819b 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -67,6 +67,19 @@ Camera settings + + + + + 0 + 0 + + + + Height + + + @@ -105,19 +118,6 @@ - - - - - 0 - 0 - - - - Height - - - @@ -144,19 +144,6 @@ - - - - - 0 - 0 - - - - Field of view - - - @@ -195,22 +182,36 @@ - - + + - + 0 0 - - Desired capture framerate + + Field of view - - Hz + + + + + + + 0 + 0 + - - 2000 + + Dynamic pose resolution + + + + + + + @@ -230,23 +231,42 @@ - - + + - + 0 0 - - Dynamic pose resolution + + Desired capture framerate + + + Hz + + + 2000 - - + + - + Dynamic pose timeout + + + + + + + ms + + + 1 + + + 10000 diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 2d113ac5..e96e7171 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -86,7 +86,7 @@ void Tracker_PT::run() ever_success |= success; if (success) - point_tracker.track(points, PointModel(s), get_focal_length(), s.dynamic_pose); + point_tracker.track(points, PointModel(s), get_focal_length(), s.dynamic_pose, s.init_phase_timeout); { Affine X_CM = pose(); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index e7f1384d..696f0b1b 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -75,6 +75,7 @@ TrackerDialog_PT::TrackerDialog_PT() tie_setting(s.active_model_panel, ui.model_tabs); tie_setting(s.dynamic_pose, ui.dynamic_pose); + tie_setting(s.init_phase_timeout, ui.init_phase_timeout); connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 4e241bc3..4d54eb68 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -32,6 +32,7 @@ struct settings_pt : opts value fov; value dynamic_pose; + value init_phase_timeout; settings_pt() : opts("tracker-pt"), @@ -60,7 +61,8 @@ struct settings_pt : opts cap_y(b, "cap-y", 0), cap_z(b, "cap-z", 0), fov(b, "camera-fov", 56), - dynamic_pose(b, "dynamic-pose-resolution", true) + dynamic_pose(b, "dynamic-pose-resolution", true), + init_phase_timeout(b, "init-phase-timeout", 500) {} }; diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index e4c999ad..bae89dbe 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -62,7 +62,7 @@ void PointModel::get_d_order(const std::vector& points, int d_order[] } -PointTracker::PointTracker() +PointTracker::PointTracker() : init_phase(true) { } @@ -96,6 +96,7 @@ PointTracker::PointOrder PointTracker::find_correspondences_previous(const vecto // if one point is closest to more than one model point, fallback if (point_taken[min_idx]) { + init_phase = true; return find_correspondences(points, model); } point_taken[min_idx] = true; @@ -104,16 +105,24 @@ PointTracker::PointOrder PointTracker::find_correspondences_previous(const vecto return p; } -void PointTracker::track(const vector& points, const PointModel& model, float f, bool dynamic_pose) +void PointTracker::track(const vector& points, const PointModel& model, float f, bool dynamic_pose, int init_phase_timeout) { PointOrder order; - - if (!dynamic_pose) - order = find_correspondences(points, model); - else - order = find_correspondences_previous(points, model, f); + + if (t.elapsed_ms() > init_phase_timeout) + { + t.start(); + init_phase = true; + } + + if (!dynamic_pose || init_phase) + order = find_correspondences(points, model); + else + order = find_correspondences_previous(points, model, f); POSIT(model, order, f); + init_phase = false; + t.start(); } PointTracker::PointOrder PointTracker::find_correspondences(const std::vector& points, const PointModel& model) diff --git a/ftnoir_tracker_pt/point_tracker.h b/ftnoir_tracker_pt/point_tracker.h index 3b9573ff..935e2eaa 100644 --- a/ftnoir_tracker_pt/point_tracker.h +++ b/ftnoir_tracker_pt/point_tracker.h @@ -15,7 +15,7 @@ # include #endif #include - +#include "opentrack/timer.hpp" #include "ftnoir_tracker_pt_settings.h" #include @@ -119,7 +119,7 @@ public: // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) // f : (focal length)/(sensor width) // dt : time since last call - void track(const std::vector& projected_points, const PointModel& model, float f, bool dynamic_pose); + void track(const std::vector& projected_points, const PointModel& model, float f, bool dynamic_pose, int init_phase_timeout); Affine pose() const { return X_CM; } cv::Vec2f project(const cv::Vec3f& v_M, float f); private: @@ -139,6 +139,9 @@ private: int POSIT(const PointModel& point_model, const PointOrder& order, float focal_length); // The POSIT algorithm, returns the number of iterations Affine X_CM; // trafo from model to camera + + Timer t; + bool init_phase; }; #endif //POINTTRACKER_H -- cgit v1.2.3 From 2d0ecf757c91c12d9a73420c5f142b652b5e3d7c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 11:19:57 +0200 Subject: maybe fix simconnect lag --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 107 ++++++++++++++---------------- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 38 ++++++----- 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index b1d84f9b..41fcf1b0 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -29,43 +29,39 @@ #include "ftnoir_protocol_sc.h" #include "opentrack/plugin-api.hpp" -importSimConnect_CameraSetRelative6DOF FTNoIR_Protocol::simconnect_set6DOF; -HANDLE FTNoIR_Protocol::hSimConnect = 0; // Handle to SimConnect - -float FTNoIR_Protocol::virtSCPosX = 0.0f; // Headpose -float FTNoIR_Protocol::virtSCPosY = 0.0f; -float FTNoIR_Protocol::virtSCPosZ = 0.0f; - -float FTNoIR_Protocol::virtSCRotX = 0.0f; -float FTNoIR_Protocol::virtSCRotY = 0.0f; -float FTNoIR_Protocol::virtSCRotZ = 0.0f; - -float FTNoIR_Protocol::prevSCPosX = 0.0f; // previous Headpose -float FTNoIR_Protocol::prevSCPosY = 0.0f; -float FTNoIR_Protocol::prevSCPosZ = 0.0f; - -float FTNoIR_Protocol::prevSCRotX = 0.0f; -float FTNoIR_Protocol::prevSCRotY = 0.0f; -float FTNoIR_Protocol::prevSCRotZ = 0.0f; - static QLibrary SCClientLib; -FTNoIR_Protocol::FTNoIR_Protocol() +FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr) { - blnSimConnectActive = false; - hSimConnect = 0; + start(); } FTNoIR_Protocol::~FTNoIR_Protocol() { - qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect; + should_stop = true; + wait(); - if (hSimConnect != 0) { - qDebug() << "~FTNoIR_Protocol says: before simconnect_close"; - if (SUCCEEDED( simconnect_close( FTNoIR_Protocol::hSimConnect ) ) ) { - qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED"; - } - } + if (hSimConnect) + (void) simconnect_close(hSimConnect); +} + +void FTNoIR_Protocol::run() +{ + if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { + simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); + + simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); + simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); + simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); + } + else + return; + + while (!should_stop) + { + (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this))); + Sleep(3); + } } void FTNoIR_Protocol::pose( const double *headpose ) { @@ -76,19 +72,6 @@ void FTNoIR_Protocol::pose( const double *headpose ) { virtSCPosX = headpose[TX]/100.f; // cm to meters virtSCPosY = headpose[TY]/100.f; virtSCPosZ = -headpose[TZ]/100.f; - - if (!blnSimConnectActive) { - if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { - simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); - - simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); - simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); - simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); - blnSimConnectActive = true; - } - } - else - (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL)); } #pragma GCC diagnostic ignored "-Wmissing-field-initializers" @@ -203,25 +186,37 @@ bool FTNoIR_Protocol::correct() return true; } -void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *) +void FTNoIR_Protocol::handle() +{ + if (prevSCPosX != virtSCPosX || + prevSCPosY != virtSCPosY || + prevSCPosZ != virtSCPosZ || + prevSCRotX != virtSCRotX || + prevSCRotY != virtSCRotY || + prevSCRotZ != virtSCRotZ) + { + (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); + } + + prevSCPosX = virtSCPosX; + prevSCPosY = virtSCPosY; + prevSCPosZ = virtSCPosZ; + prevSCRotX = virtSCRotX; + prevSCRotY = virtSCRotY; + prevSCRotZ = virtSCRotZ; +} + +void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *self_) { + FTNoIR_Protocol& self = *reinterpret_cast(self_); + switch(pData->dwID) { default: break; case SIMCONNECT_RECV_ID_EVENT_FRAME: - { - if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || - (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { - (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); - } - prevSCPosX = virtSCPosX; - prevSCPosY = virtSCPosY; - prevSCPosZ = virtSCPosZ; - prevSCRotX = virtSCRotX; - prevSCRotY = virtSCRotY; - prevSCRotZ = virtSCRotZ; - } + self.handle(); + break; case SIMCONNECT_RECV_ID_EXCEPTION: { SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; @@ -240,10 +235,8 @@ void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData } case SIMCONNECT_RECV_ID_QUIT: - { break; } - } } extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index f8db519b..b65bac85 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -39,6 +39,7 @@ #include #include "ui_ftnoir_sccontrols.h" +#include #include #include #include @@ -83,45 +84,46 @@ struct settings : opts { {} }; -class FTNoIR_Protocol : public IProtocol +class FTNoIR_Protocol : public IProtocol, private QThread { public: FTNoIR_Protocol(); ~FTNoIR_Protocol() override; bool correct(); void pose(const double* headpose); + void handle(); QString game_name() { return "FS2004/FSX"; } private: - static float virtSCPosX; - static float virtSCPosY; - static float virtSCPosZ; - - static float virtSCRotX; - static float virtSCRotY; - static float virtSCRotZ; + void run() override; + volatile bool should_stop; + + volatile float virtSCPosX; + volatile float virtSCPosY; + volatile float virtSCPosZ; + volatile float virtSCRotX; + volatile float virtSCRotY; + volatile float virtSCRotZ; - static float prevSCPosX; - static float prevSCPosY; - static float prevSCPosZ; + float prevSCPosX; + float prevSCPosY; + float prevSCPosZ; - static float prevSCRotX; - static float prevSCRotY; - static float prevSCRotZ; - - bool blnSimConnectActive; + float prevSCRotX; + float prevSCRotY; + float prevSCRotZ; importSimConnect_Open simconnect_open; // SimConnect function(s) in DLL importSimConnect_Close simconnect_close; - static importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; + importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; importSimConnect_CallDispatch simconnect_calldispatch; importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; importSimConnect_MapClientEventToSimEvent simconnect_mapclienteventtosimevent; importSimConnect_AddClientEventToNotificationGroup simconnect_addclienteventtonotificationgroup; importSimConnect_SetNotificationGroupPriority simconnect_setnotificationgrouppriority; - static HANDLE hSimConnect; // Handle to SimConnect + HANDLE hSimConnect; // Handle to SimConnect static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); settings s; }; -- cgit v1.2.3 From 6aa89934e8f22a580dc8a63cec61fb9ea9d14f23 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 11:50:41 +0200 Subject: simconnect: prevent crash with no .dll --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 12 ++++++++---- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 41fcf1b0..8e35248e 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -31,7 +31,7 @@ static QLibrary SCClientLib; -FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr) +FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr), should_start(false) { start(); } @@ -40,13 +40,13 @@ FTNoIR_Protocol::~FTNoIR_Protocol() { should_stop = true; wait(); - - if (hSimConnect) - (void) simconnect_close(hSimConnect); } void FTNoIR_Protocol::run() { + if (!should_start) + return; + if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); @@ -62,6 +62,8 @@ void FTNoIR_Protocol::run() (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this))); Sleep(3); } + + (void) simconnect_close(hSimConnect); } void FTNoIR_Protocol::pose( const double *headpose ) { @@ -182,6 +184,8 @@ bool FTNoIR_Protocol::correct() } qDebug() << "FTNoIR_Protocol::correct() says: SimConnect functions resolved in DLL!"; + + should_start = true; return true; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index b65bac85..3ced16e5 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -126,6 +126,8 @@ private: HANDLE hSimConnect; // Handle to SimConnect static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); settings s; + + bool should_start; }; class SCControls: public IProtocolDialog -- cgit v1.2.3 From 9201417e9973f901a39195507cf2935a529e821e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 14:42:33 +0200 Subject: fix msvc empty config list Some MSVC 2015RC bug with static initialized const char*. But reproduced also in #179 (?) --- facetracknoir/process_detector.cpp | 8 ++++---- facetracknoir/ui.cpp | 16 ++++++++-------- ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp | 8 ++++---- opentrack/options.hpp | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp index 237d350d..79b5c95f 100644 --- a/facetracknoir/process_detector.cpp +++ b/facetracknoir/process_detector.cpp @@ -9,25 +9,25 @@ void settings::set_game_list(const QString &game_list) { - QSettings settings(group::org); + QSettings settings(OPENTRACK_ORG); settings.setValue("executable-list", game_list); } QString settings::get_game_list() { - QSettings settings(group::org); + QSettings settings(OPENTRACK_ORG); return settings.value("executable-list").toString(); } bool settings::is_enabled() { - QSettings settings(group::org); + QSettings settings(OPENTRACK_ORG); return settings.value("executable-detector-enabled", false).toBool(); } void settings::set_is_enabled(bool enabled) { - QSettings settings(group::org); + QSettings settings(OPENTRACK_ORG); settings.setValue("executable-detector-enabled", enabled); } diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 284367ce..5a600f02 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -112,8 +112,8 @@ void MainWindow::open() { if (! fileName.isEmpty() ) { { - QSettings settings(group::org); - settings.setValue(group::filename_key, remove_app_path(fileName)); + QSettings settings(OPENTRACK_ORG); + settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); } fill_profile_combobox(); load_settings(); @@ -161,8 +161,8 @@ void MainWindow::saveAs() { (void) QFile::copy(oldFile, fileName); - QSettings settings(group::org); - settings.setValue (group::filename_key, remove_app_path(fileName)); + QSettings settings(OPENTRACK_ORG); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); } save(); @@ -460,8 +460,8 @@ void MainWindow::profileSelected(int index) return; { - QSettings settings(group::org); - settings.setValue (group::filename_key, remove_app_path(QFileInfo(group::ini_pathname()).absolutePath() + "/" + + QSettings settings(OPENTRACK_ORG); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(QFileInfo(group::ini_pathname()).absolutePath() + "/" + ui.iconcomboProfile->itemText(index))); } load_settings(); @@ -540,6 +540,6 @@ void MainWindow::maybe_start_profile_from_executable() void MainWindow::set_profile(const QString &profile) { - QSettings settings(group::org); - settings.setValue(group::filename_key, MainWindow::remove_app_path(profile)); + QSettings settings(OPENTRACK_ORG); + settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, MainWindow::remove_app_path(profile)); } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp index 017a8f0a..80543e7a 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -36,12 +36,12 @@ void TrackerSettings::load_ini() { #ifdef OPENTRACK_API - QSettings settings(options::group::org); // Registry settings (in HK_USER) + QSettings settings(OPENTRACK_ORG); // Registry settings (in HK_USER) #else QSettings settings("opentrack"); // Registry settings (in HK_USER) #endif #ifdef OPENTRACK_API - QString currentFile = settings.value( options::group::filename_key, QCoreApplication::applicationDirPath() + options::group::default_path ).toString(); + QString currentFile = settings.value( OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH ).toString(); #else QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); #endif @@ -106,12 +106,12 @@ void TrackerSettings::save_ini() const { #ifdef OPENTRACK_API - QSettings settings(options::group::org); // Registry settings (in HK_USER) + QSettings settings(OPENTRACK_ORG); // Registry settings (in HK_USER) #else QSettings settings("opentrack"); // Registry settings (in HK_USER) #endif #ifdef OPENTRACK_API - QString currentFile = settings.value( options::group::filename_key, QCoreApplication::applicationDirPath() + options::group::default_path ).toString(); + QString currentFile = settings.value( OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH ).toString(); #else QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); #endif diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 7c3f6847..a10ba382 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -38,6 +38,10 @@ #include template using mem = std::shared_ptr; +#define OPENTRACK_CONFIG_FILENAME_KEY "settings-file" +#define OPENTRACK_DEFAULT_CONFIG_PATH "/settings/default.ini" +#define OPENTRACK_ORG "opentrack-2.3" + namespace options { template using map = std::map; @@ -97,7 +101,6 @@ namespace options { } conf.endGroup(); } - static constexpr const char* org = "opentrack-2.3"; void save() { @@ -129,13 +132,10 @@ namespace options { return kvs.count(s) != 0; } - static constexpr const char* filename_key = "settings-file"; - static constexpr const char* default_path = "/settings/default.ini"; - static const QString ini_pathname() { - QSettings settings(group::org); - return settings.value(filename_key, QCoreApplication::applicationDirPath() + default_path).toString(); + QSettings settings(OPENTRACK_ORG); + return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH).toString(); } static const QStringList ini_list() -- cgit v1.2.3 From 8bdd22bccfb8df345d0a03f6c575bfc792027874 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 15:21:49 +0200 Subject: simconnect: don't race against initialization Issue: #174 --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 8 ++------ ftnoir_protocol_sc/ftnoir_protocol_sc.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 8e35248e..02ad497d 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -31,9 +31,8 @@ static QLibrary SCClientLib; -FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr), should_start(false) +FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr) { - start(); } FTNoIR_Protocol::~FTNoIR_Protocol() @@ -44,9 +43,6 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::run() { - if (!should_start) - return; - if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); @@ -185,7 +181,7 @@ bool FTNoIR_Protocol::correct() qDebug() << "FTNoIR_Protocol::correct() says: SimConnect functions resolved in DLL!"; - should_start = true; + start(); return true; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 3ced16e5..b65bac85 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -126,8 +126,6 @@ private: HANDLE hSimConnect; // Handle to SimConnect static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); settings s; - - bool should_start; }; class SCControls: public IProtocolDialog -- cgit v1.2.3 From f984d092db61cafb3b85efedeab6a9fbd6896ead Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 15:28:16 +0200 Subject: pt: default to "standard" clip dimensions Suggested-by: Mathijs Groothuis Issue: #180 --- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 4d54eb68..6260a19d 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -52,10 +52,10 @@ struct settings_pt : opts t_MH_x(b, "model-centroid-x", 0), t_MH_y(b, "model-centroid-y", 0), t_MH_z(b, "model-centroid-z", 0), - clip_ty(b, "clip-ty", 0), - clip_tz(b, "clip-tz", 0), - clip_by(b, "clip-by", 0), - clip_bz(b, "clip-bz", 0), + clip_ty(b, "clip-ty", 40), + clip_tz(b, "clip-tz", 30), + clip_by(b, "clip-by", 70), + clip_bz(b, "clip-bz", 80), active_model_panel(b, "active-model-panel", 0), cap_x(b, "cap-x", 0), cap_y(b, "cap-y", 0), -- cgit v1.2.3 From 8e442abcd71b7de741f615eac4fa1bd9fa63390e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 15:40:51 +0200 Subject: simconnect: try set camera without event notification --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 02ad497d..4d76df03 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -43,20 +43,20 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::run() { - if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { + if (!SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) + return; +#if 0 simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); - } - else - return; +#endif while (!should_stop) { (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this))); - Sleep(3); + Sleep(1); } (void) simconnect_close(hSimConnect); @@ -217,25 +217,6 @@ void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData case SIMCONNECT_RECV_ID_EVENT_FRAME: self.handle(); break; - case SIMCONNECT_RECV_ID_EXCEPTION: - { - SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; - - switch (except->dwException) - { - case SIMCONNECT_EXCEPTION_ERROR: - qDebug() << "Camera error"; - break; - - default: - qDebug() << "Exception"; - break; - } - break; - } - - case SIMCONNECT_RECV_ID_QUIT: - break; } } -- cgit v1.2.3 From 228338d8a3d3bedbec9f4f289738dcf236457e47 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 15:43:48 +0200 Subject: pt: use default cap dimensions Reported-by: Mathijs Groothuis Issue: #180 --- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 6260a19d..af2f5978 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -57,9 +57,9 @@ struct settings_pt : opts clip_by(b, "clip-by", 70), clip_bz(b, "clip-bz", 80), active_model_panel(b, "active-model-panel", 0), - cap_x(b, "cap-x", 0), - cap_y(b, "cap-y", 0), - cap_z(b, "cap-z", 0), + cap_x(b, "cap-x", 40), + cap_y(b, "cap-y", 60), + cap_z(b, "cap-z", 100), fov(b, "camera-fov", 56), dynamic_pose(b, "dynamic-pose-resolution", true), init_phase_timeout(b, "init-phase-timeout", 500) -- cgit v1.2.3 From e5598d9d15a6e7a91d3aaae9efce2c1e115a0267 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 17:01:09 +0200 Subject: ui: bail early if no dialog can be found Issue: #182 --- facetracknoir/ui.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 5a600f02..33ff6ecd 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -360,6 +360,7 @@ void MainWindow::showTrackerSettings() else { auto dialog = mk_dialog(current_tracker()); + if (!dialog) return; pTrackerDialog = dialog; if (libs.pTracker != nullptr) dialog->register_tracker(libs.pTracker.get()); @@ -376,6 +377,7 @@ void MainWindow::showProtocolSettings() { } else { auto dialog = mk_dialog(current_protocol()); + if (!dialog) return; pProtocolDialog = dialog; if (libs.pProtocol != nullptr) dialog->register_protocol(libs.pProtocol.get()); @@ -392,6 +394,7 @@ void MainWindow::showFilterSettings() { } else { auto dialog = mk_dialog(current_filter()); + if (!dialog) return; pFilterDialog = dialog; if (libs.pFilter != nullptr) dialog->register_filter(libs.pFilter.get()); -- cgit v1.2.3 From 6919231923167c04ce8788eee6deb12d8268e89c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 17:01:32 +0200 Subject: ui: simplify protocol load failure logic --- facetracknoir/ui.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 33ff6ecd..10445182 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -215,13 +215,11 @@ void MainWindow::bindKeyboardShortcuts() void MainWindow::startTracker() { s.b->save(); load_settings(); - bindKeyboardShortcuts(); // tracker dtor needs run first work = nullptr; libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); - work = std::make_shared(s, pose, libs, this, winId()); { double p[6] = {0,0,0, 0,0,0}; @@ -234,9 +232,14 @@ void MainWindow::startTracker() { "One of libraries failed to load. Check installation.", QMessageBox::Ok, QMessageBox::NoButton); + libs = SelectedLibraries(); return; } + work = std::make_shared(s, pose, libs, this, winId()); + + bindKeyboardShortcuts(); + if (pTrackerDialog) pTrackerDialog->register_tracker(libs.pTracker.get()); -- cgit v1.2.3 From 8c43f5ad67f75c2160cd37209dbe93c7fe4e97f4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 17:01:47 +0200 Subject: sc: try fix load failure logic --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 4d76df03..465d8d20 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -76,7 +76,7 @@ void FTNoIR_Protocol::pose( const double *headpose ) { class ActivationContext { public: - ActivationContext(const int resid) { + ActivationContext(const int resid) :ok (false) { hactctx = INVALID_HANDLE_VALUE; actctx_cookie = 0; ACTCTXA actx = {0}; @@ -100,7 +100,7 @@ public: hactctx = INVALID_HANDLE_VALUE; } } else { - qDebug() << "SC: can't create win32 activation context"; + qDebug() << "SC: can't create win32 activation context" << GetLastError(); } } ~ActivationContext() { @@ -110,9 +110,11 @@ public: ReleaseActCtx(hactctx); } } + bool is_ok() { return ok; } private: ULONG_PTR actctx_cookie; HANDLE hactctx; + bool ok; }; bool FTNoIR_Protocol::correct() @@ -121,11 +123,16 @@ bool FTNoIR_Protocol::correct() { ActivationContext ctx(142 + static_cast(s.sxs_manifest)); - SCClientLib.setFileName("SimConnect.dll"); - if (!SCClientLib.load()) { - qDebug() << "SC load" << SCClientLib.errorString(); - return false; + if (ctx.is_ok()) + { + SCClientLib.setFileName("SimConnect.dll"); + if (!SCClientLib.load()) { + qDebug() << "SC load" << SCClientLib.errorString(); + return false; + } } + else + return false; } // -- cgit v1.2.3 From faeb69bea8f7601d5e941fc872910641aa603628 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jul 2015 17:07:06 +0200 Subject: game-detector: prevent defaulting to first profile if one doesn't exist --- facetracknoir/process_detector.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp index 79b5c95f..8efc0c10 100644 --- a/facetracknoir/process_detector.cpp +++ b/facetracknoir/process_detector.cpp @@ -68,6 +68,7 @@ int process_detector::add_row(QString exe_name, QString profile) QComboBox* cb = new QComboBox(); cb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); + cb->addItem(""); cb->addItems(group::ini_list()); ui.tableWidget->setCellWidget(i, 1, cb); @@ -222,7 +223,7 @@ bool process_detector_worker::config_to_start(QString& str) { last_exe_name = name; str = filenames[name]; - return true; + return str != ""; } } -- cgit v1.2.3 From 2b8e059fa63299442527243df494c63aa90587de Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jul 2015 05:00:13 +0200 Subject: accela: fix redundant division --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 4546cd78..779b0728 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -88,7 +88,7 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double dz = i >= 3 ? rot_dz : trans_dz; const double vec_ = max(0., fabs(vec) - dz); const double thres = i >= 3 ? rot_t : trans_t; - const double val = m.getValue(vec_ / thres) * thres; + const double val = m.getValue(vec_ / thres); const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val; const bool negp = vec < 0.; const bool done = negp -- cgit v1.2.3 From ab742baa98af0d8632d9fceafd3fd8fc7f8ceb8e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jul 2015 05:00:50 +0200 Subject: accela: three times more sensitivity Slider range was too small. --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 779b0728..c34c5ff4 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -13,22 +13,22 @@ using namespace std; static constexpr double rot_gains[][2] = { - { 7, 200 }, - { 6, 100 }, - { 5, 45 }, - { 4, 15 }, - { 3, 5 }, - { 2, 1.4 }, - { 1, .4 }, + { 2.33, 200 }, + { 2, 100 }, + { 1.66, 45 }, + { 1.33, 15 }, + { 1, 5 }, + { .66, 1.4 }, + { .33, .4 }, { 0, 0 }, { -1, 0 } }; static constexpr double trans_gains[][2] = { - { 5, 180 }, - { 4, 64 }, - { 3, 20 }, - { 2, 5 }, - { 1, .7 }, + { 1.66, 180 }, + { 1.33, 64 }, + { 1, 20 }, + { .66, 5 }, + { .33, .7 }, { 0, 0 }, { -1, 0 } }; -- cgit v1.2.3 From 129948322c5824fc058ab6ef585a6b5f4743642f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jul 2015 05:09:57 +0200 Subject: accela: display smallest available slider value in label properly --- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 550c9d24..52c8318a 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -23,6 +23,12 @@ FilterControls::FilterControls() : tie_setting(s.ewma, ui.ewma_slider); tie_setting(s.rot_deadzone, ui.rot_dz_slider); tie_setting(s.trans_deadzone, ui.trans_dz_slider); + + update_rot_display(ui.rotation_slider->value()); + update_trans_display(ui.translation_slider->value()); + update_ewma_display(ui.ewma_slider->value()); + update_rot_dz_display(ui.rot_dz_slider->value()); + update_trans_dz_display(ui.trans_dz_slider->value()); } void FilterControls::register_filter(IFilter* filter) -- cgit v1.2.3 From 0bf534ff329cabaa61a0dddb8671827577407aba Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jul 2015 09:01:29 +0200 Subject: accela: try avoid staircase-like jumping for rotation --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index c34c5ff4..4d5f4a28 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -13,9 +13,10 @@ using namespace std; static constexpr double rot_gains[][2] = { - { 2.33, 200 }, - { 2, 100 }, - { 1.66, 45 }, + { 2.66, 110 }, + { 2.33, 80 }, + { 2, 50 }, + { 1.66, 30 }, { 1.33, 15 }, { 1, 5 }, { .66, 1.4 }, @@ -23,12 +24,15 @@ static constexpr double rot_gains[][2] = { { 0, 0 }, { -1, 0 } }; + static constexpr double trans_gains[][2] = { - { 1.66, 180 }, - { 1.33, 64 }, - { 1, 20 }, - { .66, 5 }, - { .33, .7 }, + { 2.33, 400 }, + { 2, 150 }, + { 1.66, 60 }, + { 1.33, 20 }, + { 1, 4 }, + { .66, 1.5 }, + { .33, .2 }, { 0, 0 }, { -1, 0 } }; -- cgit v1.2.3