driver - apply accel disregarding num packets

add setting for max time threshold
This commit is contained in:
a1xd 2021-04-01 18:33:00 -04:00
parent 98de0eaac2
commit e9866f27d7
4 changed files with 29 additions and 19 deletions

View file

@ -5,9 +5,11 @@
namespace rawaccel {
using milliseconds = double;
inline constexpr int POLL_RATE_MIN = 125;
inline constexpr int POLL_RATE_MAX = 8000;
inline constexpr milliseconds DEFAULT_TIME_MIN = 1000.0 / POLL_RATE_MAX / 2;
inline constexpr milliseconds DEFAULT_TIME_MAX = 1000.0 / POLL_RATE_MIN * 2;
inline constexpr milliseconds WRITE_DELAY = 1000;
@ -77,7 +79,9 @@ namespace rawaccel {
vec2d dir_multipliers = {};
domain_args dom_args = {};
vec2d range_weights = { 1, 1 };
milliseconds time_min = DEFAULT_TIME_MIN;
milliseconds time_max = DEFAULT_TIME_MAX;
bool ignore = false;
wchar_t device_id[MAX_DEV_ID_LEN] = {};

View file

@ -162,6 +162,10 @@ namespace rawaccel {
error("minimum time"" must be positive");
}
if (args.time_max < args.time_min) {
error("max time is less than min time");
}
return ret;
}

View file

@ -60,9 +60,18 @@ Arguments:
bool(wcsncmp(devExt->dev_id, global.args.device_id, ra::MAX_DEV_ID_LEN));
if (any && rel_move && dev_match) {
// if IO is backed up to the point where we get more than 1 packet here
// then applying accel is pointless as we can't get an accurate timing
bool enable_accel = num_packets == 1;
milliseconds time;
if (global.args.time_min == global.args.time_max) {
time = global.args.time_min;
}
else {
counter_t now = KeQueryPerformanceCounter(NULL).QuadPart;
counter_t ticks = now - devExt->counter;
devExt->counter = now;
milliseconds t = ticks * global.tick_interval / num_packets;
time = ra::clampsd(t, global.args.time_min, global.args.time_max);
}
auto it = InputDataStart;
do {
@ -72,22 +81,7 @@ Arguments:
static_cast<double>(it->LastY)
};
global.modifier.apply_rotation(input);
global.modifier.apply_angle_snap(input);
if (enable_accel) {
auto time_supplier = [=] {
counter_t now = KeQueryPerformanceCounter(NULL).QuadPart;
counter_t ticks = now - devExt->counter;
devExt->counter = now;
milliseconds time = ticks * global.tick_interval;
return ra::clampsd(time, global.args.time_min, 100);
};
global.modifier.apply_acceleration(input, time_supplier);
}
global.modifier.apply_sensitivity(input);
global.modifier.modify(input, time);
double carried_result_x = input.x + devExt->carry.x;
double carried_result_y = input.y + devExt->carry.y;

View file

@ -130,6 +130,9 @@ public ref struct DriverSettings
[JsonProperty(Required = Required::Default)]
double minimumTime;
[JsonProperty(Required = Required::Default)]
double maximumTime;
[JsonProperty("Ignore devices with matching ID")]
[MarshalAs(UnmanagedType::U1)]
bool ignore;
@ -143,6 +146,11 @@ public ref struct DriverSettings
return minimumTime != ra::DEFAULT_TIME_MIN;
}
bool ShouldSerializemaximumTime()
{
return maximumTime != ra::DEFAULT_TIME_MAX;
}
DriverSettings()
{
Marshal::PtrToStructure(IntPtr(&default_settings), this);