From 5b659e1cfbc4b8fbbd2f2bf41dc716929976c77d Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sat, 28 Aug 2021 01:19:18 -0400 Subject: add per-device configuration adds input and [in, out] cap for classic mode adds input cap for power mode change wrapper/input, now gets useful device names change (now dev specific) dpi to adjust sensitivity change y sensitivity to y/x ratio remove spaced LUTs grapher and convert do not build --- common/rawaccel-validate.hpp | 150 +++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 71 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index a03f56a..e901a8a 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -5,7 +5,7 @@ namespace rawaccel { - struct valid_ret_t { + struct valid_profile_ret_t { int last_x = 0; int last_y = 0; int count = 0; @@ -16,10 +16,19 @@ namespace rawaccel { } }; + struct valid_device_ret_t { + int count = 0; + + explicit operator bool() const + { + return count == 0; + } + }; + template - valid_ret_t valid(const settings& args, MsgHandler fn = {}) + valid_profile_ret_t valid(const profile& args, MsgHandler fn = {}) { - valid_ret_t ret; + valid_profile_ret_t ret; auto error = [&](auto msg) { ++ret.count; @@ -27,56 +36,18 @@ namespace rawaccel { }; auto check_accel = [&error](const accel_args& args) { - static_assert(SPACED_LUT_CAPACITY == 1025, "update error msg"); - - const auto& lut_args = args.spaced_args; - - if (lut_args.partitions <= 0) { - error("lut partitions"" must be positive"); - } - - if (lut_args.mode == spaced_lut_mode::linear) { - if (lut_args.start <= 0) { - error("start"" must be positive"); - } - - if (lut_args.stop <= lut_args.start) { - error("stop must be greater than start"); - } - - if (lut_args.num_elements < 2 || - lut_args.num_elements > 1025) { - error("num must be between 2 and 1025"); - } - } - else if (lut_args.mode == spaced_lut_mode::binlog) { - int istart = static_cast(lut_args.start); - int istop = static_cast(lut_args.stop); + static_assert(LUT_POINTS_CAPACITY == 129, "update error msg"); - if (lut_args.start < -99) { - error("start is too small"); - } - else if (lut_args.stop > 99) { - error("stop is too large"); - } - else if (istart != lut_args.start || istop != lut_args.stop) { - error("start and stop must be integers"); - } - else if (istop <= istart) { - error("stop must be greater than start"); - } - else if (lut_args.num_elements <= 0) { - error("num"" must be positive"); + if (args.mode == accel_mode::lookup) { + if (args.length < 4) { + error("lookup mode requires at least 2 points"); } - else if (((lut_args.stop - lut_args.start) * lut_args.num_elements) >= 1025) { - error("binlog mode requires (num * (stop - start)) < 1025"); + else if (args.length > ra::LUT_RAW_DATA_CAPACITY) { + error("too many data points (max=129)"); } } - - if (args.mode == accel_mode::arb_lookup) { - if (args.arb_args.length < 2) { - error("lookup mode requires at least 2 points"); - } + else if (args.length > ra::LUT_RAW_DATA_CAPACITY) { + error("data size > max"); } if (args.offset < 0) { @@ -86,16 +57,28 @@ namespace rawaccel { error("offset can not be 0"); } - if (args.cap < 0) { - error("cap"" must not be negative"); + bool jump_or_io_cap = + (args.mode == accel_mode::jump || + (args.mode == accel_mode::classic && + args.cap_mode == classic_cap_mode::io)); + + if (args.cap.x < 0) { + error("cap (input) can not be negative"); + } + else if (args.cap.x == 0 && jump_or_io_cap) { + error("cap (input) can not be 0"); + } + + if (args.cap.y < 0) { + error("cap (output) can not be negative"); } - else if (args.mode == accel_mode::jump && args.cap == 0) { - error("cap can not be 0"); + else if (args.cap.y == 0 && jump_or_io_cap) { + error("cap (output) can not be 0"); } if (args.growth_rate <= 0 || args.decay_rate <= 0 || - args.accel_classic <= 0) { + args.acceleration <= 0) { error("acceleration"" must be positive"); } @@ -103,8 +86,8 @@ namespace rawaccel { error("motivity must be greater than 1"); } - if (args.power <= 1) { - error("power must be greater than 1"); + if (args.exponent_classic <= 1) { + error("exponent must be greater than 1"); } if (args.scale <= 0) { @@ -115,7 +98,7 @@ namespace rawaccel { error("weight"" must be positive"); } - if (args.exponent <= 0) { + if (args.exponent_power <= 0) { error("exponent"" must be positive"); } @@ -133,16 +116,16 @@ namespace rawaccel { }; - check_accel(args.argsv.x); + check_accel(args.accel_x); - if (!args.combine_mags) { + if (!args.whole) { ret.last_x = ret.count; - check_accel(args.argsv.y); + check_accel(args.accel_y); ret.last_y = ret.count; } - if (args.dpi <= 0) { - error("dpi"" must be positive"); + if (args.name[0] == L'\0') { + error("profile name can not be empty"); } if (args.speed_max < 0) { @@ -156,36 +139,61 @@ namespace rawaccel { error("snap angle must be between 0 and 45 degrees"); } - if (args.sens.x == 0 || args.sens.y == 0) { + if (args.sensitivity == 0) { error("sens multiplier is 0"); } + + if (args.yx_sens_ratio == 0) { + error("Y/X sens ratio is 0"); + } - if (args.dom_args.domain_weights.x <= 0 || - args.dom_args.domain_weights.y <= 0) { + if (args.domain_weights.x <= 0 || + args.domain_weights.y <= 0) { error("domain weights"" must be positive"); } if (args.dir_multipliers.x <= 0 || args.dir_multipliers.y <= 0) { - error("directional multipliers must be positive"); + error("negative directional multipliers must be positive"); } - if (args.dom_args.lp_norm < 2) { - error("Lp norm is less than 2 (default=2)"); + if (args.lp_norm <= 0) { + error("Lp norm must be positive (default=2)"); } if (args.range_weights.x <= 0 || args.range_weights.y <= 0) { error("range weights"" must be positive"); } - if (args.time_min <= 0) { + return ret; + } + + template + valid_device_ret_t valid(const device_settings& args, MsgHandler fn = {}) + { + valid_device_ret_t ret; + + auto error = [&](auto msg) { + ++ret.count; + fn(msg); + }; + + + if (args.config.dpi < 0) { + error("dpi"" can not be negative"); + } + + if (args.config.polling_rate < 0) { + error("polling rate"" can not be negative"); + } + + if (args.config.clamp.min <= 0) { error("minimum time"" must be positive"); } - if (args.time_max < args.time_min) { + if (args.config.clamp.max < args.config.clamp.min) { error("max time is less than min time"); } return ret; } - } -- cgit v1.2.3 From 39e042a799e7abf0886119ef471eaee261aa02cc Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Mon, 6 Sep 2021 19:16:06 -0400 Subject: increase lut points capacity to 257 remove unneeded constants --- common/rawaccel-validate.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index e901a8a..8b99a56 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -36,14 +36,14 @@ namespace rawaccel { }; auto check_accel = [&error](const accel_args& args) { - static_assert(LUT_POINTS_CAPACITY == 129, "update error msg"); + static_assert(LUT_POINTS_CAPACITY == 257, "update error msg"); if (args.mode == accel_mode::lookup) { if (args.length < 4) { error("lookup mode requires at least 2 points"); } else if (args.length > ra::LUT_RAW_DATA_CAPACITY) { - error("too many data points (max=129)"); + error("too many data points (max=257)"); } } else if (args.length > ra::LUT_RAW_DATA_CAPACITY) { -- cgit v1.2.3 From 4197e030c5cfeda5592816c8028152d9b7b599e0 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 16 Sep 2021 13:07:43 -0700 Subject: Remove weight --- common/rawaccel-validate.hpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index 8b99a56..a88d514 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -94,10 +94,6 @@ namespace rawaccel { error("scale"" must be positive"); } - if (args.weight <= 0) { - error("weight"" must be positive"); - } - if (args.exponent_power <= 0) { error("exponent"" must be positive"); } -- cgit v1.2.3 From 115030165d539fde5440f6232879c7a076dea2ec Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sat, 18 Sep 2021 05:20:53 -0400 Subject: generalize power start-from-1 starting output is determined by (gain) offset --- common/rawaccel-validate.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index a88d514..23deb5f 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -50,16 +50,20 @@ namespace rawaccel { error("data size > max"); } - if (args.offset < 0) { + if (args.input_offset < 0) { error("offset can not be negative"); } - else if (args.mode == accel_mode::jump && args.offset == 0) { + else if (args.mode == accel_mode::jump && args.input_offset == 0) { error("offset can not be 0"); } + if (args.output_offset < 0) { + error("offset can not be negative"); + } + bool jump_or_io_cap = (args.mode == accel_mode::jump || - (args.mode == accel_mode::classic && + ((args.mode == accel_mode::classic || args.mode == accel_mode::power) && args.cap_mode == classic_cap_mode::io)); if (args.cap.x < 0) { @@ -76,6 +80,11 @@ namespace rawaccel { error("cap (output) can not be 0"); } + if (args.cap.x > 0 && args.cap.x < args.input_offset || + args.cap.y > 0 && args.cap.y < args.output_offset) { + error("cap < offset"); + } + if (args.growth_rate <= 0 || args.decay_rate <= 0 || args.acceleration <= 0) { -- cgit v1.2.3 From 94ce1542b03090b81a4250f7f799895c58ab286c Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sat, 18 Sep 2021 05:34:59 -0400 Subject: rename directional multipliers changes profile layout --- common/rawaccel-validate.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index 23deb5f..f1c2980 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -157,8 +157,8 @@ namespace rawaccel { error("domain weights"" must be positive"); } - if (args.dir_multipliers.x <= 0 || args.dir_multipliers.y <= 0) { - error("negative directional multipliers must be positive"); + if (args.lr_sens_ratio <= 0 || args.ud_sens_ratio <= 0) { + error("sens ratio must be positive"); } if (args.lp_norm <= 0) { -- cgit v1.2.3 From d270a967b606116596114744417a182b3f16218b Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sat, 18 Sep 2021 05:39:08 -0400 Subject: rename classic_cap_mode --- common/rawaccel-validate.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index f1c2980..2e892a5 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -64,7 +64,7 @@ namespace rawaccel { bool jump_or_io_cap = (args.mode == accel_mode::jump || ((args.mode == accel_mode::classic || args.mode == accel_mode::power) && - args.cap_mode == classic_cap_mode::io)); + args.cap_mode == cap_mode::io)); if (args.cap.x < 0) { error("cap (input) can not be negative"); -- cgit v1.2.3 From 30b54936bddf31000d6028f7deaa828c5671a48a Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sat, 18 Sep 2021 21:21:05 -0400 Subject: fix input checks --- common/rawaccel-validate.hpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index 2e892a5..4ea7936 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -53,9 +53,6 @@ namespace rawaccel { if (args.input_offset < 0) { error("offset can not be negative"); } - else if (args.mode == accel_mode::jump && args.input_offset == 0) { - error("offset can not be 0"); - } if (args.output_offset < 0) { error("offset can not be negative"); @@ -85,12 +82,22 @@ namespace rawaccel { error("cap < offset"); } - if (args.growth_rate <= 0 || - args.decay_rate <= 0 || - args.acceleration <= 0) { + if (args.acceleration <= 0) { error("acceleration"" must be positive"); } + if (args.scale <= 0) { + error("scale"" must be positive"); + } + + if (args.growth_rate <= 0) { + error("growth rate"" must be positive"); + } + + if (args.decay_rate <= 0) { + error("decay rate"" must be positive"); + } + if (args.motivity <= 1) { error("motivity must be greater than 1"); } @@ -99,10 +106,6 @@ namespace rawaccel { error("exponent must be greater than 1"); } - if (args.scale <= 0) { - error("scale"" must be positive"); - } - if (args.exponent_power <= 0) { error("exponent"" must be positive"); } -- cgit v1.2.3 From 5f997e3658944149bfd18c234de5f41b4bfae913 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sun, 19 Sep 2021 03:22:31 -0400 Subject: fix input checks only check for cap < offset if relevant modes are selected --- common/rawaccel-validate.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'common/rawaccel-validate.hpp') diff --git a/common/rawaccel-validate.hpp b/common/rawaccel-validate.hpp index 4ea7936..b84fdb7 100644 --- a/common/rawaccel-validate.hpp +++ b/common/rawaccel-validate.hpp @@ -77,8 +77,14 @@ namespace rawaccel { error("cap (output) can not be 0"); } - if (args.cap.x > 0 && args.cap.x < args.input_offset || - args.cap.y > 0 && args.cap.y < args.output_offset) { + if ((args.mode == accel_mode::classic && + args.cap.x > 0 && + args.cap.x < args.input_offset && + args.cap_mode != cap_mode::out) || + (args.mode == accel_mode::power && + args.cap.y > 0 && + args.cap.y < args.output_offset && + args.cap_mode != cap_mode::in)) { error("cap < offset"); } -- cgit v1.2.3