summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.cpp4
-rw-r--r--opentrack/shortcuts.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
index 84bd68c8..46c35958 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
@@ -88,7 +88,9 @@ void FTNoIR_Filter::filter(const double* input, double *output)
{
Map& m = i >= 3 ? rot : trans;
- smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha;
+ const bool drop = std::isnan(input[i]) || std::isinf(input[i]);
+ const double f = drop ? last_output[i] : input[i];
+ smoothed_input[i] = smoothed_input[i] * (1.-alpha) + f * alpha;
const double in = smoothed_input[i];
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h
index 576b5384..63d91829 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack/shortcuts.h
@@ -54,6 +54,8 @@ public:
bool should_process()
{
+ if (keycode == 0)
+ return false;
bool ret = timer.elapsed_ms() > 100;
timer.start();
return ret;