Skip to content

Commit

Permalink
Prediction implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Devocub authored Jul 13, 2018
1 parent b2df0b2 commit 2310225
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 71 deletions.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,54 @@ Increase Strength to 4-10 to get more sharp. Decrease Strength to 1-2 to get mor
[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u75xAd7c2gVvHRxAt/YP9kk07MbOKePxdIvxuHV5sbu/tQ8E)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/smooth.png)

**Straight**: Latency 20-40ms, Strength 20, Multiplier 1, OffsetX 0.7, OffsetY 0.6. This preset aren't good for high hovering.
**Straight**: Latency 20-40ms, Strength 20, Multiplier 1, OffsetX 0.7, OffsetY 0.6. This preset aren't good for high hovering. Because of OffsetY < 1 actual latency is less.
[Interactive link](http://yotx.ru/#!1/3_h/sH%401sH%400YM4X9t/2j/YH/rYN%40IIfyv7W/sQQ8giN31jZ0D8ObWLngLegA53T/YJ9GwGzunjMfTLcbj1uXF7v7WPgI=)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/straight.png)


**Low latency**: Set Offset Y to 0 (and could be useful to set Latency to 1-10 ms but with some settings it can break smoothing, usually OffsetY 0 is enough) to being able to go to lowest latency.


###Prediction
How it works: It adds a predicted point to smoothing algoritm. It helps to preserve sharpness of movement, help with small movements.
Low values (~<10-15ms) of smoothing latency can cause problems for cursor movement. It's very preffered to use at least 10-15ms of smoothing latency, 20-40 ms is even better and recommended. In sum cursor can even outdistance real position (similar to Wacom 6.3.9w5 drivers).

Formula for prediction is:
y(x) = 1/cosh((x-OffsetX)\*Sharpness)\*Strength+OffsetY
Where **x** is pen speed. And **y(x)** is strength of prediction.
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_formula_example.png)
[Link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4PsH%401sH%400YM4X9tf2v79%40%40fv7Gxt7kFudgFb0G2dsEXkAPoAeRg/2CfRMNubMEQjMcDxuPB7v7WPgI=)

Strength, Sharpness, OffsetX and OffsetY is values which you can change in driver.

**Strength**: is max of peak of prediction. Useful values are from 0 to 2, or up to 3-4 depends of latency.

**Sharpness**: changes how wide will be Strength.

**OffsetX**: center of peak of prediction. Useful values are from 0.5 up to 5-7. Increase value to shift cursor speedup to bigger movements.

**OffsetY**: Moves the plot up/down (positiove/negative values). Also defines minimal amount of prediction.

Presets:
**Simple+**:
Staright or Smooth preset of smoothing +
Strength 1-3 (for 5-50 ms respectively), Sharpness 1, OffsetX 0.8, OffsetY 0
[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4PsH%402f7Rgzhf21/Y2v79%40%40fv7Gxt3kAge2CtyAHu%40AdyBn0AHKwu3%40wT6JhN7ZgCMbjAePxYHd/ax8D)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_simplesmooth.png)

**Straight+**:
Staright preset of smoothing +
Strength 0.3, Sharpness 0.7, OffsetX 2, OffsetY 0.3
[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0@A9YW1PuH@xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4PsH@2f7Rgzhf21/Y2v79@@fv7Gxt7kDOdgFH0AQu@ADyAX0AHKxu3@wT6JhN7ZgCMbjAePxYHd/ax8D)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_straight.png)

**Fun**:
Smoothing: Latency 40ms, Strength 3, Multiplier 10, OffsetX 1, OffsetY 1 +
Prediction: Strength 4, Sharpness 0.75, OffsetX 2.5, OffsetY 1
[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4I8bpDXlLuPRQyatwWlk/uOf8PFf8fdH5gPhtMcNLCG1trt/sH%402b8QQ/tf2t7Z///75Gxt7m1u74AMI4mwXfAHd2j/YJ9GwG1swBOPxgPF4sLu/tb%40xB93aXd%404AG9u7YK3DqBb%40wf7JBp2Y%40eU8Xi6xXjcurzY3d/aBwU=)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_fun.png)


![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/3.png)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/4.png)
![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/7.png)
Expand Down
14 changes: 14 additions & 0 deletions TabletDriverGUI/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ public enum OutputModes
public double SmoothingLatency;
public int SmoothingInterval;
public bool SmoothingEnabled;

