LinwoodDev / Butterfly

🎨 Powerful, minimalistic, cross-platform, opensource note-taking app
https://butterfly.linwood.dev
GNU Affero General Public License v3.0
891 stars 62 forks source link

[Enhancement]: Pressure Sensitivity: Add support for ONYX BOOX Series #650

Closed TekkertheChaot closed 3 months ago

TekkertheChaot commented 3 months ago

Which feature is your request related to?

Pressure Sensitivity

Describe your request for enhancements!

Hi! I want to setup Butterfly to finally have a syncronized drawing application! All works well so far, except that the pressure sensitivity of my stylus (BOOX Pen2 Pro) on my 'ONYX BOOX Tab Ultra' (E-Ink Tablet) doesn't seem to be recognized by Butterfly. I already checked that the pen input is interpreted as a propper pen input and not as touch / mouse. So I can only assume that either...

Onyx themselves have published the SDK here on GitHub altogether with a demo project.

Using the SDK, the eraser on the pen can be implemented and the pen-inputs can be INSANELY RESPONSIVE which, for a E-Ink tablet, is very nice! πŸ˜‰ I would also be happy to somehow get the pressure sensitivity working without the hassle of implementing the SDK, but on how to do this, I am too far outside of Android development.

What do you think?

Additional context

A screencap on the current behaviour: first half shows the BOOX Note integrated note taking app, second half shows Butterfly:

https://github.com/LinwoodDev/Butterfly/assets/17234581/ac83eef5-a806-4c2e-a499-5277d88a6e26

Code of Conduct

CodeDoctorDE commented 3 months ago

Android should already have a working pen pressure implementation. Can you try changing some values in the pen tool to have a bigger difference? If this doesn't help, I could try posting a demo version where you can look if the pressure detection works

TekkertheChaot commented 3 months ago

Damn, thank you for the fast reply! I just tried different pen settings on the pen-tool itself and in the behaviour settings. Both unfortunately have no effect regarding the pressure sensitivity .

A demo would be great! In the meantime, is there any way to export a log that I can provide to you?

CodeDoctorDE commented 3 months ago

Hmm there are no logging really for inputs... I will add a playground in the setting to test if the pointer kind and pressure can be tested

TekkertheChaot commented 3 months ago

I will add a playground in the setting to test if the pointer kind and pressure can be tested

That sounds great! Maybe to add to this, is it possible to poll which sort of "button ID" is currently pressed? I think it would be also cool to see, if the Android pen implementation can differentiate between the tip and the eraser of the pen.

Btw, this 'issue' has no priority on my end as everything else seems to work fine! So no rush πŸ˜‰

CodeDoctorDE commented 3 months ago

i added a pointer test in 2.1.0-beta.4, i will release the version next monday

TekkertheChaot commented 3 months ago

Insane how fast you've implemented it! Can't wait to test πŸ’ͺ

CodeDoctorDE commented 3 months ago

I have no exams or lectures in the next 2 weeks :D Time to code!

TekkertheChaot commented 3 months ago

Sooooo... I got a little curious and already tried the PWA preview as it already is updated with your commit. And (using chrome) on the tablet the pen does get recognized with pressure sensitivity within the playground! πŸ’ͺ So I assume the chances for the native app also being able to recognize the pen accurately are high, assuming that chrome doesn't use some own pen input implementation...

Still, the lines are all the same width on my end... I have screencapped my usage with all settings if you want to take a look. (Link to my Nextcloud, as the video is too large for GitHub; FYI: my NC is a bit slow while loading stuff just so you know)

But as I said, no rush and enjoy the holidays! Frohe Ostern! ✌️

CodeDoctorDE commented 3 months ago

So I assume the chances for the native app also being able to recognize the pen accurately are high, assuming that chrome doesn't use some own pen input implementation...

No not really, the opposite is the case. The pen input implementation is very different and on web very platform acnostic. On native platforms many things can break due to different hardware requirements. Can you try these pen tool values: image

(you need to scroll for some properties)

TekkertheChaot commented 3 months ago

Can you try these pen tool values

Just tried the values: The don't react on my end to pressure, only on stroke speed. :/

No not really, the opposite is the case. The pen input implementation is very different and on web very platform acnostic.

Ahh I was worried that would be the case. Alright...

I've got the feeling that I am missing something crucial. Maybe an idea to rule out user error on my end; in the beta app you mentioned, could you add a little "pressure meter" as a text value / progress bar to be visible on the canvas? The screencaps don't show the pen pressure so they may be misinterpreted. I really want to avoid hunting ghosts if its just something that I misunderstand. πŸ˜‰

CodeDoctorDE commented 3 months ago

Okay, butterfly 2.1.0-beta.4 is out! Can you test if this works natively on your end? Fdroid and Play store takes some days publishing it, just answer here after you tried it

TekkertheChaot commented 3 months ago

Alright, busy week over...

I was able to test the beta: https://github.com/LinwoodDev/Butterfly/assets/17234581/a9857f09-4ce2-4c9a-a62d-15c0f43fbde6

On the playground it seems, it can differentiate between 'touch', 'pen' and 'invert' which are touch, pen tip and pen eraser respectively. For 'pen' and 'invert' it is able to read out the pressure sensitivity just fine. In the screen recording I tried using the fountain pen mode but I also tried the normal one.

CodeDoctorDE commented 3 months ago

Fixed in 2.1.0-beta.5, please test it tomorrow and look if it works for you

TekkertheChaot commented 3 months ago

Nice! I was curious and tested the nightly PWA in Chrome on my BOOX and there it started recognizing the pressure on the canvas. πŸ’ͺ Looks promising for tomorrow's test!

CodeDoctorDE commented 3 months ago

Yeah, if you want to know the details: Previously it simulates the pressure always regardless of the input. Now it checks the values and only start simulating if every pressure value is 0. The fix should also change existing documents

TekkertheChaot commented 3 months ago

Oh, that makes sense. I peeked into your commit and came to a similar understanding, but wasn't completely sure. Also: nice way to apply it to preexisting docs

TekkertheChaot commented 3 months ago

It Works! πŸ’ͺ I dabbled a bit with the pen settings and now I feel comfortable enough to migrate my notes over to butterfly. Maybe I will get to work on a native OnyxPenSDK integration to further improve the experience for ONYX devices. πŸ˜‰

Thank you for the fix!

CodeDoctorDE commented 3 months ago

nice. feel free to join the matrix or discord server if you have any questions