Skip to content
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

Switch to using touch state instead of most recent event #97

Merged
merged 2 commits into from
Apr 18, 2022
Merged

Conversation

bkirwi
Copy link
Collaborator

@bkirwi bkirwi commented Jan 30, 2022

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.

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 was emitted as the pen lifts but
another ToolPen won't be emitted until the pen is no longer near.
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 seems to be correct.  That code seems to reliably
fire on most tablets, but it seems that it's not guaranteed to happen.

Anyways this is all a bit sketchy, and we should test on a couple
devices before calling it good.
Copy link
Collaborator

@LinusCDE LinusCDE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding. Did a quick check with the input example on both models.

Seems to behave as expected. One thing of note is that the rM 1 doesn't emit any distance events anymore. I'm pretty sure it used to. And does so on the rM 2 and isn't related to these changes.

@bkirwi
Copy link
Collaborator Author

bkirwi commented Feb 9, 2022

Oh, that's interesting. Just to clarify... the RM1 doesn't get hover events either before or after this patch? (Wonder if it has something to do with the semi-recent evdev bump...)

@bkirwi
Copy link
Collaborator Author

bkirwi commented Apr 17, 2022

It sounds like this was good on your end, so I'm merging it in... but I'm happy to back it out if I got that wrong!

Additional fun fact: I was still a bit puzzled why the standard libremarkable demo wasn't drawing after lifting the pen, and it seems to be the case that - it actually was still "drawing," but because line thickness was based on the pressure and the pressure was zero, the line it was drawing had zero width.

@bkirwi bkirwi merged commit 573d4ac into master Apr 18, 2022
@fenollp fenollp deleted the wacom-fix branch April 18, 2022 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants