Skip to content

Commit 63bd658

Browse files
committed
RadialFollow: Add cursor reset and tweak defaults
This change prevents bounce back in relative mode and prevents cursor from getting stuck in the corner in some fringe cases
1 parent 5c50055 commit 63bd658

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The value should be >= 0 and inner radius.
1414
If smoothing leak is used, defines the point at which smoothing will be reduced,
1515
instead of hard clamping the max distance between the tablet position and a cursor.
1616

17-
Default value is 0.75 mm
17+
Default value is 1 mm
1818

1919
### Inner Radius
2020
Inner radius defines the max distance the tablet reading can deviate from the cursor without moving it.
@@ -23,22 +23,22 @@ This effectively creates a deadzone in which no movement is produced.
2323
Unit of measurement is mm.
2424
The value should be >= 0 and <= outer radius.
2525

26-
Default value is 0.1 mm
26+
Default value is 0.05 mm
2727

2828
### Smoothing Coefficient
2929
Smoothing coefficient determines how fast or slow the cursor will descend from the outer radius to the inner.
3030

3131
Possible value range is 0.0001..1, higher values mean more smoothing (slower descent to the inner radius).
3232

33-
Default value is 0.9
33+
Default value is 0.92
3434

3535
### Soft Knee Scale
3636
Soft knee scale determines how soft the transition between smoothing inside and outside the outer radius is.
3737

38-
Possible value range is 0..10, higher values mean softer transition.
38+
Possible value range is 0..100, higher values mean softer transition.
3939
The effect is somewhat logarithmic, i.e. most of the change happens closer to zero.
4040

41-
Default value is 0.3
41+
Default value is 3
4242

4343
### Smoothing Leak Coefficient
4444
Smoothing leak coefficient allows for input smooting to continue past outer radius at a reduced rate.

RadialFollow/RadialFollowSmoothing.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using OpenTabletDriver.Plugin;
44
using OpenTabletDriver.Plugin.Attributes;
55
using OpenTabletDriver.Plugin.Tablet;
6+
using OpenTabletDriver.Plugin.Timing;
67

78
namespace RadialFollow
89
{
@@ -11,14 +12,14 @@ public class RadialFollowSmoothing : IFilter
1112
{
1213
public FilterStage FilterStage => FilterStage.PreTranspose;
1314

14-
[Property("Outer Radius"), DefaultPropertyValue(0.75f), Unit("mm"), ToolTip
15+
[Property("Outer Radius"), DefaultPropertyValue(1f), Unit("mm"), ToolTip
1516
(
1617
"Outer radius defines the max distance the cursor can lag behind the actual reading.\n\n" +
1718
"Unit of measurement is mm.\n" +
1819
"The value should be >= 0 and inner radius.\n" +
1920
"If smoothing leak is used, defines the point at which smoothing will be reduced,\n" +
2021
"instead of hard clamping the max distance between the tablet position and a cursor.\n\n" +
21-
"Default value is 0.75 mm"
22+
"Default value is 1 mm"
2223
)]
2324
public float OuterRadius
2425
{
@@ -27,13 +28,13 @@ public float OuterRadius
2728
}
2829
private double rOuter = 0;
2930

30-
[Property("Inner Radius"), DefaultPropertyValue(0.1f), Unit("mm"), ToolTip
31+
[Property("Inner Radius"), DefaultPropertyValue(0.05f), Unit("mm"), ToolTip
3132
(
3233
"Inner radius defines the max distance the tablet reading can deviate from the cursor without moving it.\n" +
3334
"This effectively creates a deadzone in which no movement is produced.\n\n" +
3435
"Unit of measurement is mm.\n" +
3536
"The value should be >= 0 and <= outer radius.\n\n" +
36-
"Default value is 0.1 mm"
37+
"Default value is 0.05 mm"
3738
)]
3839
public float InnerRadius
3940
{
@@ -42,11 +43,11 @@ public float InnerRadius
4243
}
4344
private double rInner = 0;
4445

45-
[Property("Smoothing Coefficient"), DefaultPropertyValue(0.9f), ToolTip
46+
[Property("Smoothing Coefficient"), DefaultPropertyValue(0.92f), ToolTip
4647
(
4748
"Smoothing coefficient determines how fast or slow the cursor will descend from the outer radius to the inner.\n\n" +
4849
"Possible value range is 0.0001..1, higher values mean more smoothing (slower descent to the inner radius).\n\n" +
49-
"Default value is 0.9"
50+
"Default value is 0.92"
5051
)]
5152
public float SmoothingCoefficient
5253
{
@@ -55,17 +56,17 @@ public float SmoothingCoefficient
5556
}
5657
private double smoothCoef;
5758

58-
[Property("Soft Knee Scale"), DefaultPropertyValue(0.3f), ToolTip
59+
[Property("Soft Knee Scale"), DefaultPropertyValue(3f), ToolTip
5960
(
6061
"Soft knee scale determines how soft the transition between smoothing inside and outside the outer radius is.\n\n" +
61-
"Possible value range is 0..10, higher values mean softer transition.\n" +
62+
"Possible value range is 0..100, higher values mean softer transition.\n" +
6263
"The effect is somewhat logarithmic, i.e. most of the change happens closer to zero.\n\n" +
63-
"Default value is 0.3"
64+
"Default value is 3"
6465
)]
6566
public float SoftKneeScale
6667
{
6768
get { return (float)knScale; }
68-
set { knScale = System.Math.Clamp(value, 0.0f, 10.0f); updateDerivedParams(); }
69+
set { knScale = System.Math.Clamp(value, 0.0f, 100.0f); updateDerivedParams(); }
6970
}
7071
private double knScale;
7172

@@ -92,10 +93,12 @@ public Vector2 Filter(Vector2 point)
9293
double distance = direction.Length();
9394
direction = Vector2.Normalize(direction);
9495

95-
9696
float distToMove = (float)deltaFn(distance, xOffset, scaleComp);
97-
9897
cursor = cursor + Vector2.Multiply(direction, distToMove);
98+
99+
if (!(float.IsFinite(cursor.X) & float.IsFinite(cursor.Y) & stopwatch.Restart().TotalMilliseconds < 50))
100+
cursor = point;
101+
99102
return cursor;
100103
}
101104

@@ -115,6 +118,8 @@ void updateDerivedParams()
115118
}
116119
}
117120

121+
HPETDeltaStopwatch stopwatch = new HPETDeltaStopwatch(true);
122+
118123
/// Math functions
119124

120125
double kneeFunc(double x) => x switch

0 commit comments

Comments
 (0)