summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-04-01 22:08:01 -0700
committerJacob Palecki <[email protected]>2021-04-01 22:08:01 -0700
commitebfd5a8af07bc5fdf5b463714d8030e49eac53ba (patch)
treea31b8b3350cdde51cfdaa86260d9788c3e75d010
parentAdd lookuptable json (diff)
downloadrawaccel-ebfd5a8af07bc5fdf5b463714d8030e49eac53ba.tar.xz
rawaccel-ebfd5a8af07bc5fdf5b463714d8030e49eac53ba.zip
Add differing table types
-rw-r--r--grapher/Models/Serialized/LookupTable.cs57
-rw-r--r--grapher/grapher.csproj1
-rw-r--r--wrapper/wrapper.cpp35
3 files changed, 55 insertions, 38 deletions
diff --git a/grapher/Models/Serialized/LookupTable.cs b/grapher/Models/Serialized/LookupTable.cs
index 578c5bf..d373461 100644
--- a/grapher/Models/Serialized/LookupTable.cs
+++ b/grapher/Models/Serialized/LookupTable.cs
@@ -10,32 +10,9 @@ using System.Threading.Tasks;
namespace grapher.Models.Serialized
{
[Serializable]
- public class LookupTable
+ public static class LookupTable
{
- [Serializable]
- public class Point
- {
- public Point(double x, double y)
- {
- X = x;
- Y = y;
- }
-
- double X { get; set; }
-
- double Y { get; set; }
- }
-
- public LookupTable(Point[] points)
- {
- Points = points;
- }
-
- public Point[] Points { get; }
-
- public bool InSensGraph { get; }
-
- public static LookupTable Deserialize(string lutFile)
+ public static void Deserialize(string lutFile, ref DriverSettings settings)
{
if (!File.Exists(lutFile))
{
@@ -44,23 +21,29 @@ namespace grapher.Models.Serialized
JObject lutJObject = JObject.Parse(File.ReadAllText(lutFile));
- var lut = lutJObject.ToObject<LookupTable>(JsonSerializer.Create(RawAccelSettings.SerializerSettings));
+ var spacedLut = lutJObject.ToObject<SpacedTable>(JsonSerializer.Create(RawAccelSettings.SerializerSettings));
- if (lut is null || lut.Points is null)
+ if (spacedLut is null)
{
- throw new Exception($"{lutFile} does not contain valid lookuptable json.");
- }
+ var arbitraryLut = lutJObject.ToObject<ArbitraryTable>(JsonSerializer.Create(RawAccelSettings.SerializerSettings));
- lut.Verify();
+ if (arbitraryLut is null || arbitraryLut.points is null)
+ {
+ throw new Exception($"{lutFile} does not contain valid lookuptable json.");
+ }
- return lut;
- }
-
- private void Verify()
- {
- if (Points.Length >= short.MaxValue)
+ settings.ArbitraryTable = arbitraryLut;
+ settings.args.x.lutArgs.type = TableType.arbitrary;
+ }
+ else
{
- throw new Exception($"LUT file with {Points.Length} points is too long. Max points: {short.MaxValue}");
+ if (spacedLut.points is null)
+ {
+ throw new Exception($"{lutFile} does not contain valid lookuptable json.");
+ }
+
+ settings.SpacedTable = spacedLut;
+ settings.args.x.lutArgs = spacedLut.args;
}
}
}
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index 1160ba8..67948ff 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -136,6 +136,7 @@
<Compile Include="Models\Options\OptionBase.cs" />
<Compile Include="Models\Options\OptionXY.cs" />
<Compile Include="Models\Serialized\GUISettings.cs" />
+ <Compile Include="Models\Serialized\LookupTable.cs" />
<Compile Include="Models\Serialized\RawAccelSettings.cs" />
<Compile Include="Models\Serialized\SettingsManager.cs" />
<Compile Include="Program.cs" />
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp
index 84756af..7583312 100644
--- a/wrapper/wrapper.cpp
+++ b/wrapper/wrapper.cpp
@@ -25,7 +25,7 @@ ra::settings default_settings;
[JsonConverter(Converters::StringEnumConverter::typeid)]
public enum class AccelMode
{
- classic, jump, natural, power, motivity, noaccel
+ classic, jump, natural, power, motivity, lut, noaccel
};
public enum class TableMode
@@ -33,12 +33,20 @@ public enum class TableMode
off, binlog, linear
};
+public enum class TableType
+{
+ spaced, arbitrary
+};
+
[StructLayout(LayoutKind::Sequential)]
public value struct TableArgs
{
[JsonIgnore]
TableMode mode;
+ [JsonIgnore]
+ TableType type;
+
[MarshalAs(UnmanagedType::U1)]
bool transfer;
@@ -50,6 +58,7 @@ public value struct TableArgs
double stop;
};
+
generic <typename T>
[StructLayout(LayoutKind::Sequential)]
public value struct Vec2
@@ -58,6 +67,24 @@ public value struct Vec2
T y;
};
+public ref struct SpacedTable
+{
+ [JsonProperty("Arguments for spacing in table")]
+ TableArgs args;
+
+ [JsonProperty("Series of points for use in curve")]
+ List<double>^ points;
+};
+
+public ref struct ArbitraryTable
+{
+ [JsonProperty("Whether points affect velocity (true) or sensitivity (false)")]
+ bool transfer;
+
+ [JsonProperty("Series of points for use in curve")]
+ List<Vec2<double>>^ points;
+};
+
[StructLayout(LayoutKind::Sequential)]
public value struct AccelArgs
{
@@ -144,6 +171,12 @@ public ref struct DriverSettings
[MarshalAs(UnmanagedType::ByValTStr, SizeConst = ra::MAX_DEV_ID_LEN)]
String^ deviceID = "";
+ [JsonIgnore]
+ SpacedTable^ SpacedTable;
+
+ [JsonIgnore]
+ ArbitraryTable^ ArbitraryTable;
+
bool ShouldSerializeminimumTime()
{
return minimumTime != ra::DEFAULT_TIME_MIN;