summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-12-31 15:51:05 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-12-31 15:51:05 +0100
commit63016ce5c71019de315434de3e91adbf535d4986 (patch)
treeb2368aecbbc790a600f7dfebfaabc8c28fa806b0 /include
parentb9952b4938da95de07bff748cfd6d2c7e8471796 (diff)
Still working on it...
Diffstat (limited to 'include')
-rw-r--r--include/relabsd/client_types.h0
-rw-r--r--include/relabsd/config/config_file.h8
-rw-r--r--include/relabsd/config/parameters.h57
-rw-r--r--include/relabsd/config/parameters_types.h22
-rw-r--r--include/relabsd/device/axis.h26
-rw-r--r--include/relabsd/device/axis_types.h43
-rw-r--r--include/relabsd/device/physical_device.h9
-rw-r--r--include/relabsd/device/physical_device_types.h10
-rw-r--r--include/relabsd/device/virtual_device.h22
-rw-r--r--include/relabsd/device/virtual_device_types.h23
-rw-r--r--include/relabsd/server_types.h0
11 files changed, 158 insertions, 62 deletions
diff --git a/include/relabsd/client_types.h b/include/relabsd/client_types.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/relabsd/client_types.h
diff --git a/include/relabsd/config/config_file.h b/include/relabsd/config/config_file.h
index 3aa1a13..f904182 100644
--- a/include/relabsd/config/config_file.h
+++ b/include/relabsd/config/config_file.h
@@ -3,20 +3,12 @@
#include <libevdev/libevdev.h>
-#include "axis.h"
-
/* Maximum length for a axis code. */
#define RELABSD_CONF_AXIS_CODE_SIZE 2
/* Number of options that can be configured. */
#define RELABSD_OPTIONS_COUNT 3
-enum relabsd_option
-{
- RELABSD_DIRECT_OPTION,
- RELABSD_REAL_FUZZ_OPTION,
- RELABSD_FRAMED_OPTION
-};
struct relabsd_config_axis
{
diff --git a/include/relabsd/config/parameters.h b/include/relabsd/config/parameters.h
index e69de29..5a12be4 100644
--- a/include/relabsd/config/parameters.h
+++ b/include/relabsd/config/parameters.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <relabsd/config/parameters_types.h>
+
+/**** Utility *****************************************************************/
+int relabsd_parameters_parse_execution_mode
+(
+ const int argc,
+ const char * const argv [const restrict static argc],
+ struct relabsd_parameters parameters [const restrict static 1]
+);
+
+int relabsd_parameters_parse_options
+(
+ const int argc,
+ const char * const argv [const restrict static argc],
+ struct relabsd_parameters parameters [const restrict static 1]
+);
+
+int relabsd_parameters_argument_count_for
+(
+ const char option [const restrict static 1],
+ int result [const restrict static 1]
+);
+
+void relabsd_parameters_print_usage (const char exec [const restrict static 1]);
+
+/**** Accessors ***************************************************************/
+void relabsd_parameters_initialize_options
+(
+ const struct relabsd_parameters parameters [const restrict static 1]
+);
+
+int relabsd_parameters_get_run_as_daemon
+(
+ const struct relabsd_parameters parameters [const restrict static 1]
+);
+
+const char * relabsd_parameters_get_communication_node_name
+(
+ const struct relabsd_parameters parameters [const restrict static 1]
+);
+
+const char * relabsd_parameters_get_device_name
+(
+ const struct relabsd_parameters parameters [const restrict static 1]
+);
+
+const char * relabsd_parameters_get_physical_device_file_name
+(
+ const struct relabsd_parameters parameters [const restrict static 1]
+);
+
+enum relabsd_parameters_run_mode relabsd_parameters_get_execution_mode
+(
+ const struct relabsd_parameters parameters [const restrict static 1]
+);
diff --git a/include/relabsd/config/parameters_types.h b/include/relabsd/config/parameters_types.h
new file mode 100644
index 0000000..ab07bfa
--- /dev/null
+++ b/include/relabsd/config/parameters_types.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <relabsd/device/axis_types.h>
+
+enum relabsd_parameters_run_mode
+{
+ RELABSD_PARAMETERS_CLIENT_MODE,
+ RELABSD_PARAMETERS_SERVER_MODE,
+ RELABSD_PARAMETERS_COMPATIBILITY_TEST_MODE
+};
+
+struct relabsd_parameters
+{
+ int read_argc;
+ enum relabsd_parameters_run_mode mode;
+ int run_as_daemon;
+ const char * communication_node_name;
+ const char * device_name;
+ const char * physical_device_file_name;
+ const char * configuration_file;
+ struct relabsd_axis axes[RELABSD_AXIS_VALID_AXES_COUNT]
+};
diff --git a/include/relabsd/device/axis.h b/include/relabsd/device/axis.h
index 3829b51..fee8522 100644
--- a/include/relabsd/device/axis.h
+++ b/include/relabsd/device/axis.h
@@ -1,30 +1,6 @@
#pragma once
-/* Number of axes that can be configured. */
-#define RELABSD_AXIS_AXES_COUNT 8
-
-enum relabsd_axis_name
-{
- RELABSD_X,
- RELABSD_Y,
- RELABSD_Z,
- RELABSD_RX,
- RELABSD_RY,
- RELABSD_RZ,
- RELABSD_WHEEL,
- RELABSD_MISC,
- RELABSD_UNKNOWN
-};
-
-struct relabsd_axis
-{
- int min;
- int max;
- int fuzz;
- int flat;
- int resolution;
- int flags;
-};
+#include <relabsd/device/axis_types.h>
/*
* Gives the relabsd_axis and EV_ABS event code equivalent to an EV_REL event
diff --git a/include/relabsd/device/axis_types.h b/include/relabsd/device/axis_types.h
new file mode 100644
index 0000000..5ae0145
--- /dev/null
+++ b/include/relabsd/device/axis_types.h
@@ -0,0 +1,43 @@
+#pragma once
+
+/* Number of axes that can be configured. */
+#define RELABSD_AXIS_VALID_AXES_COUNT 8
+#define RELABSD_AXIS_FLAGS_COUNT 3
+
+/*
+ * C enumerations are always int, and the standard does specify that it starts
+ * at zero and increases from there, unless otherwise specified in the
+ * declaration.
+ */
+enum relabsd_axis_name
+{
+ RELABSD_X,
+ RELABSD_Y,
+ RELABSD_Z,
+ RELABSD_RX,
+ RELABSD_RY,
+ RELABSD_RZ,
+ RELABSD_WHEEL,
+ RELABSD_MISC,
+ RELABSD_UNKNOWN
+};
+
+enum relabsd_axis_flag
+{
+ RELABSD_DIRECT,
+ RELABSD_REAL_FUZZ,
+ RELABSD_FRAMED
+};
+
+struct relabsd_axis
+{
+ int min;
+ int max;
+ int fuzz;
+ int flat;
+ int resolution;
+
+ int is_enabled;
+ int previous_value;
+ int flags[RELABSD_AXIS_FLAGS_COUNT];
+};
diff --git a/include/relabsd/device/physical_device.h b/include/relabsd/device/physical_device.h
index 6b44802..3e55823 100644
--- a/include/relabsd/device/physical_device.h
+++ b/include/relabsd/device/physical_device.h
@@ -1,13 +1,6 @@
#pragma once
-#include <libevdev/libevdev.h>
-
-struct relabsd_physical_device
-{
- struct libevdev * libevdev;
- int file;
- int timed_out;
-};
+#include <relabsd/device/physical_device_types.h>
/*
* Returns -1 on (fatal) error,
diff --git a/include/relabsd/device/physical_device_types.h b/include/relabsd/device/physical_device_types.h
new file mode 100644
index 0000000..0c2cec7
--- /dev/null
+++ b/include/relabsd/device/physical_device_types.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <libevdev/libevdev.h>
+
+struct relabsd_physical_device
+{
+ struct libevdev * libevdev;
+ int file;
+ int timed_out;
+};
diff --git a/include/relabsd/device/virtual_device.h b/include/relabsd/device/virtual_device.h
index d398c7f..646422a 100644
--- a/include/relabsd/device/virtual_device.h
+++ b/include/relabsd/device/virtual_device.h
@@ -1,26 +1,6 @@
#pragma once
-#include <libevdev/libevdev.h>
-#include <libevdev/libevdev-uinput.h>
-
-/*
- LIBEVDEV_UINPUT_OPEN_MANAGED is not defined on my machines.
- It is not my place to define it, so I'll avoid the issue by defining my own
- constant.
-*/
-#ifndef LIBEVDEV_UINPUT_OPEN_MANAGED
- #pragma message "[WARNING] libevdev did not define " \
- "LIBEVDEV_UINPUT_OPEN_MANAGED, using value '-2' instead."
- #define RELABSD_UINPUT_OPEN_MANAGED -2
-#else
- #define RELABSD_UINPUT_OPEN_MANAGED LIBEVDEV_UINPUT_OPEN_MANAGED
-#endif
-
-struct relabsd_device
-{
- struct libevdev * dev;
- struct libevdev_uinput * uidev;
-};
+#include <relabsd/device/virtual_device_types.h>
/*
* - Clones the (real) input device.
diff --git a/include/relabsd/device/virtual_device_types.h b/include/relabsd/device/virtual_device_types.h
new file mode 100644
index 0000000..d20fafe
--- /dev/null
+++ b/include/relabsd/device/virtual_device_types.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <libevdev/libevdev.h>
+#include <libevdev/libevdev-uinput.h>
+
+/*
+ LIBEVDEV_UINPUT_OPEN_MANAGED is not defined on my machines.
+ It is not my place to define it, so I'll avoid the issue by defining my own
+ constant.
+*/
+#ifndef LIBEVDEV_UINPUT_OPEN_MANAGED
+ #pragma message "[WARNING] libevdev did not define " \
+ "LIBEVDEV_UINPUT_OPEN_MANAGED, using value '-2' instead."
+ #define RELABSD_UINPUT_OPEN_MANAGED -2
+#else
+ #define RELABSD_UINPUT_OPEN_MANAGED LIBEVDEV_UINPUT_OPEN_MANAGED
+#endif
+
+struct relabsd_device
+{
+ struct libevdev * dev;
+ struct libevdev_uinput * uidev;
+};
diff --git a/include/relabsd/server_types.h b/include/relabsd/server_types.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/relabsd/server_types.h