From 1f4a829c70b29e5d466799959a2d84fad017bf51 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:44:37 +0200 Subject: X-Plane: remove dead code --- x-plane-plugin/plugin.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 18a01aa2..455c202f 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -122,42 +122,7 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes return 0; } -#if 0 -static int camera_callback(XPLMCameraPosition_t* outCameraPosition, int inIsLosingControl, void* inRefCon) { - if (!inIsLosingControl && XPLMGetCycleNumber() > 0) { - //XPLMReadCameraPosition(outCameraPosition); - PortableLockedShm_lock(lck_posix); - outCameraPosition->heading = shm_posix->rx * 57.295781; - outCameraPosition->pitch = shm_posix->ry * 57.295781; - outCameraPosition->roll = shm_posix->rz * 57.295781; - outCameraPosition->x = XPLMGetDataf(view_x); - outCameraPosition->y = XPLMGetDataf(view_y); - outCameraPosition->z = XPLMGetDataf(view_z); - PortableLockedShm_unlock(lck_posix); - return 1; - } - return 0; -} -static float flight_loop ( - float inElapsedSinceLastCall, - float inElapsedTimeSinceLastFlightLoop, - int inCounter, - void * inRefcon) -{ - XPLMControlCamera(xplm_ControlCameraForever, camera_callback, NULL); - // don't want it called anymore - return 0; -} -#endif - PLUGIN_API void XPluginStop ( void ) { -#if 0 - // crashes due to race - if (lck_posix) - PortableLockedShm_free(lck_posix); - lck_posix = NULL; - shm_posix = NULL; -#endif } PLUGIN_API void XPluginEnable ( void ) { @@ -173,11 +138,6 @@ PLUGIN_API void XPluginDisable ( void ) { XPLMSetDataf(view_x, offset_x); XPLMSetDataf(view_y, offset_y); XPLMSetDataf(view_z, offset_z); -#if 0 - XPLMUnregisterFlightLoopCallback(flight_loop, NULL); - if (XPLMIsCameraBeingControlled(NULL)) - XPLMDontControlCamera(); -#endif } PLUGIN_API void XPluginReceiveMessage( -- cgit v1.2.3 From 471358347615c5cd4719ff727fc1c9f6aacdc2b6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:48:05 +0200 Subject: Play nice with IDE analysis --- x-plane-plugin/plugin.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 455c202f..b98dc975 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -15,6 +15,10 @@ #include "ftnoir_tracker_base/ftnoir_tracker_types.h" +#ifndef PLUGIN_API +#define PLUGIN_API +#endif + // using Wine name to ease things #define WINE_SHM_NAME "facetracknoir-wine-shm" #define WINE_MTX_NAME "facetracknoir-wine-mtx" -- cgit v1.2.3 From b25bc9bf12fe8dffadde9e03ab1f9119a681158c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:48:41 +0200 Subject: Even more dead code --- x-plane-plugin/plugin.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index b98dc975..33023a81 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -132,9 +132,6 @@ PLUGIN_API void XPluginStop ( void ) { PLUGIN_API void XPluginEnable ( void ) { reinit_offset(); XPLMRegisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); -#if 0 - XPLMRegisterFlightLoopCallback(flight_loop, -1, NULL); -#endif } PLUGIN_API void XPluginDisable ( void ) { -- cgit v1.2.3 From bab1d6596f1a8404e88e2d93092e7be1f9d4ca93 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:50:35 +0200 Subject: Don't leak any memory, ever (?) --- x-plane-plugin/plugin.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 33023a81..9bc5c484 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -127,6 +127,8 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes } PLUGIN_API void XPluginStop ( void ) { + if (lck_posix) + PortableLockedShm_free(lck_posix); } PLUGIN_API void XPluginEnable ( void ) { -- cgit v1.2.3 From 4ab718bdd67ee0b5327269e24675070c2a705cc5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 20:32:46 +0200 Subject: xpl: rename user-visible data following fork --- x-plane-plugin/plugin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 9bc5c484..eae2bf0b 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -108,19 +108,19 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes if (view_x && view_y && view_z && view_heading && view_pitch) { lck_posix = PortableLockedShm_init(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); if (lck_posix->mem == (void*)-1) { - fprintf(stderr, "FTNOIR failed to init SHM #1!\n"); + fprintf(stderr, "opentrack failed to init SHM #1!\n"); return 0; } if (lck_posix->mem == NULL) { - fprintf(stderr, "FTNOIR failed to init SHM #2!\n"); + fprintf(stderr, "opentrack failed to init SHM #2!\n"); return 0; } shm_posix = (WineSHM*) lck_posix->mem; memset(shm_posix, 0, sizeof(WineSHM)); - strcpy(outName, "FaceTrackNoIR"); - strcpy(outSignature, "FaceTrackNoIR - FreeTrack lives!"); - strcpy(outDescription, "Face tracking view control"); - fprintf(stderr, "FTNOIR init complete\n"); + strcpy(outName, "opentrack"); + strcpy(outSignature, "opentrack - freetrack lives!"); + strcpy(outDescription, "head tracking view control"); + fprintf(stderr, "opentrack init complete\n"); return 1; } return 0; -- cgit v1.2.3 From 4496e10f1315a72c915871801d95788884bfdb92 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:18:27 +0200 Subject: xpl: dead code. mmap(2) (void*)-1 on failure --- x-plane-plugin/plugin.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index eae2bf0b..dd771ab5 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -108,11 +108,7 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes if (view_x && view_y && view_z && view_heading && view_pitch) { 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 #1!\n"); - return 0; - } - if (lck_posix->mem == NULL) { - fprintf(stderr, "opentrack failed to init SHM #2!\n"); + fprintf(stderr, "opentrack failed to init SHM!\n"); return 0; } shm_posix = (WineSHM*) lck_posix->mem; -- cgit v1.2.3 From 629d7221887f506f1542ec8970569fb48210dfdb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:22:06 +0200 Subject: xpl: pass -Wall -pedantic in gnuc89 --- x-plane-plugin/plugin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index dd771ab5..1f30f04d 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -19,7 +19,7 @@ #define PLUGIN_API #endif -// using Wine name to ease things +/* using Wine name to ease things */ #define WINE_SHM_NAME "facetracknoir-wine-shm" #define WINE_MTX_NAME "facetracknoir-wine-mtx" @@ -48,7 +48,7 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *mutex strncpy(shm_filename+1, shmName, NAME_MAX-2); shm_filename[NAME_MAX-1] = '\0'; sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid()); - //(void) shm_unlink(shm_filename); + /* (void) shm_unlink(shm_filename); */ self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); if (ftruncate(self->fd, mapSize) == 0) @@ -60,7 +60,7 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *mutex void PortableLockedShm_free(PortableLockedShm* self) { - //(void) shm_unlink(shm_filename); + /*(void) shm_unlink(shm_filename);*/ (void) munmap(self->mem, self->size); (void) close(self->fd); free(self); -- cgit v1.2.3 From 3e71e6218557bf14220a23d5afb772c170545cb4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:30:53 +0200 Subject: reformat Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 1f30f04d..67dab7ad 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -83,8 +83,8 @@ static void reinit_offset() { } int write_head_position( - XPLMDrawingPhase inPhase, - int inIsBefore, + XPLMDrawingPhase inPhase, + int inIsBefore, void * inRefcon) { if (lck_posix != NULL && shm_posix != NULL) { -- cgit v1.2.3 From a8a8cfac5f1be7e0cbfadcc2def8aaa0e8d9d9a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:44:58 +0200 Subject: all except 3rdparty-maintained stuff pass -Wall -Wextra -pedantic Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/boost-compat.h | 2 +- ftnoir_csv/csv.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 4 ++-- ftnoir_tracker_aruco/include/boarddetector.h | 2 +- ftnoir_tracker_aruco/include/cvdrawingutils.h | 2 +- ftnoir_tracker_aruco/include/markerdetector.h | 6 +----- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 4 ++-- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 6 +++--- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 5 +---- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 8 ++++---- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 8 ++++---- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 2 +- x-plane-plugin/plugin.c | 20 +++++++++++++------- 16 files changed, 40 insertions(+), 41 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/FTNoIR_Tracker_PT/boost-compat.h b/FTNoIR_Tracker_PT/boost-compat.h index b5be237a..612f2c4d 100644 --- a/FTNoIR_Tracker_PT/boost-compat.h +++ b/FTNoIR_Tracker_PT/boost-compat.h @@ -2,4 +2,4 @@ #include namespace boost { using std::shared_ptr; -}; +} diff --git a/ftnoir_csv/csv.cpp b/ftnoir_csv/csv.cpp index 4e76e844..ebdf50bb 100644 --- a/ftnoir_csv/csv.cpp +++ b/ftnoir_csv/csv.cpp @@ -138,7 +138,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { QByteArray id = gameLine.at(7).toLatin1(); unsigned int tmp[8]; - int fuzz[3]; + unsigned int fuzz[3]; if (gameLine.at(3) == QString("V160")) { qDebug() << "no table"; @@ -155,7 +155,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) tmp + 6, tmp + 5, tmp + 4, - fuzz + 1) != 11 || ((fuzz[2] << 8) | fuzz[0]) != gameLine.at(0).toInt()) + fuzz + 1) != 11 || (int) ((fuzz[2] << 8) | fuzz[0]) != gameLine.at(0).toInt()) { qDebug() << "scanf failed" << fuzz[0] << fuzz[1] << fuzz[2]; } diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index c735b479..a221c2ff 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -385,11 +385,11 @@ TrackerControls::~TrackerControls() { } -void TrackerControls::showEvent(QShowEvent *event) +void TrackerControls::showEvent(QShowEvent *) { } -void TrackerControls::Initialize(QWidget* parent) +void TrackerControls::Initialize(QWidget*) { loadSettings(); show(); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 0f811f5d..260ca41e 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -54,9 +54,9 @@ public: explicit TrackerControls(); virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); - void Initialize(QWidget *parent); + void Initialize(QWidget *); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_aruco/include/boarddetector.h b/ftnoir_tracker_aruco/include/boarddetector.h index a0ee2361..4770b5c9 100644 --- a/ftnoir_tracker_aruco/include/boarddetector.h +++ b/ftnoir_tracker_aruco/include/boarddetector.h @@ -134,6 +134,6 @@ private: }; -}; +} #endif diff --git a/ftnoir_tracker_aruco/include/cvdrawingutils.h b/ftnoir_tracker_aruco/include/cvdrawingutils.h index ff67242f..38e9986e 100644 --- a/ftnoir_tracker_aruco/include/cvdrawingutils.h +++ b/ftnoir_tracker_aruco/include/cvdrawingutils.h @@ -46,7 +46,7 @@ namespace aruco static void draw3dCube(cv::Mat &Image,Board &m,const CameraParameters &CP); }; -}; +} #endif diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h index 68aa7f8a..4d6e7b90 100644 --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -353,9 +353,5 @@ private: void draw(cv::Mat out,const std::vector &markers ); }; - - - - -}; +} #endif diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index b4fd03f6..14cd3942 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -305,11 +305,11 @@ TrackerControls::~TrackerControls() { } -void TrackerControls::showEvent(QShowEvent *event) +void TrackerControls::showEvent(QShowEvent *) { } -void TrackerControls::Initialize(QWidget* parent) +void TrackerControls::Initialize(QWidget*) { loadSettings(); show(); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 96607411..aae4e6d6 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -46,10 +46,10 @@ public: explicit TrackerControls(); virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {} + void Initialize(QWidget *); + void registerTracker(ITracker *) {} void unRegisterTracker() {} private: diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 7333fbc4..86ca8888 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -48,7 +48,7 @@ void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_s } }*/ -void Hydra_Tracker::StartTracker(QFrame* videoFrame) +void Hydra_Tracker::StartTracker(QFrame*) { //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton); loadSettings(); @@ -78,9 +78,6 @@ bool Hydra_Tracker::GiveHeadPoseData(double *data) //Rotation quat = Rotation(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);// sixenseMath::Quat(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); - double yaw = 0.0f; - double pitch = 0.0f; - double roll = 0.0f; float ypr[3]; mat.getEulerAngles().fill(ypr); diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 82a72f56..19f2a685 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -11,7 +11,7 @@ public: Hydra_Tracker(); ~Hydra_Tracker(); - void StartTracker( QFrame *videoframe ); + void StartTracker(QFrame *); bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; @@ -44,11 +44,11 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; + void registerTracker(ITracker *) {} + void unRegisterTracker() {} private: Ui::UIHydraControls ui; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 913f8070..165f8573 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -81,7 +81,7 @@ void TrackerControls::doOK() { } // override show event -void TrackerControls::showEvent ( QShowEvent * event ) { +void TrackerControls::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index d67fb636..1539707e 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -88,7 +88,7 @@ quint16 senderPort; } } -void FTNoIR_Tracker::StartTracker(QFrame* videoFrame) +void FTNoIR_Tracker::StartTracker(QFrame*) { loadSettings(); // diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index e5ea7ff3..d158630b 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -15,7 +15,7 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void StartTracker( QFrame *videoframe ); + void StartTracker(QFrame *); bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; @@ -49,11 +49,11 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; + void registerTracker(ITracker *) {} + void unRegisterTracker() {} private: Ui::UICFTNClientControls ui; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 55bb6c97..e17d5c32 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -81,7 +81,7 @@ void TrackerControls::doOK() { } // override show event -void TrackerControls::showEvent ( QShowEvent * event ) { +void TrackerControls::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 67dab7ad..38e1e7bf 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -40,7 +40,13 @@ 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; -PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *mutexName, int mapSize) +#ifdef __GNUC__ +# define OT_UNUSED(varname) varname __attribute__((__unused__)) +#else +# define OT_UNUSED(varname) varname +#endif + +PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UNUSED(mutexName), int mapSize) { PortableLockedShm* self = malloc(sizeof(PortableLockedShm)); char shm_filename[NAME_MAX]; @@ -83,9 +89,9 @@ static void reinit_offset() { } int write_head_position( - XPLMDrawingPhase inPhase, - int inIsBefore, - void * inRefcon) + XPLMDrawingPhase OT_UNUSED(inPhase), + int OT_UNUSED(inIsBefore), + void * OT_UNUSED(inRefcon)) { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); @@ -140,9 +146,9 @@ PLUGIN_API void XPluginDisable ( void ) { } PLUGIN_API void XPluginReceiveMessage( - XPLMPluginID inFromWho, - int inMessage, - void * inParam) + XPLMPluginID OT_UNUSED(inFromWho), + int OT_UNUSED(inMessage), + void * OT_UNUSED(inParam)) { if (inMessage == XPLM_MSG_AIRPORT_LOADED) reinit_offset(); -- cgit v1.2.3 From dea1031c422c1402bd05765c33e2dd4bdaf4f6ac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:35:32 +0100 Subject: update plugin. now using radians in shm Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 38e1e7bf..ec0e1871 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -40,6 +40,12 @@ 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 void reinit_offset() { + offset_x = XPLMGetDataf(view_x); + offset_y = XPLMGetDataf(view_y); + offset_z = XPLMGetDataf(view_z); +} + #ifdef __GNUC__ # define OT_UNUSED(varname) varname __attribute__((__unused__)) #else @@ -82,33 +88,27 @@ void PortableLockedShm_unlock(PortableLockedShm* self) flock(self->fd, LOCK_UN); } -static void reinit_offset() { - offset_x = XPLMGetDataf(view_x); - offset_y = XPLMGetDataf(view_y); - offset_z = XPLMGetDataf(view_z); -} - int write_head_position( - XPLMDrawingPhase OT_UNUSED(inPhase), - int OT_UNUSED(inIsBefore), - void * OT_UNUSED(inRefcon)) + XPLMDrawingPhase OT_UNUSED(inPhase), + int OT_UNUSED(inIsBefore), + void * OT_UNUSED(inRefcon)) { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); - XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-2 + offset_x); - XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-2 + offset_y); - XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-2 + offset_z); - XPLMSetDataf(view_heading, shm_posix->data[Yaw]); - XPLMSetDataf(view_pitch, shm_posix->data[Pitch]); + XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3); + XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3); + XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3); + XPLMSetDataf(view_heading, shm_posix->data[Yaw] * 180 / 3.141592654); + XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / 3.141592654); PortableLockedShm_unlock(lck_posix); } return 1; } 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_x = XPLMFindDataRef("sim/graphics/view/pilots_head_x"); + view_y = XPLMFindDataRef("sim/graphics/view/pilots_head_y"); + view_z = XPLMFindDataRef("sim/graphics/view/pilots_head_z"); 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) { @@ -134,21 +134,17 @@ PLUGIN_API void XPluginStop ( void ) { } PLUGIN_API void XPluginEnable ( void ) { - reinit_offset(); XPLMRegisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); } PLUGIN_API void XPluginDisable ( void ) { XPLMUnregisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); - XPLMSetDataf(view_x, offset_x); - XPLMSetDataf(view_y, offset_y); - XPLMSetDataf(view_z, offset_z); } PLUGIN_API void XPluginReceiveMessage( - XPLMPluginID OT_UNUSED(inFromWho), - int OT_UNUSED(inMessage), - void * OT_UNUSED(inParam)) + XPLMPluginID OT_UNUSED(inFromWho), + int OT_UNUSED(inMessage), + void * OT_UNUSED(inParam)) { if (inMessage == XPLM_MSG_AIRPORT_LOADED) reinit_offset(); -- cgit v1.2.3 From 598ccf7316a44b5a31eb3c0c1850123985c1c5a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:45:52 +0100 Subject: use proper origin Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index ec0e1871..2c43b98d 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -95,9 +95,9 @@ int write_head_position( { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); - XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3); - XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3); - XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3); + 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); @@ -106,9 +106,9 @@ int write_head_position( } PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDescription ) { - view_x = XPLMFindDataRef("sim/graphics/view/pilots_head_x"); - view_y = XPLMFindDataRef("sim/graphics/view/pilots_head_y"); - view_z = XPLMFindDataRef("sim/graphics/view/pilots_head_z"); + 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) { -- cgit v1.2.3 From 1b49a5e35ee4ee488cab443c0e040a2e58a76af0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 17:57:08 +0100 Subject: fix bitrot shm name Reported-by: runningman84 Issue: github issue #10 Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 1 - 1 file changed, 1 deletion(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 2c43b98d..a8fd28d2 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -59,7 +59,6 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UN shm_filename[0] = '/'; strncpy(shm_filename+1, shmName, NAME_MAX-2); shm_filename[NAME_MAX-1] = '\0'; - sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid()); /* (void) shm_unlink(shm_filename); */ self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); -- cgit v1.2.3 From f413502750855ea1394e12650395697bcab01498 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 18:01:04 +0100 Subject: fix x-plane crashing on exit Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index a8fd28d2..ed6cdaff 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -129,7 +129,11 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes PLUGIN_API void XPluginStop ( void ) { if (lck_posix) + { PortableLockedShm_free(lck_posix); + lck_posix = NULL; + shm_posix = NULL; + } } PLUGIN_API void XPluginEnable ( void ) { -- cgit v1.2.3 From 3004416b35dea148212d4aa881ae099d20f3e313 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 18:05:40 +0100 Subject: untested merge from compat, hopefully fix osx Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'x-plane-plugin/plugin.c') diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index ed6cdaff..62c9d6f0 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -62,10 +62,8 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UN /* (void) shm_unlink(shm_filename); */ self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); - if (ftruncate(self->fd, mapSize) == 0) - self->mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, self->fd, (off_t)0); - else - self->mem = (void*) -1; + (void) ftruncate(self->fd, mapSize); + self->mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, self->fd, (off_t)0); return self; } -- cgit v1.2.3