From ec1c2b16379d657db92c90e25b9e01393267b596 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:51:32 +0200 Subject: Clean up preprocessor mingw-isms No functional changes. --- compat/compat.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'compat/compat.h') diff --git a/compat/compat.h b/compat/compat.h index 7692b38a..6a95f167 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -6,7 +6,7 @@ */ #pragma once -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) #include #else #include @@ -19,7 +19,7 @@ #include #endif -#if defined(IN_FTNOIR_COMPAT) && (defined(_WIN32) || defined(__WIN32)) +#if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) # define COMPAT_EXPORT __declspec(dllexport) #else # define COMPAT_EXPORT @@ -33,7 +33,7 @@ public: void unlock(); void* mem; private: -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) HANDLE hMutex, hMapFile; #else int fd, size; -- cgit v1.2.3 From 74240d04b14cffc93693b0033b65907655fcf218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:46:28 +0200 Subject: Use __declspec(dllimport) --- compat/compat.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compat/compat.h') diff --git a/compat/compat.h b/compat/compat.h index 6a95f167..c34add10 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -21,8 +21,10 @@ #if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) # define COMPAT_EXPORT __declspec(dllexport) +#elif defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllimport) #else -# define COMPAT_EXPORT +# define COMPAT_EXPORT #endif class COMPAT_EXPORT PortableLockedShm { -- cgit v1.2.3 From f159fc2b84d2c7139c348d167c7491fb43fb7e5e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 20:24:25 +0200 Subject: proto-wine: fix warnings, dependencies, reformat --- CMakeLists.txt | 4 ++++ compat/compat.h | 12 ++++++++---- ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx | 7 +++++-- ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx | 4 ++++ 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'compat/compat.h') diff --git a/CMakeLists.txt b/CMakeLists.txt index bc734e43..6385f04d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,6 +416,9 @@ endif() if(NOT SDK_WINE_NO_WRAPPER) add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so + DEPENDS "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" + "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx" + "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" COMMAND "${SDK_WINE_PREFIX}/bin/wineg++" -g -O2 -m32 -o opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" @@ -423,6 +426,7 @@ endif() "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" -lrt) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) + add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() endif() diff --git a/compat/compat.h b/compat/compat.h index c34add10..3d54ae1d 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -19,10 +19,14 @@ #include #endif -#if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) -# define COMPAT_EXPORT __declspec(dllexport) -#elif defined(_WIN32) -# define COMPAT_EXPORT __declspec(dllimport) +#if !defined(OPENTRACK_COMPAT_BUNDLED) +# if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllexport) +# elif defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllimport) +# else +# define COMPAT_EXPORT +# endif #else # define COMPAT_EXPORT #endif diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx index c88dd332..42d39ff2 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx @@ -1,9 +1,12 @@ +#define OPENTRACK_COMPAT_BUNDLED #ifdef _WIN32 -#undef _WIN32 +# undef _WIN32 #endif + #ifdef __WIN32 -#undef __WIN32 +# undef __WIN32 #endif + #define PortableLockedShm ShmPosix #include "compat/compat.h" #include "compat/compat.cpp" diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx index 6d5484a9..e7102600 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx @@ -1,7 +1,11 @@ +#define OPENTRACK_COMPAT_BUNDLED + #ifndef __WIN32 #define __WIN32 #endif + #define PortableLockedShm ShmWine + #include "ftnoir_protocol_ft/fttypes.h" #include "compat/compat.h" #include "compat/compat.cpp" -- cgit v1.2.3 From af71f2534fc1e99ed7d483190e99d4dc674bcd76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:20:30 +0200 Subject: compat: new API, check for success --- compat/compat.cpp | 9 +++++++++ compat/compat.h | 1 + 2 files changed, 10 insertions(+) (limited to 'compat/compat.h') diff --git a/compat/compat.cpp b/compat/compat.cpp index d8aac9bc..f6261738 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,6 +61,15 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } +PortableLockedShm::success() +{ +#ifndef _WIN32 + return (void*) mem != (void*) -1 +#else + return (void*) mem != NULL; +#endif +} + PortableLockedShm::~PortableLockedShm() { //(void) shm_unlink(shm_filename); diff --git a/compat/compat.h b/compat/compat.h index 3d54ae1d..8c307b14 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -37,6 +37,7 @@ public: ~PortableLockedShm(); void lock(); void unlock(); + bool success(); void* mem; private: #if defined(_WIN32) -- cgit v1.2.3 From bbaefce3a90b3c45f23e494f76ed15fa9a00d5e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 21:34:49 +0100 Subject: fix apple build --- CMakeLists.txt | 31 ++++++++++++++++++++++--------- compat/compat.cpp | 19 ++++++------------- compat/compat.h | 3 ++- facetracknoir/main.cpp | 6 ++++++ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 18 +++++++++--------- 5 files changed, 45 insertions(+), 32 deletions(-) (limited to 'compat/compat.h') diff --git a/CMakeLists.txt b/CMakeLists.txt index d17279c2..242d200d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if(GIT_FOUND) endif() SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) SET(CMAKE_SKIP_INSTALL_RPATH FALSE) SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") @@ -23,8 +23,12 @@ if(MSVC) add_definitions(-DNOMINMAX) endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_definitions(-std=c++11) +if(NOT APPLE) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-std=c++11) + endif() +else() + set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS}") endif() if(CMAKE_COMPILER_IS_GNUCXX) @@ -92,7 +96,7 @@ endif() find_package(OpenCV REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) - cmake_policy(SET CMP0020 NEW) + cmake_policy(SET CMP0020 NEW) include_directories(${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}) @@ -328,9 +332,9 @@ if(SDK_XPLANE) PREFIX "" SUFFIX "") endif() if(APPLE) - SET_TARGET_PROPERTIES(opentrack-xplane-plugin - COMPILE_FLAGS "-DAPL -DXPLM210 -framework XPLM -framework XPWidgets" - LINK_FLAGS "-framework XPLM -framework XPWidgets") + SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES + COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM210 -framework XPLM -framework XPWidgets" + LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") endif() if(UNIX AND NOT APPLE) target_link_libraries(opentrack-xplane-plugin rt) @@ -360,7 +364,12 @@ if(WIN32) set(my-qt-deps ws2_32) endif() -SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +if(APPLE) + link_directories(${CMAKE_INSTALL_PREFIX}) + set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core ${my-qt-deps}) +else() + SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +endif() add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -470,6 +479,10 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() if(NOT SDK_WINE_NO_WRAPPER) + set(my-rt -lrt) + if(APPLE) + set(my-rt) + endif() add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so DEPENDS "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" @@ -480,7 +493,7 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" - -lrt) + ${my-rt}) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() diff --git a/compat/compat.cpp b/compat/compat.cpp index bcdbd17f..7b695617 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -6,8 +6,7 @@ */ #define IN_FTNOIR_COMPAT #include "compat.h" -#include -#include +#include #if defined(_WIN32) @@ -48,17 +47,11 @@ void PortableLockedShm::unlock() #else PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { - std::string filename; - filename.append("/"); - filename.append(shmName); - //(void) shm_unlink(shm_filename); - - fd = shm_open(filename.c_str(), O_RDWR | O_CREAT, 0600); - if (ftruncate(fd, mapSize) == 0) { ;; } - else { - fprintf(stderr, "oh, bother, ftruncate: %s\n", strerror(errno)); - //mem = (void*) -1; - } + char filename[512] = {0}; + strcpy(filename, "/"); + strcat(filename, shmName); + fd = shm_open(filename, O_RDWR | O_CREAT, 0600); + (void) ftruncate(fd, mapSize); mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); } diff --git a/compat/compat.h b/compat/compat.h index 8c307b14..60395830 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -7,7 +7,8 @@ #pragma once #if defined(_WIN32) -#include +#include +#include #else #include #include diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index e643bcd3..23703ef3 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #if defined(_WIN32) && defined(_MSC_VER) # include @@ -59,6 +61,10 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); +#ifdef __APPLE__ + QDir dir(QCoreApplication::applicationDirPath()); + QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath())); +#endif FaceTrackNoIR w; QDesktopWidget desktop; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index db0ef6d6..77eede52 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -62,7 +62,7 @@ static QList get_camera_names(void) { pEnumCat->Release(); } pSysDevEnum->Release(); -#else +#elsif !defined(__APPLE__) for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); @@ -281,15 +281,15 @@ TrackerControls::TrackerControls() { ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); - connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraName, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraFPS, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rx, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ry, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tx, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ty, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); -- cgit v1.2.3 From 4630c59e40361ccb500d1384c1c611648462f93c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 18:19:05 +0100 Subject: fix mingw-w64 build --- compat/compat.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'compat/compat.h') diff --git a/compat/compat.h b/compat/compat.h index 60395830..8c307b14 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -7,8 +7,7 @@ #pragma once #if defined(_WIN32) -#include -#include +#include #else #include #include -- cgit v1.2.3 From 693e922e82914f6ea5e2184c5487af1e1b4881b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:38:53 +0100 Subject: fix build Signed-off-by: Stanislaw Halik --- compat/compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compat/compat.h') diff --git a/compat/compat.h b/compat/compat.h index 8c307b14..0e488752 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -25,7 +25,7 @@ # elif defined(_WIN32) # define COMPAT_EXPORT __declspec(dllimport) # else -# define COMPAT_EXPORT +# define COMPAT_EXPORT __attribute__ ((visibility ("default"))) # endif #else # define COMPAT_EXPORT -- cgit v1.2.3