diff options
Diffstat (limited to 'common/accel-natural.hpp')
| -rw-r--r-- | common/accel-natural.hpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 9f76d1a..9d615a9 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -2,8 +2,6 @@ #include "rawaccel-base.hpp" -#include <math.h> - namespace rawaccel { /// <summary> Struct to hold "natural" (vanishing difference) acceleration implementation. </summary> @@ -13,16 +11,20 @@ namespace rawaccel { double limit; natural_base(const accel_args& args) : - offset(args.offset), + offset(args.input_offset), limit(args.limit - 1) { accel = args.decay_rate / fabs(limit); } + }; - struct natural_legacy : natural_base { + template<bool Gain> struct natural; + + template<> + struct natural<LEGACY> : natural_base { - double operator()(double x) const + double operator()(double x, const accel_args&) const { if (x <= offset) return 1; @@ -34,10 +36,11 @@ namespace rawaccel { using natural_base::natural_base; }; - struct natural : natural_base { + template<> + struct natural<GAIN> : natural_base { double constant; - double operator()(double x) const + double operator()(double x, const accel_args&) const { if (x <= offset) return 1; @@ -50,6 +53,6 @@ namespace rawaccel { natural(const accel_args& args) : natural_base(args), constant(-limit / accel) {} - }; + }; } |