-
-
Notifications
You must be signed in to change notification settings - Fork 30
fix: 修复上下红外框触摸屏手掌擦橡皮过大的问题 #636
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
Open
fplj-fplj
wants to merge
1
commit into
InkCanvasForClass:net10
Choose a base branch
from
fplj-fplj:fix/palm-eraser-top-bottom-ir
base: net10
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| using System; | ||
|
|
||
| namespace Ink_Canvas.Ink | ||
| { | ||
| /// <summary> | ||
| /// 手掌擦接触尺寸计算。 | ||
| /// 上下红外等触摸框可能把接触矩形某一轴异常放大(例如接近全屏宽度的长条), | ||
| /// 这里把异常细长接触折算为几何平均宽度,并限制最终手掌橡皮大小。 | ||
| /// </summary> | ||
| internal static class PalmEraserGeometry | ||
| { | ||
| /// <summary> | ||
| /// 手掌橡皮最大宽度(DIP)。用于防止上下红外等设备上报的异常接触矩形 | ||
| /// 把橡皮放大到远超真实手掌的程度。 | ||
| /// </summary> | ||
| internal const double MaxPalmEraserWidthDip = 200; | ||
|
|
||
| /// <summary> | ||
| /// 接触矩形长宽比超过该值时,认为某一轴可能是红外框的异常放大结果, | ||
| /// 改用几何平均 sqrt(width*height) 来估算有效接触宽度。 | ||
| /// </summary> | ||
| private const double ElongatedAspectRatioThreshold = 3.0; | ||
|
|
||
| internal static double GetEffectiveContactWidthDip( | ||
| double contactWidthDip, | ||
| double contactHeightDip, | ||
| bool isQuadIr) | ||
| { | ||
| if (contactWidthDip <= 0) | ||
| return 0; | ||
|
|
||
| // 部分设备不提供高度,仍回退到宽度,避免破坏原有行为。 | ||
| if (contactHeightDip <= 0) | ||
| return contactWidthDip; | ||
|
|
||
| var min = Math.Min(contactWidthDip, contactHeightDip); | ||
| var max = Math.Max(contactWidthDip, contactHeightDip); | ||
| var elongated = min <= 0 || max / min > ElongatedAspectRatioThreshold; | ||
|
|
||
| if (isQuadIr || elongated) | ||
| return Math.Sqrt(Math.Max(0, contactWidthDip * contactHeightDip)); | ||
|
|
||
| return contactWidthDip; | ||
| } | ||
|
|
||
| internal static double ApplyPalmEraserSize( | ||
| double effectiveContactWidthDip, | ||
| double eraserSizeFactor, | ||
| bool isSpecialScreen, | ||
| double touchMultiplier) | ||
| { | ||
| var widthDip = effectiveContactWidthDip * eraserSizeFactor; | ||
| if (isSpecialScreen) | ||
| widthDip *= touchMultiplier; | ||
|
|
||
| return Math.Min(widthDip, MaxPalmEraserWidthDip); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
Ink Canvas/Ink/PalmEraserGeometry.cs:37, this early return also applies whenisQuadIris true, changing the previous quad-IR result for a zero-height contact from0to the raw width. A quad-IR frame with a screen-wide width and a missing/degenerate height can therefore activate an oversized palm eraser again rather than being rejected by the existing threshold checks.Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.