public bool AntichatterEnabled;
public double AntichatterStrength;
public double AntichatterMultiplier;
public double AntichatterOffsetX;
public double AntichatterOffsetY;

public bool PredictionEnabled;
public double PredictionSharpness;
public double PredictionStrength;
public double PredictionOffsetX;
public double PredictionOffsetY;

public Area DesktopSize;
public bool AutomaticDesktopSize;

Expand Down Expand Up @@ -87,12 +94,19 @@ public Configuration()
SmoothingEnabled = false;
SmoothingLatency = 0;
SmoothingInterval = 4;

AntichatterEnabled = true;
AntichatterStrength = 3.0;
AntichatterMultiplier = 1.0;
AntichatterOffsetX = 0.0;
AntichatterOffsetY = 1.0;

PredictionEnabled = true;
PredictionSharpness = 1.0;
PredictionStrength = 1.1;
PredictionOffsetX = 3.0;
PredictionOffsetY = 0.3;

CommandsAfter = new string[] { "" };
CommandsBefore = new string[] { "" };

Expand Down
224 changes: 165 additions & 59 deletions TabletDriverGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TabletDriverGUI"
mc:Ignorable="d"
Title="TabletDriverGUI" Height="713" Width="686"
Title="TabletDriverGUI" Height="786" Width="686"
>
<Window.Resources>
<Style TargetType="GroupBox">
Expand Down Expand Up @@ -360,43 +360,46 @@

<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<Grid Width="166">

<!-- Filter Checkbox -->
<CheckBox x:Name="checkBoxSmoothing"
<StackPanel Orientation="Vertical">
<!-- Filter Checkbox -->
<CheckBox x:Name="checkBoxSmoothing"
VerticalAlignment="Top"
Checked="CheckboxChanged" Unchecked="CheckboxChanged" Content="Enabled" Width="62" Margin="50,7,54,0"/>

<!-- Filter Latency -->
<GroupBox Header="Latency" Height="50" Width="80" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textSmoothingLatency" Padding="4,0,0,0"
<StackPanel Orientation="Horizontal">
<!-- Filter Latency -->
<GroupBox Header="Latency" Height="50" Width="80" Margin="0,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textSmoothingLatency" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
<Label Width="30" HorizontalAlignment="Right">ms</Label>
</Grid>
</GroupBox>


<!-- Filter Rate -->
<GroupBox Header="Rate" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="85" Height="50">
<ComboBox x:Name="comboBoxSmoothingRate" SelectionChanged="ItemSelectionChanged" VerticalContentAlignment="Center">

<ComboBoxItem Content="1000 Hz"/>
<ComboBoxItem Content="500 Hz"/>
<ComboBoxItem Content="333 Hz"/>
<ComboBoxItem Selector.IsSelected="True" Content="250 Hz"/>
<ComboBoxItem Content="125 Hz"/>
</ComboBox>
</GroupBox>
<Label Width="30" HorizontalAlignment="Right">ms</Label>
</Grid>
</GroupBox>


<!-- Filter Rate -->
<GroupBox Header="Rate" VerticalAlignment="Top" HorizontalAlignment="Right" Width="85" Height="50">
<ComboBox x:Name="comboBoxSmoothingRate" SelectionChanged="ItemSelectionChanged" VerticalContentAlignment="Center">

<ComboBoxItem Content="1000 Hz"/>
<ComboBoxItem Content="500 Hz"/>
<ComboBoxItem Content="333 Hz"/>
<ComboBoxItem Selector.IsSelected="True" Content="250 Hz"/>
<ComboBoxItem Content="125 Hz"/>
</ComboBox>
</GroupBox>
</StackPanel>
</StackPanel>
</Grid>


