Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 0.7.x API #25

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ 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
run: dotnet build ${{ matrix.Filters }}/${{ matrix.Filters }}.csproj -o ./build -c Release

- name: Upload Filters artifact
uses: actions/upload-artifact@master
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule ".modules/OpenTabletDriver"]
path = .modules/OpenTabletDriver
url = https://github.com/InfinityGhost/OpenTabletDriver
url = https://github.com/OpenTabletDriver/OpenTabletDriver
2 changes: 1 addition & 1 deletion .modules/OpenTabletDriver
Submodule OpenTabletDriver updated 988 files
22 changes: 6 additions & 16 deletions Common/MillimeterAsyncPositionedPipelineElement.cs
Original file line number Diff line number Diff line change
@@ -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<IDeviceReport>
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
}
}
}
21 changes: 7 additions & 14 deletions Common/MillimeterPositionedPipelineElement.cs
Original file line number Diff line number Diff line change
@@ -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<IDeviceReport>
public abstract class MillimeterPositionedPipelineElement : IDevicePipelineElement
{
protected Vector2 MillimeterScale;

[TabletReference]
public TabletReference TabletReference { set => HandleTabletReferenceInternal(value); }
public abstract PipelinePosition Position { get; }
public abstract event Action<IDeviceReport> 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
}
}
}
33 changes: 20 additions & 13 deletions DevocubFilters/AntiChatter.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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;
Expand All @@ -115,6 +117,11 @@ public float Latency
private uint pressure;
private Vector2 prevTargetPos, targetPos, calcTarget;

public Antichatter(InputDevice inputDevice, ITimer scheduler, ISettingsProvider settingsProvider) : base(inputDevice, scheduler)
{
settingsProvider.Inject(this);
}

protected override void ConsumeState()
{
if (State is ITabletReport report)
Expand Down
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)/.modules/OpenTabletDriver/OpenTabletDriver.Plugin/OpenTabletDriver.Plugin.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)/.modules/OpenTabletDriver/OpenTabletDriver/OpenTabletDriver.csproj" />
<Compile Include="$(MSBuildThisFileDirectory)/Common/*.cs" />
</ItemGroup>

Expand Down
16 changes: 11 additions & 5 deletions HawkuFilters/NoiseReduction.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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
Expand All @@ -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
Expand All @@ -59,6 +60,11 @@ public float DistanceThreshold
private int samples;
private Vector2 outputPosition;

public NoiseReduction(InputDevice inputDevice, ISettingsProvider settingsProvider) : base(inputDevice)
{
settingsProvider.Inject(this);
}

public override event Action<IDeviceReport> Emit;

public override void Consume(IDeviceReport value)
Expand Down
38 changes: 21 additions & 17 deletions HawkuFilters/Smoothing.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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"
Expand All @@ -25,14 +27,27 @@ 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;
private Vector3 mmScale;
private Vector3 targetPos;
private Vector3 lastPos;

public Smoothing(InputDevice inputDevice, ITimer scheduler, ISettingsProvider settingsProvider) : 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
};

settingsProvider.Inject(this);
}

protected override void ConsumeState()
{
if (State is ITabletReport report)
Expand Down Expand Up @@ -76,20 +91,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
};
}
}
}