aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2015-09-03 05:11:31 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2015-09-03 05:11:31 +0200
commit5867bb8f12f3841a06eed3cd253365be0728c0af (patch)
tree990fef402177d252f800ae1c01931532f869964b
parent8e9d02a8bf86555cd040b5e7a29a12851e9764bf (diff)
downloadrelabsd-5867bb8f12f3841a06eed3cd253365be0728c0af.zip
relabsd-5867bb8f12f3841a06eed3cd253365be0728c0af.tar.bz2
Now applies the 'fuzz' and 'flat' properties.
-rw-r--r--conf/space_navigator.conf12
-rw-r--r--src/config.c24
-rw-r--r--src/config.h7
-rw-r--r--src/main.c4
4 files changed, 35 insertions, 12 deletions
diff --git a/conf/space_navigator.conf b/conf/space_navigator.conf
index 07a5ae0..4936713 100644
--- a/conf/space_navigator.conf
+++ b/conf/space_navigator.conf
@@ -1,8 +1,8 @@
# 3DConnexion SpaceNavigator
# AXIS MIN MAX FUZZ FLAT RESOLUTION
-X -350 350 1 1 1
-Y -350 350 1 1 1
-Z -350 350 1 1 1
-RX -350 350 1 1 1
-RY -350 350 1 1 1
-RZ -350 350 1 1 1
+X -350 350 0 0 1
+Y -350 350 0 0 1
+Z -350 350 0 0 1
+RX -350 350 0 0 1
+RY -350 350 0 0 1
+RZ -350 350 0 0 1
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
);
diff --git a/src/main.c b/src/main.c
index 9eb3433..47b78a2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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
)