| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-07-31 21:14:05 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-07-31 21:14:05 +0200 |
| commit | 038b03bbf519bdc44d1b8a3fce34901943c9bc7b (patch) | |
| tree | 6087a4fea8d78da04bd5c682b7520a3807351404 | |
| parent | 6ca39654bfc65eee45cb38cbc53ce838d1f656a0 (diff) | |
Implementing what is needed for rel axis renaming.
| -rw-r--r-- | conf/pro1_mouse.conf | 4 | ||||
| -rw-r--r-- | include/relabsd/debug.h | 8 | ||||
| -rw-r--r-- | include/relabsd/device/axis.h | 6 | ||||
| -rw-r--r-- | include/relabsd/device/axis_types.h | 5 | ||||
| -rw-r--r-- | src/config/parameters/compatibility.c | 11 | ||||
| -rw-r--r-- | src/device/axis/axis.c | 9 | ||||
| -rw-r--r-- | src/device/axis/axis_filter.c | 5 | ||||
| -rw-r--r-- | src/device/axis/axis_option.c | 4 | ||||
| -rw-r--r-- | src/device/virtual/virtual_device.c | 48 | ||||
| -rw-r--r-- | src/server/conversion_main_loop.c | 52 |
10 files changed, 100 insertions, 52 deletions
diff --git a/conf/pro1_mouse.conf b/conf/pro1_mouse.conf new file mode 100644 index 0000000..6fe718e --- /dev/null +++ b/conf/pro1_mouse.conf @@ -0,0 +1,4 @@ +# Pro1 mouse, just rename axis +# AXIS MIN MAX FUZZ FLAT RESOLUTION OPTIONS +X 0 0 0 0 0 notabs,convert_to=Y +Y 0 0 0 0 0 notabs,convert_to=X diff --git a/include/relabsd/debug.h b/include/relabsd/debug.h index 025c312..6745779 100644 --- a/include/relabsd/debug.h +++ b/include/relabsd/debug.h @@ -5,19 +5,19 @@ #include <relabsd/util/macro.h> #ifndef RELABSD_DEBUG_PROGRAM_FLOW - #define RELABSD_DEBUG_PROGRAM_FLOW 0 + #define RELABSD_DEBUG_PROGRAM_FLOW 1 #endif #ifndef RELABSD_DEBUG_CONFIG - #define RELABSD_DEBUG_CONFIG 0 + #define RELABSD_DEBUG_CONFIG 1 #endif #ifndef RELABSD_DEBUG_REAL_EVENTS - #define RELABSD_DEBUG_REAL_EVENTS 0 + #define RELABSD_DEBUG_REAL_EVENTS 1 #endif #ifndef RELABSD_DEBUG_VIRTUAL_EVENTS - #define RELABSD_DEBUG_VIRTUAL_EVENTS 0 + #define RELABSD_DEBUG_VIRTUAL_EVENTS 1 #endif #ifndef RELABSD_ENABLE_WARNINGS_OUTPUT diff --git a/include/relabsd/device/axis.h b/include/relabsd/device/axis.h index e3f0794..780981c 100644 --- a/include/relabsd/device/axis.h +++ b/include/relabsd/device/axis.h @@ -115,3 +115,9 @@ void relabsd_axis_set_attributes_are_dirty const int val, struct relabsd_axis axis [const restrict static 1] ); + +int relabsd_axis_has_flag +( + const struct relabsd_axis axis [const restrict static 1], + const enum relabsd_axis_flag flag +); diff --git a/include/relabsd/device/axis_types.h b/include/relabsd/device/axis_types.h index 8fbb726..20ed44c 100644 --- a/include/relabsd/device/axis_types.h +++ b/include/relabsd/device/axis_types.h @@ -2,7 +2,7 @@ /* Number of axes that can be configured. */ #define RELABSD_AXIS_VALID_AXES_COUNT 8 -#define RELABSD_AXIS_FLAGS_COUNT 3 +#define RELABSD_AXIS_FLAGS_COUNT 4 /* * C enumerations are always int, and the standard does specify that it starts @@ -26,7 +26,8 @@ enum relabsd_axis_flag { RELABSD_DIRECT, RELABSD_REAL_FUZZ, - RELABSD_FRAMED + RELABSD_FRAMED, + RELABSD_NOT_ABS }; struct relabsd_axis diff --git a/src/config/parameters/compatibility.c b/src/config/parameters/compatibility.c index cc65c7f..9f605ac 100644 --- a/src/config/parameters/compatibility.c +++ b/src/config/parameters/compatibility.c @@ -32,7 +32,16 @@ int relabsd_parameters_are_compatible_with { rel_code = relabsd_axis_name_to_evdev_rel((enum relabsd_axis_name) i); - if (!libevdev_has_event_code(libevdev, EV_REL, rel_code)) + if + ( + (!libevdev_has_event_code(libevdev, EV_REL, rel_code)) + && + ( + relabsd_axis_get_convert_to(parameters->axes + i) + == + RELABSD_UNKNOWN + ) + ) { RELABSD_ERROR ( diff --git a/src/device/axis/axis.c b/src/device/axis/axis.c index 1cdb856..ada6fa3 100644 --- a/src/device/axis/axis.c +++ b/src/device/axis/axis.c @@ -46,6 +46,15 @@ void relabsd_axis_enable axis->is_enabled = 1; } +int relabsd_axis_has_flag +( + const struct relabsd_axis axis [const restrict static 1], + const enum relabsd_axis_flag flag +) +{ + return axis->flags[flag]; +} + int relabsd_axis_is_enabled ( const struct relabsd_axis axis [const restrict static 1] diff --git a/src/device/axis/axis_filter.c b/src/device/axis/axis_filter.c index 04dfdb7..6258ad9 100644 --- a/src/device/axis/axis_filter.c +++ b/src/device/axis/axis_filter.c @@ -122,6 +122,11 @@ int relabsd_axis_filter_new_value return 0; } + if (axis->flags[RELABSD_NOT_ABS]) + { + return 1; + } + 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 index 8e52fe1..7796eb7 100644 --- a/src/device/axis/axis_option.c +++ b/src/device/axis/axis_option.c @@ -57,6 +57,10 @@ int relabsd_axis_enable_option_from_name ); } } + else if (RELABSD_IS_PREFIX("notabs", option_name)) + { + axis->flags[RELABSD_NOT_ABS] = 1; + } else if (RELABSD_IS_PREFIX("convert_to=", option_name)) { axis->convert_to = diff --git a/src/device/virtual/virtual_device.c b/src/device/virtual/virtual_device.c index 5ec06f5..0b92804 100644 --- a/src/device/virtual/virtual_device.c +++ b/src/device/virtual/virtual_device.c @@ -29,6 +29,7 @@ static void replace_rel_axes ) { int i; + for (i = 0; i < RELABSD_AXIS_VALID_AXES_COUNT; i++) { enum relabsd_axis_name axis_name; @@ -37,7 +38,18 @@ static void replace_rel_axes axis_name = ((enum relabsd_axis_name) i); axis = relabsd_parameters_get_axis(axis_name, parameters); - if (relabsd_axis_is_enabled(axis)) + axis_name = relabsd_axis_get_convert_to(axis); + + if (axis_name == RELABSD_UNKNOWN) + { + axis_name = ((enum relabsd_axis_name) i); + } + + if + ( + relabsd_axis_is_enabled(axis) + && !relabsd_axis_has_flag(axis, RELABSD_NOT_ABS) + ) { (void) relabsd_virtual_device_update_axis_absinfo ( @@ -160,20 +172,23 @@ int relabsd_virtual_device_update_axis_absinfo * Might want to add an option to see if people want to use the tool to * alter existing EV_ABS axes instead of converting from EV_REL to EV_ABS. */ - (void) libevdev_disable_event_code - ( - device->libevdev, - EV_REL, - relabsd_axis_name_to_evdev_rel(axis_name) - ); + if (!relabsd_axis_has_flag(axis, RELABSD_NOT_ABS)) + { + (void) libevdev_disable_event_code + ( + device->libevdev, + EV_REL, + relabsd_axis_name_to_evdev_rel(axis_name) + ); - (void) libevdev_enable_event_code - ( - device->libevdev, - EV_ABS, - relabsd_axis_name_to_evdev_abs(target_axis_name), - &absinfo - ); + (void) libevdev_enable_event_code + ( + device->libevdev, + EV_ABS, + relabsd_axis_name_to_evdev_abs(target_axis_name), + &absinfo + ); + } return 0; } @@ -392,6 +407,11 @@ void relabsd_virtual_device_set_axes_to_zero axis = relabsd_parameters_get_axis((enum relabsd_axis_name) i, parameters); + if (relabsd_axis_has_flag(axis, RELABSD_NOT_ABS)) + { + continue; + } + if (relabsd_axis_is_enabled(axis)) { relabsd_virtual_device_write_evdev_event diff --git a/src/server/conversion_main_loop.c b/src/server/conversion_main_loop.c index f9af4f8..fd12408 100644 --- a/src/server/conversion_main_loop.c +++ b/src/server/conversion_main_loop.c @@ -43,9 +43,10 @@ static void convert_input if (input_type == EV_REL) { struct relabsd_axis * axis; - unsigned int abs_code; + unsigned int abs_type, abs_code; enum relabsd_axis_name axis_name; + abs_type = EV_ABS; axis_name = relabsd_axis_name_and_evdev_abs_from_evdev_rel(input_code, &abs_code); @@ -57,9 +58,25 @@ static void convert_input axis = relabsd_parameters_get_axis(axis_name, &(server->parameters)); axis_name = relabsd_axis_get_convert_to(axis); - if (axis_name != RELABSD_UNKNOWN) + if (relabsd_axis_has_flag(axis, RELABSD_NOT_ABS)) { - abs_code = relabsd_axis_name_to_evdev_abs(axis_name); + abs_type = EV_REL; + + if (axis_name == RELABSD_UNKNOWN) + { + abs_code = input_code; + } + else + { + abs_code = relabsd_axis_name_to_evdev_rel(axis_name); + } + } + else + { + if (axis_name != RELABSD_UNKNOWN) + { + abs_code = relabsd_axis_name_to_evdev_abs(axis_name); + } } switch (relabsd_axis_filter_new_value(axis, &value)) @@ -72,7 +89,7 @@ static void convert_input (void) relabsd_virtual_device_write_evdev_event ( &(server->virtual_device), - EV_ABS, + abs_type, abs_code, value ); @@ -95,33 +112,6 @@ static void convert_input return; } } - else if (input_type == EV_ABS) - { - enum relabsd_axis_name axis_name; - - axis_name = relabsd_axis_name_from_evdev_abs(input_code); - - if (axis_name != RELABSD_UNKNOWN) - { - struct relabsd_axis * axis; - - axis = relabsd_parameters_get_axis(axis_name, &(server->parameters)); - axis_name = relabsd_axis_get_convert_to(axis); - - if (axis_name != RELABSD_UNKNOWN) - { - input_code = relabsd_axis_name_to_evdev_abs(axis_name); - } - } - - (void) relabsd_virtual_device_write_evdev_event - ( - &(server->virtual_device), - input_type, - input_code, - value - ); - } else { /* Any other event is retransmitted as is. */ |


