summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/device')
-rw-r--r--src/device/axis/axis.c15
-rw-r--r--src/device/axis/axis_filter.c20
-rw-r--r--src/device/axis/axis_option.c71
3 files changed, 97 insertions, 9 deletions
diff --git a/src/device/axis/axis.c b/src/device/axis/axis.c
index 75afad8..2659c84 100644
--- a/src/device/axis/axis.c
+++ b/src/device/axis/axis.c
@@ -1,6 +1,9 @@
/**** POSIX *******************************************************************/
#include <string.h>
+/**** LIBEVDEV ****************************************************************/
+#include <libevdev/libevdev.h>
+
/**** RELABSD *****************************************************************/
#include <relabsd/device/axis.h>
@@ -21,7 +24,7 @@ void relabsd_axis_initialize
void relabsd_axis_to_absinfo
(
- struct relabsd_axis axis [const restrict static 1]
+ struct relabsd_axis axis [const restrict static 1],
struct input_absinfo absinfo [const restrict static 1]
)
{
@@ -32,3 +35,13 @@ void relabsd_axis_to_absinfo
absinfo->flat = (__s32) axis->flat;
absinfo->resolution = (__s32) axis->resolution;
}
+
+void relabsd_axis_enable
+(
+ struct relabsd_axis axis [const restrict static 1]
+)
+{
+ axis->is_enabled = 1;
+}
+
+
diff --git a/src/device/axis/axis_filter.c b/src/device/axis/axis_filter.c
index 295a7f6..eb14edd 100644
--- a/src/device/axis/axis_filter.c
+++ b/src/device/axis/axis_filter.c
@@ -1,3 +1,7 @@
+/**** POSIX *******************************************************************/
+#include <stdlib.h>
+#include <limits.h>
+
/**** RELABSD *****************************************************************/
#include <relabsd/device/axis.h>
@@ -6,13 +10,13 @@
/******************************************************************************/
static int direct_filter
(
- struct relabsd_config_axis * const axis,
- int * const value
+ struct relabsd_axis axis [const restrict static 1],
+ int value [const restrict static 1]
)
{
if (abs(*value - axis->previous_value) <= axis->fuzz)
{
- if (axis->option[RELABSD_REAL_FUZZ_OPTION])
+ if (axis->flags[RELABSD_REAL_FUZZ])
{
axis->previous_value = *value;
}
@@ -45,8 +49,8 @@ static int direct_filter
static int rel_to_abs_filter
(
- struct relabsd_config_axis * const axis,
- int * const value
+ struct relabsd_axis axis [const restrict static 1],
+ int value [const restrict static 1]
)
{
long int guard;
@@ -64,7 +68,7 @@ static int rel_to_abs_filter
*value = (int) guard;
- if (axis->option[RELABSD_FRAMED_OPTION])
+ if (axis->flags[RELABSD_FRAMED])
{
if (*value < axis->min)
{
@@ -115,12 +119,12 @@ int relabsd_axis_filter_new_value
{
if (!(axis->is_enabled))
{
- return;
+ return 0;
}
/* TODO: handle conf->axis[axis].resolution */
- if (axis->flag[RELABSD_DIRECT_OPTION])
+ if (axis->flags[RELABSD_DIRECT])
{
return direct_filter(axis, value);
}
diff --git a/src/device/axis/axis_option.c b/src/device/axis/axis_option.c
new file mode 100644
index 0000000..fd1cb9c
--- /dev/null
+++ b/src/device/axis/axis_option.c
@@ -0,0 +1,71 @@
+/**** POSIX *******************************************************************/
+#include <string.h>
+
+/**** RELABSD *****************************************************************/
+#include <relabsd/debug.h>
+
+#include <relabsd/device/axis.h>
+
+/******************************************************************************/
+/**** LOCAL FUNCTIONS *********************************************************/
+/******************************************************************************/
+
+/******************************************************************************/
+/**** EXPORTED FUNCTIONS ******************************************************/
+/******************************************************************************/
+/*
+ * Returns -1 if the option was discarded (an error has been reported),
+ * 0 if the option was successfully parsed.
+ */
+int relabsd_axis_enable_option_from_name
+(
+ const char option_name [const restrict static 1],
+ const char axis_name [const restrict static 1],
+ struct relabsd_axis axis [const restrict static 1]
+)
+{
+
+ if (strcmp(option_name, "direct") == 0)
+ {
+ axis->flags[RELABSD_DIRECT] = 1;
+
+ if (axis->flags[RELABSD_FRAMED])
+ {
+ RELABSD_WARNING
+ (
+ "Option 'direct' on axis '%s' supersedes its 'framed' option.",
+ axis_name
+ );
+ }
+ }
+ else if (strcmp(option_name, "real_fuzz") == 0)
+ {
+ axis->flags[RELABSD_REAL_FUZZ] = 1;
+ }
+ else if (strcmp(option_name, "framed") == 0)
+ {
+ axis->flags[RELABSD_FRAMED] = 1;
+
+ if (axis->flags[RELABSD_DIRECT])
+ {
+ RELABSD_WARNING
+ (
+ "Option 'direct' on axis '%s' supersedes its 'framed' option.",
+ axis_name
+ );
+ }
+ }
+ else
+ {
+ RELABSD_ERROR
+ (
+ "Unknown option '%s' for axis '%s'.",
+ option_name,
+ axis_name
+ );
+
+ return -1;
+ }
+
+ return 0;
+}