<!-- Antichatter -->
<GroupBox Header="Antichatter" Margin="5,0,0,0" VerticalAlignment="Center">
<StackPanel Orientation="Vertical">
<!-- Antichatter -->
<GroupBox Header="Antichatter" Margin="5,0,0,0" VerticalAlignment="Center">

<GroupBox.ToolTip>
<StackPanel>
<TextBlock>
<GroupBox.ToolTip>
<StackPanel>
<TextBlock>
<TextBlock FontWeight="Bold">Please, visit https://github.com/Devocub/TabletDriver for images</TextBlock><LineBreak/>
<Run Text="Antichatter feature is meant to prevent cursor chattering/rattling/shaking/trembling when it's almost doesn't moves and/or too high to prevent tablet noise."/><LineBreak/>
<Run Text="Antichatter in it's primary form is useful for tablets which doesn't have any smoothing (including hardware smoothing)."/><LineBreak/>
Expand Down Expand Up @@ -442,55 +445,158 @@


</TextBlock>
</StackPanel>

</GroupBox.ToolTip>

<StackPanel Orientation="Horizontal" VerticalAlignment="Top">

<CheckBox x:Name="checkBoxAntichatter"
VerticalAlignment="Center" HorizontalAlignment="Left"
Checked="CheckboxChanged" Unchecked="CheckboxChanged" Content="Enabled"
IsEnabled="True" Width="62"
Margin="0,10,5,0"/>

<!-- Antichatter Strength -->
<GroupBox Header="Strength" Height="50" Width="70" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterStrength" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>

<!-- Antichatter Multiplier -->
<GroupBox Header="Multiplier" Height="50" Width="70" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterMultiplier" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>

<!-- Antichatter OffsetX -->
<GroupBox Header="OffsetX" Height="50" Width="60" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterOffsetX" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>

<!-- Antichatter OffsetY -->
<GroupBox Header="OffsetY" Height="50" Width="60" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterOffsetY" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>
</StackPanel>
</GroupBox>


<!-- Prediction -->
<GroupBox Header="Prediction" Margin="5,0,0,0" VerticalAlignment="Center">

<GroupBox.ToolTip>
<StackPanel>
<TextBlock>
<TextBlock FontWeight="Bold">Please, visit https://github.com/Devocub/TabletDriver for images</TextBlock><LineBreak/>
<Run Text="Prediction - How it works: It adds a predicted point to smoothing algoritm. It helps to preserve sharpness of movement, help with small movements."/><LineBreak/>
<Run Text="Low values (~10-15ms) of smoothing latency can cause problems for cursor movement. It's very preffered to use at least 10-15ms of smoothing latency, 20-40 ms is even better and recommended."/><LineBreak/>
<Run Text="In sum cursor can even outdistance real position (similar to Wacom 6.3.9w5 drivers)."/><LineBreak/><LineBreak/>

<Run Text="Formula for prediction is:"/>
<LineBreak/>
<Run Text="y(x) = 1/cosh((x-OffsetX)*Sharpness)*Strength+OffsetY "/>
<LineBreak/>
<Run Text="Where "/><TextBlock FontWeight="Bold">x</TextBlock><Run Text=" is pen speed. And "/><TextBlock FontWeight="Bold">y(x)</TextBlock><Run Text=" is strength of prediction"/><LineBreak/>
<TextBlock FontWeight="Bold">Please, visit https://github.com/Devocub/TabletDriver for images</TextBlock>
<LineBreak/><LineBreak/>

<TextBlock FontWeight="Bold">Strength</TextBlock>
<Run Text=": is max of peak of prediction. Useful values are from 0 to 2, or up to 3-4 depends of latency."/><LineBreak/>

</GroupBox.ToolTip>
<TextBlock FontWeight="Bold">Sharpness</TextBlock>
<Run Text=": changes how wide will be Strength."/><LineBreak/>

