| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.c | 24 | ||||
| -rw-r--r-- | src/config.h | 7 | ||||
| -rw-r--r-- | src/main.c | 4 | 
3 files changed, 29 insertions, 6 deletions
| 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 <errno.h>  #include <string.h> +#include <stdlib.h>  #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;  } diff --git a/src/config.h b/src/config.h index 1ede1f3..c0c83a7 100644 --- a/src/config.h +++ b/src/config.h @@ -8,6 +8,7 @@  struct relabsd_config_axis  {     int enabled; +   int previous_value;     int min;     int max;     int fuzz; @@ -54,11 +55,13 @@ int relabsd_config_parse   *   * If the return value is 0, this function will not have altered the value at   * 'value'. Otherwise, this function can have altered it to match its - * requierements. + * requirements. + * If the return value is either 0 or -1, the 'previous_value' of the axis + * has been updated.   */  int relabsd_config_filter  ( -   const struct relabsd_config * const conf, +   struct relabsd_config * const conf,     enum relabsd_axis const axis,     int * const value  ); @@ -21,7 +21,7 @@ static void interrupt (int unused_mandatory_parameter)  static void handle_relative_axis_event  ( -   const struct relabsd_config * const conf, +   struct relabsd_config * const conf,     const struct relabsd_device * const dev,     unsigned int const input_type,     unsigned int const input_code, @@ -53,7 +53,7 @@ static void handle_relative_axis_event  static void convert_input  ( -   const struct relabsd_config * const conf, +   struct relabsd_config * const conf,     const struct relabsd_input * const input,     const struct relabsd_device * const dev  ) | 


