From f83a3fabcaf45151b24b0e308a3193d1530a7c4d Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Tue, 20 Dec 2022 02:39:54 +0800 Subject: [PATCH 1/7] Update OTD submodule to 0.7.0-pre --- .gitmodules | 2 +- .modules/OpenTabletDriver | 2 +- Directory.Build.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index f395a5e..9210110 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule ".modules/OpenTabletDriver"] path = .modules/OpenTabletDriver - url = https://github.com/InfinityGhost/OpenTabletDriver + url = https://github.com/OpenTabletDriver/OpenTabletDriver diff --git a/.modules/OpenTabletDriver b/.modules/OpenTabletDriver index 0af7678..d01818c 160000 --- a/.modules/OpenTabletDriver +++ b/.modules/OpenTabletDriver @@ -1 +1 @@ -Subproject commit 0af7678defe2f4390fcc2aa8a6b2420074c7e3d2 +Subproject commit d01818c1419b8901702f3e0b97c7d50674c90c67 diff --git a/Directory.Build.props b/Directory.Build.props index 8349d68..59b3354 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,7 @@ - + From 51947ec65d4bb1cd703baedabedf69a3d8c14859 Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Tue, 20 Dec 2022 02:40:08 +0800 Subject: [PATCH 2/7] Switch to .NET 7.0 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 59b3354..04aaf88 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - net6.0 + net7.0 From a662c20c2009aca38170d0df43a3e6e81b317f68 Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Tue, 20 Dec 2022 03:29:06 +0800 Subject: [PATCH 3/7] Update filters to 0.7.x API --- ...illimeterAsyncPositionedPipelineElement.cs | 22 ++++-------- Common/MillimeterPositionedPipelineElement.cs | 21 ++++------- DevocubFilters/AntiChatter.cs | 32 ++++++++++------- HawkuFilters/NoiseReduction.cs | 15 +++++--- HawkuFilters/Smoothing.cs | 36 ++++++++++--------- 5 files changed, 61 insertions(+), 65 deletions(-) diff --git a/Common/MillimeterAsyncPositionedPipelineElement.cs b/Common/MillimeterAsyncPositionedPipelineElement.cs index abc97f4..8675116 100644 --- a/Common/MillimeterAsyncPositionedPipelineElement.cs +++ b/Common/MillimeterAsyncPositionedPipelineElement.cs @@ -1,31 +1,21 @@ using System.Numerics; -using OpenTabletDriver.Plugin.Attributes; -using OpenTabletDriver.Plugin.Output; -using OpenTabletDriver.Plugin.Tablet; +using OpenTabletDriver; +using OpenTabletDriver.Output; namespace TabletDriverFilters { - public abstract class MillimeterAsyncPositionedPipelineElement : AsyncPositionedPipelineElement + public abstract class MillimeterAsyncPositionedPipelineElement : AsyncDevicePipelineElement { - [TabletReference] - public TabletReference TabletReference { set => HandleTabletReferenceInternal(value); } + protected readonly Vector2 MillimeterScale; - protected Vector2 MillimeterScale; - - private void HandleTabletReferenceInternal(TabletReference tabletReference) + protected MillimeterAsyncPositionedPipelineElement(InputDevice inputDevice, ITimer scheduler) : base(scheduler) { - var digitizer = tabletReference.Properties.Specifications.Digitizer; + var digitizer = inputDevice.Configuration.Specifications.Digitizer; MillimeterScale = new Vector2 { X = digitizer.Width / digitizer.MaxX, Y = digitizer.Height / digitizer.MaxY }; - HandleTabletReference(tabletReference); - } - - protected virtual void HandleTabletReference(TabletReference tabletReference) - { - // Override when needed } } } diff --git a/Common/MillimeterPositionedPipelineElement.cs b/Common/MillimeterPositionedPipelineElement.cs index 86e1de6..8a51326 100644 --- a/Common/MillimeterPositionedPipelineElement.cs +++ b/Common/MillimeterPositionedPipelineElement.cs @@ -1,35 +1,28 @@ using System; using System.Numerics; -using OpenTabletDriver.Plugin.Attributes; -using OpenTabletDriver.Plugin.Output; -using OpenTabletDriver.Plugin.Tablet; +using OpenTabletDriver; +using OpenTabletDriver.Attributes; +using OpenTabletDriver.Output; +using OpenTabletDriver.Tablet; namespace TabletDriverFilters { - public abstract class MillimeterPositionedPipelineElement : IPositionedPipelineElement + public abstract class MillimeterPositionedPipelineElement : IDevicePipelineElement { protected Vector2 MillimeterScale; - [TabletReference] - public TabletReference TabletReference { set => HandleTabletReferenceInternal(value); } public abstract PipelinePosition Position { get; } public abstract event Action Emit; public abstract void Consume(IDeviceReport value); - private void HandleTabletReferenceInternal(TabletReference tabletReference) + protected MillimeterPositionedPipelineElement(InputDevice inputDevice) { - var digitizer = tabletReference.Properties.Specifications.Digitizer; + var digitizer = inputDevice.Configuration.Specifications.Digitizer; MillimeterScale = new Vector2 { X = digitizer.Width / digitizer.MaxX, Y = digitizer.Height / digitizer.MaxY }; - HandleTabletReference(tabletReference); - } - - protected virtual void HandleTabletReference(TabletReference tabletReference) - { - // Override when needed } } } diff --git a/DevocubFilters/AntiChatter.cs b/DevocubFilters/AntiChatter.cs index 3124118..004c047 100644 --- a/DevocubFilters/AntiChatter.cs +++ b/DevocubFilters/AntiChatter.cs @@ -1,8 +1,10 @@ using System; +using System.ComponentModel; using System.Numerics; -using OpenTabletDriver.Plugin.Attributes; -using OpenTabletDriver.Plugin.Output; -using OpenTabletDriver.Plugin.Tablet; +using OpenTabletDriver; +using OpenTabletDriver.Attributes; +using OpenTabletDriver.Output; +using OpenTabletDriver.Tablet; namespace TabletDriverFilters.Devocub { @@ -72,38 +74,38 @@ public class Antichatter : MillimeterAsyncPositionedPipelineElement public override PipelinePosition Position => PipelinePosition.PreTransform; - [SliderProperty("Latency", 0f, 1000f, 2f), DefaultPropertyValue(2f), ToolTip(LATENCY_TOOLTIP)] + [RangeSetting("Latency", 0f, 1000f, 2f), DefaultValue(2f), ToolTip(LATENCY_TOOLTIP)] public float Latency { set => this.latency = Math.Clamp(value, 0, 1000); get => this.latency; } - [Property("Antichatter Strength"), DefaultPropertyValue(3f), ToolTip(ANTICHATTER_TOOLTIP)] + [Setting("Antichatter Strength"), DefaultValue(3f), ToolTip(ANTICHATTER_TOOLTIP)] public float AntichatterStrength { set; get; } - [Property("Antichatter Multiplier"), DefaultPropertyValue(1f), ToolTip(ANTICHATTER_TOOLTIP)] + [Setting("Antichatter Multiplier"), DefaultValue(1f), ToolTip(ANTICHATTER_TOOLTIP)] public float AntichatterMultiplier { set; get; } - [Property("Antichatter Offset X"), ToolTip(ANTICHATTER_TOOLTIP)] + [Setting("Antichatter Offset X"), ToolTip(ANTICHATTER_TOOLTIP)] public float AntichatterOffsetX { set; get; } - [Property("Antichatter Offset Y"), DefaultPropertyValue(1f), ToolTip(ANTICHATTER_TOOLTIP)] + [Setting("Antichatter Offset Y"), DefaultValue(1f), ToolTip(ANTICHATTER_TOOLTIP)] public float AntichatterOffsetY { set; get; } - [BooleanProperty("Prediction", ""), ToolTip(PREDICTION_TOOLTIP)] + [Setting("Prediction"), ToolTip(PREDICTION_TOOLTIP)] public bool PredictionEnabled { set; get; } - [Property("Prediction Strength"), DefaultPropertyValue(1.1f), ToolTip(PREDICTION_TOOLTIP)] + [Setting("Prediction Strength"), DefaultValue(1.1f), ToolTip(PREDICTION_TOOLTIP)] public float PredictionStrength { set; get; } - [Property("Prediction Sharpness"), DefaultPropertyValue(1f), ToolTip(PREDICTION_TOOLTIP)] + [Setting("Prediction Sharpness"), DefaultValue(1f), ToolTip(PREDICTION_TOOLTIP)] public float PredictionSharpness { set; get; } - [Property("Prediction Offset X"), DefaultPropertyValue(3f), ToolTip(PREDICTION_TOOLTIP)] + [Setting("Prediction Offset X"), DefaultValue(3f), ToolTip(PREDICTION_TOOLTIP)] public float PredictionOffsetX { set; get; } - [Property("Prediction Offset Y"), DefaultPropertyValue(0.3f), ToolTip(PREDICTION_TOOLTIP)] + [Setting("Prediction Offset Y"), DefaultValue(0.3f), ToolTip(PREDICTION_TOOLTIP)] public float PredictionOffsetY { set; get; } private const float THRESHOLD = 0.9f; @@ -115,6 +117,10 @@ public float Latency private uint pressure; private Vector2 prevTargetPos, targetPos, calcTarget; + public Antichatter(InputDevice inputDevice, ITimer scheduler) : base(inputDevice, scheduler) + { + } + protected override void ConsumeState() { if (State is ITabletReport report) diff --git a/HawkuFilters/NoiseReduction.cs b/HawkuFilters/NoiseReduction.cs index b50d5a4..95ae27f 100644 --- a/HawkuFilters/NoiseReduction.cs +++ b/HawkuFilters/NoiseReduction.cs @@ -1,8 +1,9 @@ using System; +using System.ComponentModel; using System.Numerics; -using OpenTabletDriver.Plugin.Attributes; -using OpenTabletDriver.Plugin.Output; -using OpenTabletDriver.Plugin.Tablet; +using OpenTabletDriver.Attributes; +using OpenTabletDriver.Output; +using OpenTabletDriver.Tablet; using TabletDriverFilters; using TabletDriverFilters.Hawku.Utility; @@ -29,7 +30,7 @@ public class NoiseReduction : MillimeterPositionedPipelineElement + "Recommendations:\n" + " Samples = 5 - 20, Threshold = 0.2 - 1.0 mm."; - [Property("Buffer"), DefaultPropertyValue(10), ToolTip(NOISEREDUCTION_TOOLTIP)] + [Setting("Buffer"), DefaultValue(10), ToolTip(NOISEREDUCTION_TOOLTIP)] public int Samples { set @@ -40,7 +41,7 @@ public int Samples get => this.samples; } - [Property("Distance Threshold"), Unit("mm"), DefaultPropertyValue(0.5f), ToolTip(NOISEREDUCTION_TOOLTIP)] + [Setting("Distance Threshold"), Unit("mm"), DefaultValue(0.5f), ToolTip(NOISEREDUCTION_TOOLTIP)] public float DistanceThreshold { set @@ -59,6 +60,10 @@ public float DistanceThreshold private int samples; private Vector2 outputPosition; + public NoiseReduction(InputDevice inputDevice) : base(inputDevice) + { + } + public override event Action Emit; public override void Consume(IDeviceReport value) diff --git a/HawkuFilters/Smoothing.cs b/HawkuFilters/Smoothing.cs index 58ec14a..d593b79 100644 --- a/HawkuFilters/Smoothing.cs +++ b/HawkuFilters/Smoothing.cs @@ -1,8 +1,10 @@ using System; +using System.ComponentModel; using System.Numerics; -using OpenTabletDriver.Plugin.Attributes; -using OpenTabletDriver.Plugin.Output; -using OpenTabletDriver.Plugin.Tablet; +using OpenTabletDriver; +using OpenTabletDriver.Attributes; +using OpenTabletDriver.Output; +using OpenTabletDriver.Tablet; namespace TabletDriverFilters.Hawku { @@ -11,7 +13,7 @@ public class Smoothing : MillimeterAsyncPositionedPipelineElement { public override PipelinePosition Position => PipelinePosition.PreTransform; - [SliderProperty("Latency", 0.0f, 1000.0f, 2.0f), DefaultPropertyValue(2f)] + [RangeSetting("Latency", 0.0f, 1000.0f, 2.0f), DefaultValue(2f)] [ToolTip( "Smoothing Filter\n" + " - Smoothing filter adds latency to the input, so don't enable it if you want the lowest possible input latency.\n" @@ -25,7 +27,7 @@ public class Smoothing : MillimeterAsyncPositionedPipelineElement public float Latency { set; get; } private const float THRESHOLD = 0.63f; - private float timerInterval => 1000 / Frequency; + private float TimerInterval => 1000 / Frequency; private float weight; private DateTime? lastFilterTime; @@ -33,6 +35,17 @@ public class Smoothing : MillimeterAsyncPositionedPipelineElement private Vector3 targetPos; private Vector3 lastPos; + public Smoothing(InputDevice inputDevice, ITimer scheduler) : base(inputDevice, scheduler) + { + var digitizer = inputDevice.Configuration.Specifications.Digitizer; + this.mmScale = new Vector3 + { + X = digitizer.Width / digitizer.MaxX, + Y = digitizer.Height / digitizer.MaxY, + Z = 1 // passthrough + }; + } + protected override void ConsumeState() { if (State is ITabletReport report) @@ -76,20 +89,9 @@ public Vector3 Filter(Vector3 point) private void SetWeight(float latency) { - float stepCount = latency / timerInterval; + float stepCount = latency / TimerInterval; float target = 1 - THRESHOLD; this.weight = 1f - (1f / MathF.Pow(1f / target, 1f / stepCount)); } - - protected override void HandleTabletReference(TabletReference tabletReference) - { - var digitizer = tabletReference.Properties.Specifications.Digitizer; - this.mmScale = new Vector3 - { - X = digitizer.Width / digitizer.MaxX, - Y = digitizer.Height / digitizer.MaxY, - Z = 1 // passthrough - }; - } } } From 553e67b602b24d6bfbc2495ffd886834b635dd73 Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Wed, 21 Dec 2022 05:18:21 +0800 Subject: [PATCH 4/7] Update CI --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index cb436de..62bd849 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0' + dotnet-version: '7.0' - name: Filters Build run: dotnet build ${{ matrix.Filters }}/${{ matrix.Filters }}.csproj -o ./build From 5ff7b6e7f57b80d3d555c7f1f1cdf50518c81f9a Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Mon, 9 Jan 2023 08:07:48 +0000 Subject: [PATCH 5/7] Inject settings --- DevocubFilters/AntiChatter.cs | 3 ++- HawkuFilters/NoiseReduction.cs | 3 ++- HawkuFilters/Smoothing.cs | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DevocubFilters/AntiChatter.cs b/DevocubFilters/AntiChatter.cs index 004c047..9e0d9ff 100644 --- a/DevocubFilters/AntiChatter.cs +++ b/DevocubFilters/AntiChatter.cs @@ -117,8 +117,9 @@ public float Latency private uint pressure; private Vector2 prevTargetPos, targetPos, calcTarget; - public Antichatter(InputDevice inputDevice, ITimer scheduler) : base(inputDevice, scheduler) + public Antichatter(InputDevice inputDevice, ITimer scheduler, ISettingsProvider settingsProvider) : base(inputDevice, scheduler) { + settingsProvider.Inject(this); } protected override void ConsumeState() diff --git a/HawkuFilters/NoiseReduction.cs b/HawkuFilters/NoiseReduction.cs index 95ae27f..ce4da2e 100644 --- a/HawkuFilters/NoiseReduction.cs +++ b/HawkuFilters/NoiseReduction.cs @@ -60,8 +60,9 @@ public float DistanceThreshold private int samples; private Vector2 outputPosition; - public NoiseReduction(InputDevice inputDevice) : base(inputDevice) + public NoiseReduction(InputDevice inputDevice, ISettingsProvider settingsProvider) : base(inputDevice) { + settingsProvider.Inject(this); } public override event Action Emit; diff --git a/HawkuFilters/Smoothing.cs b/HawkuFilters/Smoothing.cs index d593b79..cae6c6c 100644 --- a/HawkuFilters/Smoothing.cs +++ b/HawkuFilters/Smoothing.cs @@ -35,7 +35,7 @@ public class Smoothing : MillimeterAsyncPositionedPipelineElement private Vector3 targetPos; private Vector3 lastPos; - public Smoothing(InputDevice inputDevice, ITimer scheduler) : base(inputDevice, scheduler) + public Smoothing(InputDevice inputDevice, ITimer scheduler, ISettingsProvider settingsProvider) : base(inputDevice, scheduler) { var digitizer = inputDevice.Configuration.Specifications.Digitizer; this.mmScale = new Vector3 @@ -44,6 +44,8 @@ public Smoothing(InputDevice inputDevice, ITimer scheduler) : base(inputDevice, Y = digitizer.Height / digitizer.MaxY, Z = 1 // passthrough }; + + settingsProvider.Inject(this); } protected override void ConsumeState() From 12a0edc74c64751fcb1e7819a04409c210facc53 Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Mon, 9 Jan 2023 09:33:09 +0000 Subject: [PATCH 6/7] Use Release configuration --- .github/workflows/dotnet.yml | 2 +- Directory.Build.props | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 62bd849..2449b6a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -27,7 +27,7 @@ jobs: dotnet-version: '7.0' - name: Filters Build - run: dotnet build ${{ matrix.Filters }}/${{ matrix.Filters }}.csproj -o ./build + run: dotnet build ${{ matrix.Filters }}/${{ matrix.Filters }}.csproj -o ./build -c Release - name: Upload Filters artifact uses: actions/upload-artifact@master diff --git a/Directory.Build.props b/Directory.Build.props index 04aaf88..add2205 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,6 +2,7 @@ net7.0 + embedded From fe009fe27324b56b42e0caa9f8333c4343e3ce8d Mon Sep 17 00:00:00 2001 From: X9VoiD Date: Mon, 9 Jan 2023 09:33:49 +0000 Subject: [PATCH 7/7] Update submodule --- .modules/OpenTabletDriver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.modules/OpenTabletDriver b/.modules/OpenTabletDriver index d01818c..da80af4 160000 --- a/.modules/OpenTabletDriver +++ b/.modules/OpenTabletDriver @@ -1 +1 @@ -Subproject commit d01818c1419b8901702f3e0b97c7d50674c90c67 +Subproject commit da80af4258293044ba38db06497a950ae1dd8a55