Switch to using touch state instead of most recent event #97
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.
This should fix a weird edge-case bug in the event handling code. (Thanks to
okeh
on the discord for finding this issue and helping me debug.)I've included the commit-message description below, but let me know if anything's not clear. (Or if you know what the "interesting behaviour" in the
ecodes::ABS_DISTANCE
handler is!)Previously, the wacom code would emit WacomEvent::Hover iff the last event seen was ToolPen. This has the wrong behaviour when the pen is leaving the screen, since a Touch event gets emitted as the pen lifts but another ToolPen won't be emitted until the pen is no longer near the screen at all. Instead, we use the current touch state to decide if we're hovering or
not.
So why wasn't this always broken? In the ABS_DIST code farther down in the file, it would update last_tool as part of some pressure / distance corrections I don't fully understand. When we hit this codepath, the resulting last_tool value seems to be correct. That code seems to reliably fire pretty often on my tablet, masking the bug, but it seems that it's not guaranteed to happen.
Anyways this is all a bit sketchy, and we should probably test on a couple devices before calling it good.