diff options
| author | Jacob Palecki <[email protected]> | 2021-01-08 00:22:33 -0800 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2021-01-08 00:22:33 -0800 |
| commit | a368a0ede47a6f70b2779fca86f800741debcc19 (patch) | |
| tree | 1fc72a3b9b2336aca6e0a5a9d019c338da22385e | |
| parent | Add core logic in common (diff) | |
| download | rawaccel-a368a0ede47a6f70b2779fca86f800741debcc19.tar.xz rawaccel-a368a0ede47a6f70b2779fca86f800741debcc19.zip | |
Add to stigma, directional to settings
| -rw-r--r-- | common/rawaccel-settings.h | 2 | ||||
| -rw-r--r-- | common/rawaccel.hpp | 31 |
2 files changed, 22 insertions, 11 deletions
diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index 649c936..2c5b86f 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -22,6 +22,8 @@ namespace rawaccel { vec2<accel_args> argsv; vec2d sens = { 1, 1 }; vec2d dir_multipliers = {}; + vec2d directional_weights = { 1, 1 }; + stigma_args args_stigma; milliseconds time_min = DEFAULT_TIME_MIN; }; diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index d00f689..4a9dc90 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -225,6 +225,11 @@ namespace rawaccel { accelerator() = default; }; + struct stigma_args { + vec2d sigmas = { 1, 1 }; + double lp_norm = 2; + }; + struct stigma_distance { double p = 2.0; double p_inverse = 0.5; @@ -232,11 +237,11 @@ namespace rawaccel { double sigma_x = 1.0; double sigma_y = 1.0; - stigma_distance(double sigma_x_in, double sigma_y_in, double lp_norm_in) + stigma_distance(stigma_args args) { - sigma_x = sigma_x_in; - sigma_y = sigma_y_in; - if (lp_norm_in <= 0) + sigma_x = args.sigmas.x; + sigma_y = args.sigmas.y; + if (args.lp_norm <= 0) { lp_norm_infinity = true; p = 0.0; @@ -245,15 +250,15 @@ namespace rawaccel { else { lp_norm_infinity = false; - p = lp_norm_in; - p_inverse = 1 / lp_norm_in; + p = args.lp_norm; + p_inverse = 1 / args.lp_norm; } } double calculate(int x, int y) { double x_scaled = x * sigma_x; - double y_scaled = y * sigma_x; + double y_scaled = y * sigma_y; return pow(pow(x_scaled, p) + pow(y_scaled, p), p_inverse); } @@ -265,10 +270,10 @@ namespace rawaccel { double start = 1.0; bool should_apply = false; - direction_weight(double theta_x_in, double theta_y_in) + direction_weight(vec2d thetas) { - diff = theta_y_in - theta_x_in; - start = theta_x_in; + diff = thetas.y - thetas.x; + start = thetas.x; if (diff != 0) { @@ -282,7 +287,7 @@ namespace rawaccel { inline int atan_scale(double x, double y) { - return M_2_PI * atan2(abs(y), abs(x)); + return M_2_PI * atan2(fabs(y), fabs(x)); } double apply(double x, double y) @@ -327,6 +332,10 @@ namespace rawaccel { accels.x = accelerator(args.argsv.x, args.modes.x, luts.x); accels.y = accelerator(args.argsv.y, args.modes.y, luts.y); + + stigma = stigma_distance(args.args_stigma); + directional = direction_weight(args.directional_weights); + apply_accel = true; } |