summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-16 12:34:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-16 12:35:51 +0200
commit0760fe011114fa440275b487eaf766b015f40e5b (patch)
treea0141fb291b7dc1e38d16dd0eb2c767ec93b310a
parent60460f56cabe0155996adf8ba5e9f6730ef0b203 (diff)
all: split "api" into "api" and "logic"
Here, the "logic" module has all the stuff for building one's own graphical user interface. The "api" module has stuff used by other trackers. While at it, each of "api", "logic", and "compat" need their own export headers. This is because of preprocessor symbol clashes. This is all because a change in the "gui"-only dependency required a relink of all the trackers, protocols, and flters. It takes too long when building in the release configuration. With the split, only the "gui" module gets rebuilt. Since it has close to no static dependencies, it's fast enough.
-rw-r--r--cmake/opentrack-version.cmake3
-rw-r--r--gui/CMakeLists.txt1
-rw-r--r--gui/curve-config.cpp6
-rw-r--r--gui/curve-config.h2
-rw-r--r--gui/keyboard.h4
-rw-r--r--gui/options-dialog.hpp2
-rw-r--r--gui/ui.cpp2
-rw-r--r--gui/ui.h10
-rw-r--r--opentrack-compat/camera-names.hpp6
-rw-r--r--opentrack-compat/export.hpp8
-rw-r--r--opentrack-compat/import.hpp20
-rw-r--r--opentrack-compat/options.hpp6
-rw-r--r--opentrack-compat/shm.h6
-rw-r--r--opentrack-compat/timer.hpp6
-rw-r--r--opentrack-logic/CMakeLists.txt10
-rw-r--r--opentrack-logic/export.hpp18
-rw-r--r--opentrack-logic/import.hpp13
-rw-r--r--opentrack-logic/keybinding-worker.cpp (renamed from opentrack/keybinding-worker.cpp)0
-rw-r--r--opentrack-logic/keybinding-worker.hpp (renamed from opentrack/keybinding-worker.hpp)10
-rw-r--r--opentrack-logic/main-settings.hpp (renamed from opentrack/main-settings.hpp)11
-rw-r--r--opentrack-logic/mappings.hpp (renamed from opentrack/mappings.hpp)0
-rw-r--r--opentrack-logic/nan.cpp (renamed from opentrack/nan.cpp)0
-rw-r--r--opentrack-logic/selected-libraries.cpp (renamed from opentrack/selected-libraries.cpp)2
-rw-r--r--opentrack-logic/selected-libraries.hpp (renamed from opentrack/selected-libraries.hpp)10
-rw-r--r--opentrack-logic/shortcuts.cpp (renamed from opentrack/shortcuts.cpp)0
-rw-r--r--opentrack-logic/shortcuts.h (renamed from opentrack/shortcuts.h)13
-rw-r--r--opentrack-logic/state.hpp (renamed from opentrack/state.hpp)8
-rw-r--r--opentrack-logic/tracker.cpp (renamed from opentrack/tracker.cpp)4
-rw-r--r--opentrack-logic/tracker.h (renamed from opentrack/tracker.h)20
-rw-r--r--opentrack-logic/win32-joystick.cpp (renamed from opentrack/win32-joystick.cpp)0
-rw-r--r--opentrack-logic/win32-joystick.hpp (renamed from opentrack/win32-joystick.hpp)26
-rw-r--r--opentrack-logic/win32-shortcuts.cpp (renamed from opentrack/win32-shortcuts.cpp)0
-rw-r--r--opentrack-logic/win32-shortcuts.h (renamed from opentrack/win32-shortcuts.h)10
-rw-r--r--opentrack-logic/work.hpp (renamed from opentrack/work.hpp)8
-rw-r--r--opentrack/CMakeLists.txt10
-rw-r--r--opentrack/dtors.cpp1
-rw-r--r--opentrack/export.hpp18
-rw-r--r--opentrack/import.hpp13
-rw-r--r--opentrack/plugin-api.hpp22
-rw-r--r--opentrack/simple-mat.hpp6
-rw-r--r--proto-wine/wine-shm.h4
-rw-r--r--tracker-joystick/CMakeLists.txt2
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick.h2
-rw-r--r--x-plane-plugin/plugin.c19
44 files changed, 192 insertions, 150 deletions
diff --git a/cmake/opentrack-version.cmake b/cmake/opentrack-version.cmake
index b5b18ff0..b1896b55 100644
--- a/cmake/opentrack-version.cmake
+++ b/cmake/opentrack-version.cmake
@@ -19,6 +19,7 @@ endif()
file(WRITE ${CMAKE_BINARY_DIR}/opentrack-version.h "#define OPENTRACK_VERSION \"${_build_type}${OPENTRACK_COMMIT}\"")
set(version-string "
+#define BUILD_compat
#include \"opentrack-compat/export.hpp\"
#ifdef __cplusplus
@@ -26,7 +27,7 @@ extern \"C\"
#else
extern
#endif
-OPENTRACK_EXPORT
+OPENTRACK_COMPAT_EXPORT
const char* opentrack_version;
const char* opentrack_version = \"${_build_type}${OPENTRACK_COMMIT}\";
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 08534795..b7448b4c 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -17,6 +17,7 @@ if(NOT WIN32)
endif()
target_link_libraries(opentrack
+ opentrack-logic
opentrack-spline-widget
opentrack-pose-widget
opentrack-version
diff --git a/gui/curve-config.cpp b/gui/curve-config.cpp
index e4396e01..61459c1c 100644
--- a/gui/curve-config.cpp
+++ b/gui/curve-config.cpp
@@ -7,7 +7,7 @@
*/
#include "curve-config.h"
-#include "opentrack/main-settings.hpp"
+#include "opentrack-logic/main-settings.hpp"
MapWidget::MapWidget(Mappings& m, main_settings& s) :
m(m)
{
@@ -54,12 +54,12 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) :
qfc.setEnabled(qfcs[i].checkbox->isChecked());
qfc.force_redraw();
}
-
+
if (qfcs[i].axis >= 3)
qfcs[i].qfc->set_snap(2, 5);
else
qfcs[i].qfc->set_snap(1, 5);
-
+
qfcs[i].qfc->setConfig(conf, name);
}
}
diff --git a/gui/curve-config.h b/gui/curve-config.h
index 0cbc7055..9a9475b9 100644
--- a/gui/curve-config.h
+++ b/gui/curve-config.h
@@ -1,6 +1,6 @@
#pragma once
#include <QWidget>
-#include "opentrack/mappings.hpp"
+#include "opentrack-logic/mappings.hpp"
#include "ui_mapping.h"
class MapWidget: public QWidget
diff --git a/gui/keyboard.h b/gui/keyboard.h
index 696df605..07f326ea 100644
--- a/gui/keyboard.h
+++ b/gui/keyboard.h
@@ -1,8 +1,8 @@
#pragma once
#include "ui_keyboard_listener.h"
#ifdef _WIN32
-#include "opentrack/win32-shortcuts.h"
-#include "opentrack/keybinding-worker.hpp"
+#include "opentrack-logic/win32-shortcuts.h"
+#include "opentrack-logic/keybinding-worker.hpp"
#endif
#include <QLabel>
#include <QKeyEvent>
diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp
index a879a208..eee9d090 100644
--- a/gui/options-dialog.hpp
+++ b/gui/options-dialog.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "ui_settings.h"
-#include "opentrack/shortcuts.h"
+#include "opentrack-logic/shortcuts.h"
#include <QObject>
#include <QWidget>
#include <functional>
diff --git a/gui/ui.cpp b/gui/ui.cpp
index fd86aca8..63f40cf8 100644
--- a/gui/ui.cpp
+++ b/gui/ui.cpp
@@ -7,7 +7,7 @@
*/
#include "ui.h"
-#include "opentrack/tracker.h"
+#include "opentrack-logic/tracker.h"
#include "opentrack-compat/options.hpp"
#include "new_file_dialog.h"
#include <QFileDialog>
diff --git a/gui/ui.h b/gui/ui.h
index 42c4630c..626b1bb3 100644
--- a/gui/ui.h
+++ b/gui/ui.h
@@ -23,12 +23,12 @@
#include "ui_main.h"
#include "opentrack-compat/options.hpp"
-#include "opentrack/main-settings.hpp"
+#include "opentrack-logic/main-settings.hpp"
#include "opentrack/plugin-support.hpp"
-#include "opentrack/tracker.h"
-#include "opentrack/shortcuts.h"
-#include "opentrack/work.hpp"
-#include "opentrack/state.hpp"
+#include "opentrack-logic/tracker.h"
+#include "opentrack-logic/shortcuts.h"
+#include "opentrack-logic/work.hpp"
+#include "opentrack-logic/state.hpp"
#include "curve-config.h"
#include "options-dialog.hpp"
#include "process_detector.h"
diff --git a/opentrack-compat/camera-names.hpp b/opentrack-compat/camera-names.hpp
index c2879000..ae0c6b25 100644
--- a/opentrack-compat/camera-names.hpp
+++ b/opentrack-compat/camera-names.hpp
@@ -11,11 +11,7 @@
#include <QList>
#include <QString>
-#ifdef BUILD_compat
-# include "compat-export.hpp"
-#else
-# include "compat-import.hpp"
-#endif
+#include "export.hpp"
OPENTRACK_COMPAT_EXPORT QList<QString> get_camera_names();
OPENTRACK_COMPAT_EXPORT int camera_name_to_index(const QString &name);
diff --git a/opentrack-compat/export.hpp b/opentrack-compat/export.hpp
index 100950a0..fbb62e1f 100644
--- a/opentrack-compat/export.hpp
+++ b/opentrack-compat/export.hpp
@@ -1,6 +1,6 @@
#pragma once
-#ifndef OPENTRACK_EXPORT
+#ifdef BUILD_compat
# ifdef _WIN32
# define OPENTRACK_LINKAGE __declspec(dllexport)
# else
@@ -8,8 +8,10 @@
# endif
# ifndef _MSC_VER
-# define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
+# define OPENTRACK_COMPAT_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
# else
-# define OPENTRACK_EXPORT OPENTRACK_LINKAGE
+# define OPENTRACK_COMPAT_EXPORT OPENTRACK_LINKAGE
# endif
+#else
+# include "import.hpp"
#endif
diff --git a/opentrack-compat/import.hpp b/opentrack-compat/import.hpp
index 3747b141..1b4aa8f1 100644
--- a/opentrack-compat/import.hpp
+++ b/opentrack-compat/import.hpp
@@ -1,15 +1,13 @@
#pragma once
-#ifndef OPENTRACK_EXPORT
-# ifdef _WIN32
-# define OPENTRACK_LINKAGE __declspec(dllimport)
-# else
-# define OPENTRACK_LINKAGE
-# endif
+#ifdef _WIN32
+# define OPENTRACK_LINKAGE __declspec(dllimport)
+#else
+# define OPENTRACK_LINKAGE
+#endif
-# ifndef _MSC_VER
-# define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
-# else
-# define OPENTRACK_EXPORT OPENTRACK_LINKAGE
-# endif
+#ifndef _MSC_VER
+# define OPENTRACK_COMPAT_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
+#else
+# define OPENTRACK_COMPAT_EXPORT OPENTRACK_LINKAGE
#endif
diff --git a/opentrack-compat/options.hpp b/opentrack-compat/options.hpp
index 17ab093c..b8db411a 100644
--- a/opentrack-compat/options.hpp
+++ b/opentrack-compat/options.hpp
@@ -42,11 +42,7 @@
#include <QDebug>
-#ifdef BUILD_compat
-# include "compat-export.hpp"
-#else
-# include "compat-import.hpp"
-#endif
+#include "export.hpp"
template<typename t> using mem = std::shared_ptr<t>;
diff --git a/opentrack-compat/shm.h b/opentrack-compat/shm.h
index 3edb0080..c7af4ac7 100644
--- a/opentrack-compat/shm.h
+++ b/opentrack-compat/shm.h
@@ -24,11 +24,7 @@
# pragma GCC diagnostic ignored "-Wattributes"
#endif
-#ifdef BUILD_compat
-# include "compat-export.hpp"
-#else
-# include "compat-import.hpp"
-#endif
+#include "export.hpp"
class OPENTRACK_COMPAT_EXPORT PortableLockedShm {
public:
diff --git a/opentrack-compat/timer.hpp b/opentrack-compat/timer.hpp
index 4f7e8d2e..c048844c 100644
--- a/opentrack-compat/timer.hpp
+++ b/opentrack-compat/timer.hpp
@@ -8,6 +8,9 @@
#pragma once
#include <ctime>
+
+#include "export.hpp"
+
#if defined (_WIN32)
# include <windows.h>
# ifndef CLOCK_MONOTONIC
@@ -52,7 +55,8 @@ static inline void clock_gettime(int, struct timespec* ts)
}
# endif
#endif
-class Timer {
+class OPENTRACK_COMPAT_EXPORT Timer
+{
private:
struct timespec state;
long long conv(const struct timespec& cur) const
diff --git a/opentrack-logic/CMakeLists.txt b/opentrack-logic/CMakeLists.txt
new file mode 100644
index 00000000..000276d5
--- /dev/null
+++ b/opentrack-logic/CMakeLists.txt
@@ -0,0 +1,10 @@
+opentrack_boilerplate(opentrack-logic)
+target_link_libraries(opentrack-logic opentrack-spline-widget)
+if(NOT WIN32)
+ target_link_libraries(opentrack-logic opentrack-qxt-mini)
+else()
+ target_link_libraries(opentrack-logic winmm)
+endif()
+if(CMAKE_COMPILER_IS_GNUCXX)
+ set_source_files_properties(nan.cpp PROPERTIES COMPILE_FLAGS "-fno-fast-math -fno-finite-math-only -fno-fast-math -O2")
+endif()
diff --git a/opentrack-logic/export.hpp b/opentrack-logic/export.hpp
new file mode 100644
index 00000000..699fdd6a
--- /dev/null
+++ b/opentrack-logic/export.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#ifdef BUILD_logic
+# ifdef _WIN32
+# define OPENTRACK_LOGIC_LINKAGE __declspec(dllexport)
+# else
+# define OPENTRACK_LOGIC_LINKAGE
+# endif
+
+# ifndef _MSC_VER
+# define OPENTRACK_LOGIC_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LOGIC_LINKAGE
+# else
+# define OPENTRACK_LOGIC_EXPORT OPENTRACK_LINKAGE
+# endif
+
+#else
+# include "import.hpp"
+#endif \ No newline at end of file
diff --git a/opentrack-logic/import.hpp b/opentrack-logic/import.hpp
new file mode 100644
index 00000000..8a3e80c1
--- /dev/null
+++ b/opentrack-logic/import.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifdef _WIN32
+# define OPENTRACK_LOGIC_LINKAGE __declspec(dllimport)
+#else
+# define OPENTRACK_LOGIC_LINKAGE
+#endif
+
+#ifndef _MSC_VER
+# define OPENTRACK_LOGIC_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LOGIC_LINKAGE
+#else
+# define OPENTRACK_LOGIC_EXPORT OPENTRACK_LOGIC_LINKAGE
+#endif
diff --git a/opentrack/keybinding-worker.cpp b/opentrack-logic/keybinding-worker.cpp
index a0c7178c..a0c7178c 100644
--- a/opentrack/keybinding-worker.cpp
+++ b/opentrack-logic/keybinding-worker.cpp
diff --git a/opentrack/keybinding-worker.hpp b/opentrack-logic/keybinding-worker.hpp
index 19db0fa9..12237ab0 100644
--- a/opentrack/keybinding-worker.hpp
+++ b/opentrack-logic/keybinding-worker.hpp
@@ -8,14 +8,10 @@
#pragma once
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
+#include "export.hpp"
#include "opentrack-compat/timer.hpp"
-#include "opentrack/win32-joystick.hpp"
+#include "win32-joystick.hpp"
#include <QThread>
#include <QMutex>
#include <QWidget>
@@ -42,7 +38,7 @@ public:
bool should_process();
};
-struct OPENTRACK_EXPORT KeybindingWorker : private QThread
+struct OPENTRACK_LOGIC_EXPORT KeybindingWorker : private QThread
{
private:
LPDIRECTINPUT8 din;
diff --git a/opentrack/main-settings.hpp b/opentrack-logic/main-settings.hpp
index 7c04fd6d..16ff59e4 100644
--- a/opentrack/main-settings.hpp
+++ b/opentrack-logic/main-settings.hpp
@@ -14,7 +14,10 @@
using namespace options;
-struct axis_opts {
+#include "export.hpp"
+
+struct axis_opts
+{
pbundle b;
value<double> zero;
value<bool> invert, altp;
@@ -32,7 +35,8 @@ private:
}
};
-struct key_opts {
+struct key_opts
+{
value<QString> keycode, guid;
value<int> button;
@@ -43,7 +47,8 @@ struct key_opts {
{}
};
-struct main_settings : opts {
+struct main_settings : opts
+{
value<QString> tracker_dll, filter_dll, protocol_dll;
axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll;
value<bool> tcomp_p, tcomp_tz;
diff --git a/opentrack/mappings.hpp b/opentrack-logic/mappings.hpp
index 087ea7f3..087ea7f3 100644
--- a/opentrack/mappings.hpp
+++ b/opentrack-logic/mappings.hpp
diff --git a/opentrack/nan.cpp b/opentrack-logic/nan.cpp
index 2522ba38..2522ba38 100644
--- a/opentrack/nan.cpp
+++ b/opentrack-logic/nan.cpp
diff --git a/opentrack/selected-libraries.cpp b/opentrack-logic/selected-libraries.cpp
index 63517774..4a1a9f09 100644
--- a/opentrack/selected-libraries.cpp
+++ b/opentrack-logic/selected-libraries.cpp
@@ -1,4 +1,4 @@
-#include "opentrack/selected-libraries.hpp"
+#include "selected-libraries.hpp"
#include <QDebug>
SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) :
diff --git a/opentrack/selected-libraries.hpp b/opentrack-logic/selected-libraries.hpp
index b396b5ec..2538adff 100644
--- a/opentrack/selected-libraries.hpp
+++ b/opentrack-logic/selected-libraries.hpp
@@ -11,14 +11,10 @@
#include "opentrack/plugin-support.hpp"
#include <QFrame>
+#include "export.hpp"
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
-
-struct OPENTRACK_EXPORT SelectedLibraries {
+struct OPENTRACK_LOGIC_EXPORT SelectedLibraries
+{
using dylibptr = mem<dylib>;
mem<ITracker> pTracker;
mem<IFilter> pFilter;
diff --git a/opentrack/shortcuts.cpp b/opentrack-logic/shortcuts.cpp
index 06c246af..06c246af 100644
--- a/opentrack/shortcuts.cpp
+++ b/opentrack-logic/shortcuts.cpp
diff --git a/opentrack/shortcuts.h b/opentrack-logic/shortcuts.h
index 2362c88b..87e24d4f 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack-logic/shortcuts.h
@@ -12,15 +12,11 @@
#include <vector>
#include <functional>
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
+#include "export.hpp"
#include "qxt-mini/QxtGlobalShortcut"
#include "opentrack-compat/options.hpp"
-#include "opentrack/main-settings.hpp"
+#include "main-settings.hpp"
#ifdef _WIN32
# include "keybinding-worker.hpp"
@@ -34,7 +30,8 @@
using namespace options;
-struct OPENTRACK_EXPORT Shortcuts : public QObject {
+struct OPENTRACK_LOGIC_EXPORT Shortcuts : public QObject
+{
Q_OBJECT
public:
@@ -45,7 +42,7 @@ public:
Key
#endif
;
-
+
using fun = std::function<void(bool)>;
using tt = std::tuple<K, fun, bool>;
std::vector<tt> keys;
diff --git a/opentrack/state.hpp b/opentrack-logic/state.hpp
index dcb18293..ff46cc36 100644
--- a/opentrack/state.hpp
+++ b/opentrack-logic/state.hpp
@@ -12,10 +12,10 @@
#include "opentrack-compat/options.hpp"
using namespace options;
#include "opentrack/plugin-support.hpp"
-#include "opentrack/main-settings.hpp"
-#include "opentrack/mappings.hpp"
-#include "opentrack/selected-libraries.hpp"
-#include "opentrack/work.hpp"
+#include "main-settings.hpp"
+#include "mappings.hpp"
+#include "selected-libraries.hpp"
+#include "work.hpp"
struct State {
State() :
diff --git a/opentrack/tracker.cpp b/opentrack-logic/tracker.cpp
index 9d754324..3b3f35e6 100644
--- a/opentrack/tracker.cpp
+++ b/opentrack-logic/tracker.cpp
@@ -30,7 +30,7 @@ Tracker::Tracker(main_settings& s, Mappings &m, SelectedLibraries &libs) :
zero_(false),
should_quit(false),
libs(libs),
- r_b(dmat<3,3>::eye()),
+ r_b(rmat::eye()),
t_b {0,0,0}
{
}
@@ -173,7 +173,6 @@ void Tracker::logic()
{
double tmp[3] = { t(0) - t_b[0], t(1) - t_b[1], t(2) - t_b[2] };
- t_compensate(cam, tmp, tmp, false);
rmat m_;
switch (s.center_method)
{
@@ -264,6 +263,7 @@ void Tracker::run()
t.start();
double tmp[6] {0,0,0, 0,0,0};
+ t_compensate(cam, tmp, tmp, false);
libs.pTracker->data(tmp);
if (enabledp)
diff --git a/opentrack/tracker.h b/opentrack-logic/tracker.h
index ea831eb0..591ca03c 100644
--- a/opentrack/tracker.h
+++ b/opentrack-logic/tracker.h
@@ -11,9 +11,9 @@
#include <vector>
#include "opentrack-compat/timer.hpp"
-#include "plugin-support.hpp"
+#include "opentrack/plugin-support.hpp"
#include "mappings.hpp"
-#include "simple-mat.hpp"
+#include "opentrack/simple-mat.hpp"
#include "selected-libraries.hpp"
#include "spline-widget/functionconfig.h"
@@ -23,7 +23,10 @@
#include <QMutex>
#include <QThread>
-class Pose {
+#include "export.hpp"
+
+class Pose
+{
private:
static constexpr double pi = 3.141592653;
static constexpr double d2r = pi/180.0;
@@ -40,13 +43,8 @@ public:
inline double operator()(int i) const { return axes[i]; }
};
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
-
-class OPENTRACK_EXPORT Tracker : private QThread {
+class OPENTRACK_LOGIC_EXPORT Tracker : private QThread
+{
Q_OBJECT
private:
QMutex mtx;
@@ -65,7 +63,7 @@ private:
using rmat = dmat<3, 3>;
- dmat<3, 3> r_b;
+ rmat r_b;
double t_b[3];
double map(double pos, Mapping& axis);
diff --git a/opentrack/win32-joystick.cpp b/opentrack-logic/win32-joystick.cpp
index bf919f4a..bf919f4a 100644
--- a/opentrack/win32-joystick.cpp
+++ b/opentrack-logic/win32-joystick.cpp
diff --git a/opentrack/win32-joystick.hpp b/opentrack-logic/win32-joystick.hpp
index 9c888326..d9b62e45 100644
--- a/opentrack/win32-joystick.hpp
+++ b/opentrack-logic/win32-joystick.hpp
@@ -2,6 +2,8 @@
#ifdef _WIN32
+#include "export.hpp"
+
#include <cstring>
#include <memory>
#include <vector>
@@ -31,18 +33,12 @@ struct hash<QString>
};
}
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
-
-struct OPENTRACK_EXPORT win32_joy_ctx
+struct OPENTRACK_LOGIC_EXPORT win32_joy_ctx
{
using fn = std::function<void(const QString& guid, int btn, bool held)>;
-
+
enum { joy_axis_size = 65535 };
-
+
struct joy_info
{
QString name, guid;
@@ -51,10 +47,10 @@ struct OPENTRACK_EXPORT win32_joy_ctx
void poll(fn f);
bool poll_axis(const QString& guid, int axes[8]);
std::vector<joy_info> get_joy_info();
-
+
win32_joy_ctx(const win32_joy_ctx&) = delete;
win32_joy_ctx& operator=(const win32_joy_ctx&) = delete;
-
+
win32_joy_ctx();
~win32_joy_ctx();
void refresh();
@@ -62,10 +58,10 @@ private:
QMutex mtx;
QMainWindow fake_main_window;
LPDIRECTINPUT8 di;
-
+
static QString guid_to_string(const GUID guid);
void release();
-
+
struct joy
{
LPDIRECTINPUTDEVICE8 joy_handle;
@@ -80,7 +76,7 @@ private:
void release();
bool poll(fn f);
};
-
+
std::unordered_map<QString, std::shared_ptr<joy>> joys;
class enum_state
@@ -88,7 +84,7 @@ private:
std::unordered_map<QString, std::shared_ptr<joy>> joys;
QMainWindow& fake_main_window;
LPDIRECTINPUT8 di;
-
+
std::vector<QString> all;
static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext);
static BOOL CALLBACK EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* ctx);
diff --git a/opentrack/win32-shortcuts.cpp b/opentrack-logic/win32-shortcuts.cpp
index a93803a3..a93803a3 100644
--- a/opentrack/win32-shortcuts.cpp
+++ b/opentrack-logic/win32-shortcuts.cpp
diff --git a/opentrack/win32-shortcuts.h b/opentrack-logic/win32-shortcuts.h
index 9b2c6121..7626a31f 100644
--- a/opentrack/win32-shortcuts.h
+++ b/opentrack-logic/win32-shortcuts.h
@@ -3,20 +3,16 @@
#ifdef _WIN32
#include <QKeySequence>
-#include "opentrack/shortcuts.h"
+#include "shortcuts.h"
struct win_key;
extern QList<win_key> windows_key_mods;
extern QList<win_key> windows_key_sequences;
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
+#include "export.hpp"
-struct OPENTRACK_EXPORT win_key
+struct OPENTRACK_LOGIC_EXPORT win_key
{
win_key(int win, Qt::Key qt) : win(win), qt(qt) {}
int win;
diff --git a/opentrack/work.hpp b/opentrack-logic/work.hpp
index 3b65ba52..2377be5a 100644
--- a/opentrack/work.hpp
+++ b/opentrack-logic/work.hpp
@@ -8,10 +8,10 @@
#pragma once
-#include "opentrack/main-settings.hpp"
+#include "main-settings.hpp"
#include "opentrack/plugin-support.hpp"
-#include "opentrack/tracker.h"
-#include "opentrack/shortcuts.h"
+#include "tracker.h"
+#include "shortcuts.h"
#include <QObject>
#include <QFrame>
@@ -30,7 +30,7 @@ struct Work
using fn = std::function<void(bool)>;
using tt = std::tuple<key_opts&, fn, bool>;
std::vector<tt> keys;
-
+
Work(main_settings& s, Mappings& m, SelectedLibraries& libs, WId handle) :
s(s), libs(libs),
tracker(std::make_shared<Tracker>(s, m, libs)),
diff --git a/opentrack/CMakeLists.txt b/opentrack/CMakeLists.txt
index dd90bda6..6dc6a96d 100644
--- a/opentrack/CMakeLists.txt
+++ b/opentrack/CMakeLists.txt
@@ -1,10 +1,2 @@
opentrack_boilerplate(opentrack-api NO-COMPAT)
-target_link_libraries(opentrack-api opentrack-spline-widget opentrack-compat)
-if(NOT WIN32)
- target_link_libraries(opentrack-api opentrack-qxt-mini)
-else()
- target_link_libraries(opentrack-api winmm)
-endif()
-if(CMAKE_COMPILER_IS_GNUCXX)
- set_source_files_properties(nan.cpp PROPERTIES COMPILE_FLAGS "-fno-fast-math -fno-finite-math-only -fno-fast-math -O2")
-endif()
+target_link_libraries(opentrack-api opentrack-compat)
diff --git a/opentrack/dtors.cpp b/opentrack/dtors.cpp
index 578d067a..5cc87187 100644
--- a/opentrack/dtors.cpp
+++ b/opentrack/dtors.cpp
@@ -1,5 +1,4 @@
#include "plugin-api.hpp"
-#include "main-settings.hpp"
// these exist only so that vtable is emitted in a single compilation unit, not all of them.
diff --git a/opentrack/export.hpp b/opentrack/export.hpp
new file mode 100644
index 00000000..2dab8bef
--- /dev/null
+++ b/opentrack/export.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#ifdef BUILD_api
+# ifdef _WIN32
+# define OPENTRACK_API_LINKAGE __declspec(dllexport)
+# else
+# define OPENTRACK_API_LINKAGE
+# endif
+
+# ifndef _MSC_VER
+# define OPENTRACK_API_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_API_LINKAGE
+# else
+# define OPENTRACK_API_EXPORT OPENTRACK_LINKAGE
+# endif
+
+#else
+# include "import.hpp"
+#endif
diff --git a/opentrack/import.hpp b/opentrack/import.hpp
new file mode 100644
index 00000000..7448416a
--- /dev/null
+++ b/opentrack/import.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifdef _WIN32
+# define OPENTRACK_API_LINKAGE __declspec(dllimport)
+#else
+# define OPENTRACK_API_LINKAGE
+#endif
+
+#ifndef _MSC_VER
+# define OPENTRACK_API_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_API_LINKAGE
+#else
+# define OPENTRACK_API_EXPORT OPENTRACK_API_LINKAGE
+#endif
diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp
index e715780e..6cd76a16 100644
--- a/opentrack/plugin-api.hpp
+++ b/opentrack/plugin-api.hpp
@@ -13,11 +13,7 @@
#include <QFrame>
#include <QIcon>
-#ifdef BUILD_api
-# include "opentrack-compat/export.hpp"
-#else
-# include "opentrack-compat/import.hpp"
-#endif
+#include "export.hpp"
#ifndef OPENTRACK_PLUGIN_EXPORT
# ifdef _WIN32
@@ -39,7 +35,7 @@ enum Axis {
namespace plugin_api {
namespace detail {
-class OPENTRACK_EXPORT BaseDialog : public QWidget
+class OPENTRACK_API_EXPORT BaseDialog : public QWidget
{
Q_OBJECT
public:
@@ -67,7 +63,7 @@ signals:
// implement this in all plugins
// also you must link against "opentrack-api" in CMakeLists.txt to avoid vtable link errors
-struct OPENTRACK_EXPORT Metadata
+struct OPENTRACK_API_EXPORT Metadata
{
Metadata(const Metadata&) = delete;
Metadata(Metadata&&) = delete;
@@ -83,7 +79,7 @@ struct OPENTRACK_EXPORT Metadata
};
// implement this in filters
-struct OPENTRACK_EXPORT IFilter
+struct OPENTRACK_API_EXPORT IFilter
{
IFilter(const IFilter&) = delete;
IFilter(IFilter&&) = delete;
@@ -99,7 +95,7 @@ struct OPENTRACK_EXPORT IFilter
virtual void center() {}
};
-struct OPENTRACK_EXPORT IFilterDialog : public plugin_api::detail::BaseDialog
+struct OPENTRACK_API_EXPORT IFilterDialog : public plugin_api::detail::BaseDialog
{
// optional destructor
virtual ~IFilterDialog();
@@ -114,7 +110,7 @@ struct OPENTRACK_EXPORT IFilterDialog : public plugin_api::detail::BaseDialog
OPENTRACK_DECLARE_PLUGIN_INTERNAL(filter_class, IFilter, metadata_class, dialog_class, IFilterDialog)
// implement this in protocols
-struct OPENTRACK_EXPORT IProtocol
+struct OPENTRACK_API_EXPORT IProtocol
{
IProtocol(const IProtocol&) = delete;
IProtocol(IProtocol&&) = delete;
@@ -132,7 +128,7 @@ struct OPENTRACK_EXPORT IProtocol
virtual QString game_name() = 0;
};
-struct OPENTRACK_EXPORT IProtocolDialog : public plugin_api::detail::BaseDialog
+struct OPENTRACK_API_EXPORT IProtocolDialog : public plugin_api::detail::BaseDialog
{
// optional destructor
virtual ~IProtocolDialog();
@@ -147,7 +143,7 @@ struct OPENTRACK_EXPORT IProtocolDialog : public plugin_api::detail::BaseDialog
OPENTRACK_DECLARE_PLUGIN_INTERNAL(protocol_class, IProtocol, metadata_class, dialog_class, IProtocolDialog)
// implement this in trackers
-struct OPENTRACK_EXPORT ITracker
+struct OPENTRACK_API_EXPORT ITracker
{
ITracker(const ITracker&) = delete;
ITracker(ITracker&&) = delete;
@@ -162,7 +158,7 @@ struct OPENTRACK_EXPORT ITracker
virtual void data(double *data) = 0;
};
-struct OPENTRACK_EXPORT ITrackerDialog : public plugin_api::detail::BaseDialog
+struct OPENTRACK_API_EXPORT ITrackerDialog : public plugin_api::detail::BaseDialog
{
// optional destructor
virtual ~ITrackerDialog();
diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp
index 54ebb920..ce2bccc5 100644
--- a/opentrack/simple-mat.hpp
+++ b/opentrack/simple-mat.hpp
@@ -242,16 +242,18 @@ public:
}
};
+#include "export.hpp"
+
namespace euler {
template<int y, int x> using dmat = Mat<double, y, x>;
using rmat = dmat<3, 3>;
using euler_t = dmat<3, 1>;
-rmat euler_to_rmat(const double* input);
+rmat OPENTRACK_API_EXPORT euler_to_rmat(const double* input);
// http://stackoverflow.com/a/18436193
-euler_t rmat_to_euler(const dmat<3, 3>& R);
+euler_t OPENTRACK_API_EXPORT rmat_to_euler(const dmat<3, 3>& R);
} // end ns euler
diff --git a/proto-wine/wine-shm.h b/proto-wine/wine-shm.h
index c7e29abb..a717dcc8 100644
--- a/proto-wine/wine-shm.h
+++ b/proto-wine/wine-shm.h
@@ -4,9 +4,7 @@
#define WINE_MTX_NAME "facetracknoir-wine-mtx"
// OSX sdk 10.8 build error otherwise
-#ifdef _LIBCPP_MSVCRT
-# undef _LIBCPP_MSVCRT
-#endif
+#undef _LIBCPP_MSVCRT
#include <memory>
diff --git a/tracker-joystick/CMakeLists.txt b/tracker-joystick/CMakeLists.txt
index b5fbcf75..e0b6f281 100644
--- a/tracker-joystick/CMakeLists.txt
+++ b/tracker-joystick/CMakeLists.txt
@@ -1,3 +1,5 @@
if(WIN32)
opentrack_boilerplate(opentrack-tracker-joystick)
+ target_link_libraries(opentrack-tracker-joystick opentrack-logic)
endif()
+
diff --git a/tracker-joystick/ftnoir_tracker_joystick.h b/tracker-joystick/ftnoir_tracker_joystick.h
index 1f940b63..31f1dee7 100644
--- a/tracker-joystick/ftnoir_tracker_joystick.h
+++ b/tracker-joystick/ftnoir_tracker_joystick.h
@@ -17,7 +17,7 @@
#include <cmath>
#include "opentrack/plugin-api.hpp"
-#include "opentrack/win32-joystick.hpp"
+#include "opentrack-logic/win32-joystick.hpp"
#include "opentrack-compat/options.hpp"
using namespace options;
diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c
index 4d4c6c92..b0a41414 100644
--- a/x-plane-plugin/plugin.c
+++ b/x-plane-plugin/plugin.c
@@ -22,18 +22,21 @@
#define WINE_SHM_NAME "facetracknoir-wine-shm"
#define WINE_MTX_NAME "facetracknoir-wine-mtx"
+#define BUILD_compat
#include "../opentrack-compat/export.hpp"
enum Axis {
TX = 0, TY, TZ, Yaw, Pitch, Roll
};
-typedef struct PortableLockedShm {
+typedef struct PortableLockedShm
+{
void* mem;
int fd, size;
} PortableLockedShm;
-typedef struct WineSHM {
+typedef struct WineSHM
+{
double data[6];
int gameid, gameid2;
unsigned char table[8];
@@ -68,7 +71,7 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UN
strncpy(shm_filename+1, shmName, NAME_MAX-2);
shm_filename[NAME_MAX-1] = '\0';
/* (void) shm_unlink(shm_filename); */
-
+
self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600);
(void) ftruncate(self->fd, mapSize);
self->mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, self->fd, (off_t)0);
@@ -149,7 +152,7 @@ static int TranslationToggleHandler( XPLMCommandRef inCommand,
return 0;
}
-PLUGIN_API OPENTRACK_EXPORT int XPluginStart ( char * outName, char * outSignature, char * outDescription ) {
+PLUGIN_API OPENTRACK_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");
@@ -187,7 +190,7 @@ PLUGIN_API OPENTRACK_EXPORT int XPluginStart ( char * outName, char * outSignatu
return 0;
}
-PLUGIN_API OPENTRACK_EXPORT void XPluginStop ( void ) {
+PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginStop ( void ) {
if (lck_posix)
{
PortableLockedShm_free(lck_posix);
@@ -196,17 +199,17 @@ PLUGIN_API OPENTRACK_EXPORT void XPluginStop ( void ) {
}
}
-PLUGIN_API OPENTRACK_EXPORT void XPluginEnable ( void ) {
+PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginEnable ( void ) {
XPLMRegisterFlightLoopCallback(write_head_position, -1.0, NULL);
track_disabled = 0;
}
-PLUGIN_API OPENTRACK_EXPORT void XPluginDisable ( void ) {
+PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginDisable ( void ) {
XPLMUnregisterFlightLoopCallback(write_head_position, NULL);
track_disabled = 1;
}
-PLUGIN_API OPENTRACK_EXPORT void XPluginReceiveMessage(
+PLUGIN_API OPENTRACK_COMPAT_EXPORT void XPluginReceiveMessage(
XPLMPluginID OT_UNUSED(inFromWho),
int OT_UNUSED(inMessage),
void * OT_UNUSED(inParam))