From 023490db6ac86ee3f82b1b89e279d0b2ccae5fd3 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sat, 1 Aug 2020 09:20:19 +0200 Subject: Adds invert option, updates usage. --- src/config/parameters/handle_remote_client_commands.c | 17 +++++++++++++++++ src/config/parameters/parameters.c | 10 +++++----- src/device/axis/axis_filter.c | 5 +++++ src/device/axis/axis_option.c | 6 +++++- 4 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/config/parameters/handle_remote_client_commands.c b/src/config/parameters/handle_remote_client_commands.c index caa82dc..95830c7 100644 --- a/src/config/parameters/handle_remote_client_commands.c +++ b/src/config/parameters/handle_remote_client_commands.c @@ -366,10 +366,27 @@ static int handle_option_toggle { parameters->axes[axis_name].flags[RELABSD_REAL_FUZZ] ^= 1; } + else if (RELABSD_STRING_EQUALS("invert", input->buffer)) + { + parameters->axes[axis_name].flags[RELABSD_INVERT] ^= 1; + } + else if (RELABSD_STRING_EQUALS("not_abs", input->buffer)) + { + parameters->axes[axis_name].flags[RELABSD_NOT_ABS] ^= 1; + } else if (RELABSD_STRING_EQUALS("enable", input->buffer)) { parameters->axes[axis_name].is_enabled ^= 1; } + else if (RELABSD_IS_PREFIX("convert_to=", input->buffer)) + { + relabsd_axis_enable_option_from_name + ( + input->buffer, + relabsd_axis_name_to_string(axis_name), + (parameters->axes + axis_name) + ); + } else { RELABSD_ERROR diff --git a/src/config/parameters/parameters.c b/src/config/parameters/parameters.c index cee6f2e..d9a3d46 100644 --- a/src/config/parameters/parameters.c +++ b/src/config/parameters/parameters.c @@ -320,7 +320,7 @@ int relabsd_parameters_parse_options RELABSD_STRING_EQUALS("-m", argv[i]) || RELABSD_STRING_EQUALS("--mod-axis", argv[i]) || RELABSD_STRING_EQUALS("-o", argv[i]) - || RELABSD_STRING_EQUALS("--toggle-argv[i]", argv[i]) + || RELABSD_STRING_EQUALS("--toggle-option", argv[i]) ||RELABSD_STRING_EQUALS("-q", argv[i]) || RELABSD_STRING_EQUALS("--quit", argv[i]) ) @@ -460,13 +460,13 @@ void relabsd_parameters_print_usage (const char exec [const restrict static 1]) "\t[-q | --quit]\n" "\t\tTerminates the targeted server instance.\n\n" - "\t[-m | --mod-axis] [min|max|fuzz|flat|resolution]" - " [+|-|=]\n" + "\t[-m | --mod-axis] " + "[min|max|fuzz|flat|resolution] [+|-|=]\n" "\t\tModifies an axis.\n\n" "\t[-o | --toggle-option] " - "[direct|real_fuzz|framed|enable|convert_to=]\n" - "\t\tToggles an axis option.\n", + "[direct|real_fuzz|framed|enable|invert|not_abs|convert_to=]\n" + "\t\tToggles or sets an axis option.\n", exec, exec, exec, diff --git a/src/device/axis/axis_filter.c b/src/device/axis/axis_filter.c index 6258ad9..d7840ca 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_INVERT]) + { + *value = -(*value); + } + if (axis->flags[RELABSD_NOT_ABS]) { return 1; diff --git a/src/device/axis/axis_option.c b/src/device/axis/axis_option.c index 7796eb7..e8d06f5 100644 --- a/src/device/axis/axis_option.c +++ b/src/device/axis/axis_option.c @@ -57,10 +57,14 @@ int relabsd_axis_enable_option_from_name ); } } - else if (RELABSD_IS_PREFIX("notabs", option_name)) + else if (RELABSD_IS_PREFIX("not_abs", option_name)) { axis->flags[RELABSD_NOT_ABS] = 1; } + else if (RELABSD_IS_PREFIX("invert", option_name)) + { + axis->flags[RELABSD_INVERT] = 1; + } else if (RELABSD_IS_PREFIX("convert_to=", option_name)) { axis->convert_to = -- cgit v1.2.3-70-g09d2