From aacc3bb2b563cd172e340365b8f14ec8fae32d9d Mon Sep 17 00:00:00 2001 From: Sven Kocksch Date: Tue, 16 May 2017 10:14:53 +0200 Subject: rename macro --- x-plane-plugin/plugin.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 7897abe6..39e928ba 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -160,7 +160,7 @@ static int TranslationToggleHandler( XPLMCommandRef inCommand, return 0; } -PLUGIN_API OPENTRACK_COMPAT_EXPORT int XPluginStart ( char * outName, char * outSignature, char * outDescription ) { +PLUGIN_API OTR_COMPAT_EXPORT 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"); @@ -198,7 +198,7 @@ PLUGIN_API OPENTRACK_COMPAT_EXPORT int XPluginStart ( char * outName, char * out return 0; } -PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginStop ( void ) { +PLUGIN_API OTR_COMPAT_EXPORT void XPluginStop ( void ) { if (lck_posix) { PortableLockedShm_free(lck_posix); @@ -207,17 +207,17 @@ PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginStop ( void ) { } } -PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginEnable ( void ) { +PLUGIN_API OTR_COMPAT_EXPORT void XPluginEnable ( void ) { XPLMRegisterFlightLoopCallback(write_head_position, -1.0, NULL); track_disabled = 0; } -PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginDisable ( void ) { +PLUGIN_API OTR_COMPAT_EXPORT void XPluginDisable ( void ) { XPLMUnregisterFlightLoopCallback(write_head_position, NULL); track_disabled = 1; } -PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginReceiveMessage( +PLUGIN_API OTR_COMPAT_EXPORT void XPluginReceiveMessage( XPLMPluginID OT_UNUSED(inFromWho), int OT_UNUSED(inMessage), void * OT_UNUSED(inParam)) -- cgit v1.2.3 From b7b96007553a5ed11c43aab40f5361487ce9a5e7 Mon Sep 17 00:00:00 2001 From: Sven Kocksch Date: Wed, 17 May 2017 07:11:26 +0200 Subject: head roll only set view if tracking is running --- x-plane-plugin/plugin.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 39e928ba..3795024c 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,7 @@ #include "compat/export.hpp" enum Axis { - TX = 0, TY, TZ, Yaw, Pitch, Roll + TX = 0, TY, TZ, Yaw, Pitch, Roll }; typedef struct PortableLockedShm @@ -53,7 +54,8 @@ typedef struct WineSHM static PortableLockedShm* lck_posix = NULL; static WineSHM* shm_posix = NULL; -static void *view_x, *view_y, *view_z, *view_heading, *view_pitch; +static WineSHM* data_last = NULL; +static void *view_x, *view_y, *view_z, *view_heading, *view_pitch, *view_roll; static float offset_x, offset_y, offset_z; static XPLMCommandRef track_toggle = NULL, translation_disable_toggle = NULL; static int track_disabled = 1; @@ -111,15 +113,29 @@ float write_head_position( void * OT_UNUSED(inRefcon) ) { if (lck_posix != NULL && shm_posix != NULL) { - PortableLockedShm_lock(lck_posix); - 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); + if(data_last == NULL){ + data_last = calloc(1, sizeof(WineSHM)); } - XPLMSetDataf(view_heading, shm_posix->data[Yaw] * 180 / 3.141592654); - XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / 3.141592654); + + //only set the view if tracking is running + if(memcmp(shm_posix, data_last, sizeof(shm_posix->data)) != 0){ + PortableLockedShm_lock(lck_posix); + 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 / M_PI); + XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / M_PI); + XPLMSetDataf(view_roll, shm_posix->data[Roll] * 180 / M_PI); + } else { + //reset roll, otherwise it would be stuck at last angle + XPLMSetDataf(view_roll, 0); + } + + memcpy(&data_last, &shm_posix, sizeof(WineSHM)); + PortableLockedShm_unlock(lck_posix); } return -1.0; @@ -166,6 +182,7 @@ PLUGIN_API OTR_COMPAT_EXPORT int XPluginStart ( char * outName, char * outSignat 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"); + view_roll = XPLMFindDataRef("sim/graphics/view/field_of_view_roll_deg"); track_toggle = XPLMCreateCommand("opentrack/toggle", "Disable/Enable head tracking"); translation_disable_toggle = XPLMCreateCommand("opentrack/toggle_translation", "Disable/Enable input translation from opentrack"); -- cgit v1.2.3 From 0d8bfd9e607e0aea7c5af61496a6105449eae2b9 Mon Sep 17 00:00:00 2001 From: Sven Kocksch Date: Wed, 17 May 2017 07:22:02 +0200 Subject: use math const --- proto-wine/ftnoir_protocol_wine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp index ea7fadf2..b3a780e7 100644 --- a/proto-wine/ftnoir_protocol_wine.cpp +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include /* For mode constants */ #include /* For O_* constants */ @@ -37,7 +38,7 @@ void wine::pose( const double *headpose ) { lck_shm.lock(); for (int i = 3; i < 6; i++) - shm->data[i] = headpose[i] / 57.295781; + shm->data[i] = headpose[i] / (180 / M_PI ); for (int i = 0; i < 3; i++) shm->data[i] = headpose[i] * 10; if (shm->gameid != gameid) -- cgit v1.2.3