From 5867bb8f12f3841a06eed3cd253365be0728c0af Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Thu, 3 Sep 2015 05:11:31 +0200 Subject: Now applies the 'fuzz' and 'flat' properties. --- src/config.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index d4288ef..e84737a 100644 --- a/src/config.c +++ b/src/config.c @@ -1,5 +1,6 @@ #include #include +#include #include "error.h" #include "pervasive.h" @@ -136,6 +137,7 @@ static int parse_axis_configuration_line errno = prev_errno; conf->axis[axis].enabled = 1; + conf->axis[axis].previous_value = 0; return 0; } @@ -314,7 +316,7 @@ int relabsd_config_parse int relabsd_config_filter ( - const struct relabsd_config * const conf, + struct relabsd_config * const conf, enum relabsd_axis const axis, int * const value ) @@ -324,6 +326,13 @@ int relabsd_config_filter return 0; } + if (abs(*value - conf->axis[axis].previous_value) <= conf->axis[axis].fuzz) + { + conf->axis[axis].previous_value = *value; + + return -1; + } + if (*value < conf->axis[axis].min) { *value = conf->axis[axis].min; @@ -332,8 +341,19 @@ int relabsd_config_filter { *value = conf->axis[axis].max; } + else if (abs(*value) <= conf->axis[axis].flat) + { + *value = 0; + + /* + * As long as the 'fuzz' test is done prior the 'flat' one, moving around + * in the 'flat' zone won't trigger useless '0' value events. + */ + } + + /* TODO: handle conf->axis[axis].resolution */ - /* TODO: handle the other properties. */ + conf->axis[axis].previous_value = *value; return 1; } -- cgit v1.2.3-70-g09d2