mirror of
https://github.com/RawAccelOfficial/rawaccel.git
synced 2025-05-12 10:57:10 +02:00
other changes: modifier_args type name is now settings, which is now the type passed in driver ioctl remove most settings/args verification from driver, plan to let gui handle most of it add another accel arg, rate, which is used to set the 'accel' parameter of types which call exp (nat/sig), might want to cap it add (update) serializable DriverSettings (ModifierArgs) class to gui and static methods for interop remove properties from ManagedAccel, its now just a black box for accessing modifier methods add exception handling in wrapper_io to throw proper managed types change SettingsManager::Startup to make a new settings file if an error occurs during deserialization change structure of accel types; how offset and weight are applied now depend on additivity of types remove tagged_union and add a handrolled variant/visit impl AccelGui::UpdateActiveValueLabels currently broken for caps and a few other args remove gui default layout and initial natural accel setup cli not updated
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#pragma once
|
|
|
|
namespace rawaccel {
|
|
|
|
/// <summary> Struct to hold arguments for an acceleration function. </summary>
|
|
struct accel_args {
|
|
double offset = 0;
|
|
double accel = 0;
|
|
double limit = 2;
|
|
double exponent = 2;
|
|
double midpoint = 0;
|
|
double power_scale = 1;
|
|
double power_exp = 0.05;
|
|
double weight = 1;
|
|
double rate = 0;
|
|
double scale_cap = 0;
|
|
double gain_cap = 0;
|
|
};
|
|
|
|
template <typename Func>
|
|
struct accel_val_base {
|
|
double offset = 0;
|
|
double weight = 1;
|
|
Func fn;
|
|
|
|
accel_val_base(const accel_args& args) : fn(args) {}
|
|
|
|
};
|
|
|
|
template <typename Func>
|
|
struct additive_accel : accel_val_base<Func> {
|
|
|
|
additive_accel(const accel_args& args) : accel_val_base(args) {
|
|
offset = args.offset;
|
|
weight = args.weight;
|
|
}
|
|
|
|
inline double operator()(double speed) const {
|
|
return 1 + fn(maxsd(speed - offset, 0)) * weight;
|
|
}
|
|
|
|
};
|
|
|
|
template <typename Func>
|
|
struct nonadditive_accel : accel_val_base<Func> {
|
|
|
|
nonadditive_accel(const accel_args& args) : accel_val_base(args) {
|
|
if (args.weight != 0) weight = args.weight;
|
|
}
|
|
|
|
inline double operator()(double speed) const {
|
|
return fn(speed) * weight;
|
|
}
|
|
|
|
};
|
|
|
|
}
|