summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/util.hpp10
-rw-r--r--proto-vjoystick/vjoystick.cpp11
-rw-r--r--spline-widget/spline.hpp11
3 files changed, 12 insertions, 20 deletions
diff --git a/compat/util.hpp b/compat/util.hpp
index 33e64a80..453d94bd 100644
--- a/compat/util.hpp
+++ b/compat/util.hpp
@@ -46,6 +46,16 @@ public:
inhibit_qt_signals(std::shared_ptr<QObject> val) : inhibit_qt_signals(*val.get()) {}
};
+template<typename t, typename u, typename w>
+auto clamp(t val, u min, w max) -> decltype (val * min * max)
+{
+ if (val > max)
+ return max;
+ if (val < min)
+ return min;
+ return val;
+}
+
namespace detail {
template<typename t>
diff --git a/proto-vjoystick/vjoystick.cpp b/proto-vjoystick/vjoystick.cpp
index ad582b6d..5a780222 100644
--- a/proto-vjoystick/vjoystick.cpp
+++ b/proto-vjoystick/vjoystick.cpp
@@ -1,5 +1,6 @@
#include "vjoystick.h"
#include "api/plugin-api.hpp"
+#include "compat/util.hpp"
#include <cstring>
#include <QDebug>
@@ -18,16 +19,6 @@
#define OPENTRACK_VJOYSTICK_ID 1
-template<typename t, typename u, typename v>
-static t clamp(t val, u min, v max)
-{
- if (val < min)
- return t(min);
- if (val > max)
- return t(max);
- return val;
-}
-
const unsigned char handle::axis_ids[6] =
{
HID_USAGE_X,
diff --git a/spline-widget/spline.hpp b/spline-widget/spline.hpp
index 0ffc4de9..75a9e95e 100644
--- a/spline-widget/spline.hpp
+++ b/spline-widget/spline.hpp
@@ -10,6 +10,7 @@
#include "compat/qcopyable-mutex.hpp"
#include "options/options.hpp"
+#include "compat/util.hpp"
using namespace options;
#include "export.hpp"
@@ -48,16 +49,6 @@ class OPENTRACK_SPLINE_EXPORT spline final
static QPointF ensure_in_bounds(const QList<QPointF>& points, int i);
- template<typename t, typename u, typename w>
- static inline auto clamp(t val, u min, w max) -> decltype (val * min * max)
- {
- if (val > max)
- return max;
- if (val < min)
- return min;
- return val;
- }
-
mem<spline_detail::settings> s;
QMetaObject::Connection connection;