summaryrefslogtreecommitdiff
blob: 1ede1f3415e7def5794780b80479ff09a0616c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef RELABSD_CONFIG_H
#define RELABSD_CONFIG_H

#include <libevdev/libevdev.h>

#include "axis.h"

struct relabsd_config_axis
{
   int enabled;
   int min;
   int max;
   int fuzz;
   int flat;
   int resolution;
};

/*
 * There is no relabsd_config_free function, so be careful about using dynamic
 * memory for input_file or device_name.
 */
struct relabsd_config
{
   const char * input_file;
   const char * device_name;
   struct relabsd_config_axis axis[RELABSD_VALID_AXES_COUNT];
};

/*
 * Parses the invocation parameters and the config file into 'conf'.
 *
 * Returns -1 on (fatal) error,
 *          0 on successfully parsed config.
 *
 * 'conf' does not need to be initialized, as the function will only write to
 * it.
 * As one would expect, argc is the number of elements in argv.
 */
int relabsd_config_parse
(
   struct relabsd_config * const conf,
   int const argc,
   char * const * const argv
);

/*
 * This function aims at preventing us from emitting values that are incoherent
 * with our REV_ABS axis configuration, such as the axis' minimum or maximum
 * values.
 *
 * Returns 1 if 'conf' allows the value to be emitted,
 *         0 if 'conf' wants the event to be transmitted as is.
 *         -1 if 'conf' doesn't want the event to be transmitted.
 *
 * 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.
 */
int relabsd_config_filter
(
   const struct relabsd_config * const conf,
   enum relabsd_axis const axis,
   int * const value
);

/*
 * Copies all the ABS event parameters of 'axis' into 'absinfo'.
 * 'absinfo' does not need to be initialized, as the function will only write to
 * it.
 */
void relabsd_config_get_absinfo
(
   const struct relabsd_config * const conf,
   enum relabsd_axis const axis,
   struct input_absinfo * const absinfo
);

#endif