<TextBlock FontWeight="Bold">Offset X</TextBlock>
<Run Text=": center of peak of prediction. Useful values are from 0.5 up to 5-7. Increase value to shift cursor speedup to bigger movements."/><LineBreak/>

<TextBlock FontWeight="Bold">Offset Y</TextBlock>
<Run Text=": Moves the plot up/down (positiove/negative values). Also defines minimal amount of prediction."/><LineBreak/><LineBreak/>

<StackPanel Orientation="Horizontal" VerticalAlignment="Top">

<CheckBox x:Name="checkBoxAntichatter"
<TextBlock FontWeight="Bold">Presets</TextBlock><Run Text=":"/><LineBreak/>
<TextBlock FontWeight="Bold">Simple+</TextBlock><Run Text=":"/><LineBreak/>
<Run Text="Staright or Smooth preset of smoothing +"/><LineBreak/>
<Run Text="Strength 1-3 (for 5-50 ms respectively), Sharpness 1, OffsetX 0.8, OffsetY 0"/><LineBreak/>
<LineBreak/>

<TextBlock FontWeight="Bold">Straight+</TextBlock><Run Text=":"/><LineBreak/>
<Run Text="Staright preset of smoothing +"/><LineBreak/>
<Run Text="Strength 0.3, Sharpness 0.7, OffsetX 2, OffsetY 0.3"/><LineBreak/>
<LineBreak/>

<TextBlock FontWeight="Bold">Fun</TextBlock><Run Text=":"/><LineBreak/>
<Run Text="Smoothing: Latency 40ms, Strength 3, Multiplier 10, OffsetX 1, OffsetY 1 +"/><LineBreak/>
<Run Text="Prediction: Strength 4, Sharpness 0.75, OffsetX 2.5, OffsetY 1"/><LineBreak/><LineBreak/>

<TextBlock FontWeight="Bold">Please, visit https://github.com/Devocub/TabletDriver for images</TextBlock>


</TextBlock>
</StackPanel>

</GroupBox.ToolTip>

<StackPanel Orientation="Horizontal" VerticalAlignment="Top">

<CheckBox x:Name="checkBoxPrediction"
VerticalAlignment="Center" HorizontalAlignment="Left"
Checked="CheckboxChanged" Unchecked="CheckboxChanged" Content="Enabled"
IsEnabled="True" Width="62"
Margin="0,10,5,0"/>

<!-- Antichatter Strength -->
<GroupBox Header="Strength" Height="50" Width="70" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterStrength" Padding="4,0,0,0"
<!-- Prediction Strength -->
<GroupBox Header="Strength" Height="50" Width="70" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textPredictionStrength" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>
</Grid>
</GroupBox>

<!-- Antichatter Multiplier -->
<GroupBox Header="Multiplier" Height="50" Width="70" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterMultiplier" Padding="4,0,0,0"
<!-- Prediction Sharpness -->
<GroupBox Header="Sharpness" Height="50" Width="70" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textPredictionSharpness" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>
</Grid>
</GroupBox>

<!-- Antichatter OffsetX -->
<GroupBox Header="OffsetX" Height="50" Width="60" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterOffsetX" Padding="4,0,0,0"
<!-- Prediction OffsetX -->
<GroupBox Header="OffsetX" Height="50" Width="60" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textPredictionOffsetX" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>
</Grid>
</GroupBox>

<!-- Antichatter OffsetY -->
<GroupBox Header="OffsetY" Height="50" Width="60" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textAntichatterOffsetY" Padding="4,0,0,0"
<!-- Prediction OffsetY -->
<GroupBox Header="OffsetY" Height="50" Width="60" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Left">
<Grid>
<TextBox Name="textPredictionOffsetY" Padding="4,0,0,0"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
TextChanged="TextChanged">0</TextBox>
</Grid>
</GroupBox>
</StackPanel>
</GroupBox>
</Grid>
</GroupBox>
</StackPanel>
</GroupBox>
</StackPanel>

</StackPanel>

Expand Down
Loading

0 comments on commit 2310225

Please sign in to comment.