mirror of
https://github.com/RawAccelOfficial/rawaccel.git
synced 2025-05-10 18:06:38 +02:00
Adjust test and use constants
This commit is contained in:
parent
814e9bbdb1
commit
dc6a076537
9 changed files with 26 additions and 16 deletions
|
@ -110,7 +110,7 @@ Arguments:
|
|||
static_cast<double>(it->LastY)
|
||||
};
|
||||
|
||||
devExt->mod.modify(input, devExt->speed_processor, devExt->mod_settings, devExt->input_dpi_factor, time);
|
||||
devExt->mod.modify(input, devExt->speed_processor, devExt->mod_settings, devExt->input_dpi_normalization_factor, time);
|
||||
|
||||
double carried_result_x = input.x + devExt->carry.x;
|
||||
double carried_result_y = input.y + devExt->carry.y;
|
||||
|
@ -373,7 +373,7 @@ DeviceSetup(WDFOBJECT hDevice)
|
|||
auto set_ext_from_cfg = [devExt](const ra::device_config& cfg) {
|
||||
devExt->enable = !cfg.disable;
|
||||
devExt->set_extra_info = cfg.set_extra_info;
|
||||
devExt->input_dpi_factor = (cfg.dpi > 0) ? (1000.0 / cfg.dpi) : 1;
|
||||
devExt->input_dpi_normalization_factor = (cfg.dpi > 0) ? (ra::NORMALIZED_DPI / cfg.dpi) : 1;
|
||||
|
||||
bool rate_given = cfg.polling_rate > 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ typedef struct _DEVICE_EXTENSION {
|
|||
bool enable;
|
||||
bool keep_time;
|
||||
bool set_extra_info;
|
||||
double input_dpi_factor;
|
||||
double input_dpi_normalization_factor;
|
||||
counter_t counter;
|
||||
ra::time_clamp clamp;
|
||||
ra::modifier mod;
|
||||
|
|
|
@ -8,10 +8,10 @@ namespace grapher
|
|||
#region Constants
|
||||
|
||||
/// <summary> DPI by which charts are scaled if none is set by user. </summary>
|
||||
public const int DefaultDPI = 1200;
|
||||
public const int DefaultChartsScalingDPI = 1200;
|
||||
|
||||
/// <summary> Poll rate by which charts are scaled if none is set by user. </summary>
|
||||
public const int DefaultPollRate = 1000;
|
||||
public const int DefaultChartsScalingPollRate = 1000;
|
||||
|
||||
/// <summary> Resolution of chart calulation. </summary>
|
||||
public const int Resolution = 500;
|
||||
|
@ -145,6 +145,9 @@ namespace grapher
|
|||
|
||||
/// <summary> Line Width For Series data on chart </summary>
|
||||
public const int ChartSeriesLineWidth = 3;
|
||||
|
||||
/// <summary> DPI to which driver is normalizing inputs </summary>
|
||||
public const double DriverNormalizedDPI = 1000.0;
|
||||
#endregion Constants
|
||||
|
||||
#region ReadOnly
|
||||
|
|
|
@ -213,8 +213,8 @@ namespace grapher.Models
|
|||
fakeBox.Hide();
|
||||
|
||||
var accelCalculator = new AccelCalculator(
|
||||
new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI, 1),
|
||||
new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate, 1));
|
||||
new Field(dpiTextBox.TextBox, form, Constants.DefaultChartsScalingDPI, 1),
|
||||
new Field(pollRateTextBox.TextBox, form, Constants.DefaultChartsScalingPollRate, 1));
|
||||
|
||||
var accelCharts = new AccelCharts(
|
||||
form,
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace grapher.Models.Calculations
|
|||
}
|
||||
|
||||
var ratio = DecimalCheck(magnitude / simulatedInputDatum.velocity);
|
||||
var slope = DecimalCheck(inDiff > 0 ? outDiff / inDiff : settings.outputDPI / 1000.0);
|
||||
var slope = DecimalCheck(inDiff > 0 ? outDiff / inDiff : settings.outputDPI / Constants.DriverNormalizedDPI);
|
||||
|
||||
bool indexToMeasureExtrema = (angleIndex == 0) || (angleIndex == (Constants.AngleDivisions - 1));
|
||||
|
||||
|
@ -484,7 +484,7 @@ namespace grapher.Models.Calculations
|
|||
settings.rotation > 0;
|
||||
|
||||
public static (double, double) GetSens(Profile settings) =>
|
||||
(settings.outputDPI / 1000.0, settings.outputDPI * settings.yxSensRatio / 1000.0);
|
||||
(settings.outputDPI / Constants.DriverNormalizedDPI, settings.outputDPI * settings.yxSensRatio / Constants.DriverNormalizedDPI);
|
||||
|
||||
public static (double, double) GetRotVector(Profile settings) =>
|
||||
(Math.Cos(settings.rotation), Math.Sin(settings.rotation));
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace grapher.Models.Calculations.Data
|
|||
public void CreateGraphData(ManagedAccel accel, Profile settings)
|
||||
{
|
||||
Clear();
|
||||
Calculator.Calculate(X, accel, settings.outputDPI / 1000.0, Calculator.SimulatedInputCombined);
|
||||
Calculator.Calculate(X, accel, settings.outputDPI / Constants.DriverNormalizedDPI, Calculator.SimulatedInputCombined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ namespace grapher.Models.Calculations.Data
|
|||
public void CreateGraphData(ManagedAccel accel, Profile settings)
|
||||
{
|
||||
Clear();
|
||||
var sensY = settings.outputDPI * settings.yxSensRatio / 1000.0;
|
||||
Calculator.Calculate(X, accel, settings.outputDPI / 1000.0, Calculator.SimulatedInputX);
|
||||
var sensY = settings.outputDPI * settings.yxSensRatio / Constants.DriverNormalizedDPI;
|
||||
Calculator.Calculate(X, accel, settings.outputDPI / Constants.DriverNormalizedDPI, Calculator.SimulatedInputX);
|
||||
Calculator.Calculate(Y, accel, sensY, Calculator.SimulatedInputY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace grapher.Models.Options
|
|||
|
||||
public void SetActiveValues(Profile settings)
|
||||
{
|
||||
Sensitivity.SetActiveValue(settings.outputDPI / 1000.0);
|
||||
Sensitivity.SetActiveValue(settings.outputDPI / Constants.DriverNormalizedDPI);
|
||||
YToXRatio.SetActiveValue(settings.yxSensRatio);
|
||||
Rotation.SetActiveValue(settings.rotation);
|
||||
|
||||
|
|
|
@ -19,12 +19,19 @@ namespace wrapper_tests
|
|||
[TestMethod]
|
||||
public void ModifyInput_WithOutputDPI_HasCorrectFactor()
|
||||
{
|
||||
var accel = new ManagedAccel();
|
||||
double expectedFactor = 2;
|
||||
double expectedNormalizedDPI = 1000;
|
||||
(int x, int y) input = (1, 1);
|
||||
|
||||
var profile = new Profile();
|
||||
profile.outputDPI = expectedFactor * expectedNormalizedDPI;
|
||||
var accel = new ManagedAccel(profile);
|
||||
|
||||
var output = accel.Accelerate(input.x, input.y, 1, 1);
|
||||
|
||||
Assert.AreEqual(input.x, output.Item1);
|
||||
Assert.AreEqual(input.y, output.Item2);
|
||||
(double x, double y) expectedOutput = (expectedFactor * input.x, expectedFactor * input.y);
|
||||
Assert.AreEqual(expectedOutput.x, output.Item1);
|
||||
Assert.AreEqual(expectedOutput.y, output.Item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue