Skip to content

Commit

Permalink
Add pressure filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed May 9, 2021
1 parent 23fcdf9 commit 3365936
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 9 deletions.
56 changes: 51 additions & 5 deletions Hover_Distance_Limiter/Hover_Distance_Limiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ public IDeviceReport Hover_Distance(IDeviceReport input)
}
}

public IDeviceReport Pressure_Cutoff(IDeviceReport input)
{
if (Pressure)
{
if (input is ITabletReport tabletReport)
{
if (tabletReport.Pressure >= Pressure_min && tabletReport.Pressure <= Pressure_max)
{
return input;
}
else
{
return null;
}
}
else
{
return input;
}
}
else
{
return input;
}
}

public event Action<IDeviceReport> Emit;

public void Consume(IDeviceReport value)
Expand All @@ -58,29 +84,49 @@ public void Consume(IDeviceReport value)
Emit?.Invoke(value);
}

public IDeviceReport Filter(IDeviceReport input) => Hover_Distance(input);
public IDeviceReport Filter(IDeviceReport input) => Hover_Distance(Pressure_Cutoff(input));

public PipelinePosition Position => PipelinePosition.PreTransform;

[Property("Minimum Hover Distance"), DefaultPropertyValue(0f), ToolTip
("Hover Distance Limiter:\n\n" +
"Minimum Hover Distance: The minimum HoverDistance where input is sent.\n" +
"(When Use ReportID Workaround is enabled, ReportID is used.)\n\n" +
"(HoverDistance and ReportID values can be found in the tablet debugger for supported tablets.)")]
"(HoverDistance and ReportID can be found in the tablet debugger for supported tablets.)")]
public float Hover_min { set; get; }

[Property("Maximum Hover Distance"), DefaultPropertyValue(63f), ToolTip
("Hover Distance Limiter:\n\n" +
"Maximum Hover Distance: The maximum HoverDistance where input is sent.\n" +
"(When Use ReportID Workaround is enabled, ReportID is used.)\n\n" +
"(HoverDistance and ReportID values can be found in the tablet debugger for supported tablets.)")]
"(HoverDistance and ReportID can be found in the tablet debugger for supported tablets.)")]
public float Hover_max { set; get; }

[BooleanProperty("Use ReportID Workaround", ""), ToolTip
("Hover Distance Limiter:\n\n" +
"Use ReportID Workaround: Uses ReportID to filter input instead of HoverDistance values.\n\n" +
"Use ReportID Workaround: Uses ReportID to filter input instead of HoverDistance.\n\n" +
"Many tablets do not send HoverDistance but will send general pen detection strength readings which can be used to limit hover distance.\n\n" +
"(ReportID values can be found in the tablet debugger)")]
"(ReportID can be found in the tablet debugger)")]
public bool ReportID { set; get; }

[BooleanProperty("Use Pressure Range Cutoff", ""), ToolTip
("Hover Distance Limiter:\n\n" +
"Use Pressure Range Cutoff: Uses Pressure to filter input along with either HoverDistance or ReportID.\n\n" +
"(Pressure can be found in the tablet debugger)")]
public bool Pressure { set; get; }

[Property("Minimum Pressure"), DefaultPropertyValue(0f), ToolTip
("Hover Distance Limiter:\n\n" +
"Minimum Pressure: The minimum Pressure where input is sent.\n\n" +
"(Only used when Use Pressure Range Cutoff is enabled.)\n" +
"(Pressure can be found in the tablet debugger.)")]
public float Pressure_min { set; get; }

[Property("Maximum Pressure"), DefaultPropertyValue(8192f), ToolTip
("Hover Distance Limiter:\n\n" +
"Maximum Pressure: The maximum Pressure where input is sent.\n\n" +
"(Only used when Use Pressure Range Cutoff is enabled.)\n" +
"(Pressure can be found in the tablet debugger.)")]
public float Pressure_max { set; get; }
}
}
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ Limits minimum and maximum hover distance.

**Maximum Hover Distance:** The maximum `HoverDistance` where input is sent. (When **Use ReportID Workaround** is enabled, ReportID is used.)

**Use ReportID Workaround:** Uses `ReportID` to filter input instead of `HoverDistance` values. Many tablets do not send `HoverDistance` but will send general pen detection strength readings which can be used to limit hover distance.
**Use ReportID Workaround:** Uses `ReportID` to filter input instead of `HoverDistance`. Many tablets do not send `HoverDistance` but will send general pen detection strength readings which can be used to limit hover distance.

**Use Pressure Range Cutoff:** Uses `Pressure` to filter input along with either `HoverDistance` or `ReportID`.

**Minimum Pressure:** The minimum `Pressure` where input is sent. (Only used when **Use Pressure Range Cutoff** is enabled.)

**Maximum Pressure:** The Maximum `Pressure` where input is sent. (Only used when **Use Pressure Range Cutoff** is enabled.)

<br>

## How to find HoverDistance or ReportID:
## How to find HoverDistance, ReportID or Pressure:
- Open tablet debugger by going to `Tablets > Tablet debugger...`
- Put your pen within detection range of your tablet
- The `Tablet Report` box will show `HoverDistance` or `ReportID` which is the raw value for each.
- The `Tablet Report` box will show `HoverDistance`, `ReportID` and `Pressure` which is the raw value for each.

(If a `HoverDistance` is not shown, your tablet is not compatible with the default filtering method. Enabling **Use ReportID Workaround** and using `ReportID` values can be used on some tablets which do not send `HoverDistance`.)
(If a `HoverDistance` is not shown, your tablet is not compatible with the default filtering method. Enabling **Use ReportID Workaround** and using `ReportID` can be used on some tablets which do not send `HoverDistance`.)

0 comments on commit 3365936

Please sign in to comment.