fltk / fltk

FLTK - Fast Light Tool Kit - https://github.com/fltk/fltk - cross platform GUI development
https://www.fltk.org
Other
1.67k stars 272 forks source link

Suggestion: Please add ability to use tablet features like pen pressure sensitivity, tilt, and other stuff. #208

Open ghost opened 3 years ago

ghost commented 3 years ago

I want to use FLTK, but I truly need ability to use tablet features such as pen pressure sensitivity and other stuff related to the tablet. How difficult would it be to implement it into FLTK?

By tablet I mean my drawing tablet like a wacom tablet.

fire-eggs commented 3 years ago

You don't tell us what platform(s) you wish to target. Drivers for tablets are platform and sometimes manufacturer specific. A fair amount of work is necessary to handle devices in a cross-platform fashion. [Someone more knowledgeable than I might know of a "standard" interface for tablets and similar devices.]

For instance, if you were targeting Wacom compatible tablets on Linux, you could install or use the Wacom driver and write your code to use the tablet, following the test programs in that repo.

erco77 commented 3 years ago

Yes, we should add this, but no one's been able to come up with this cross platform as yet.

Back in 2016 I proposed a Mac specific patch in STR#3329 to support pen movement + pressure/tilt that worked for me on a Cintiq (Wacom monitor/tablet combo used for drawing), see:

[1] https://www.fltk.org/newsgroups.php?gfltk.general+v:40003 [2] https://www.fltk.org/str.php?L3329

But that's as far as I got. Which is to say it worked for my app, but I don't think in this state it's ready for implementation into an FLTK release just yet; a proper API needs to be conceived.

I was not sure what the proper API should be, and sought input, but since none was offered, the STR has languished.

Could be revived though, we just need a way that (a) works for cross platform, (b) does not impact performance on non-tablet devices (since this causes a lot of excess event traffic, or at least in my case it certainly did), or at least provides a way to turn these events on and off easily.

fire-eggs commented 3 years ago

I was going to point out that Gimp supports tablets [via GTK+], but then I read that their tablet support is broken on Windows and Mac.

erco77 commented 3 years ago

Inkscape might be a good reference for an app that uses e.g. pen pressure. I use Gimp on a mac with the Wacom Cintiq and it works fine. If it's broken, I'm not aware of it.

But we already have an example of Mac <-> FLTK <-> Cintiq in STR#3329. What's needed is Win and Linux. I'm pretty sure Linux probably uses the same stuff SGI did back in the day, as X input extensions, IIRC.

I wrote some pure X windows/OpenGL code very long ago (1998) on an SGI using X input extensions to read pen pressure and tilt from a Wacom Artz tablet, code for that is here: http://seriss.com/people/erco/wacom/

Since Linux inherited a lot from SGI regarding X and graphics, I wouldn't be surprised if the same/similar techniques still work 23 years later, lol. It's just never been dragged into FLTK because at the time the specs were still in a state of formation. I think Matthias took that code and tried to integrate it into FLTK, maybe FLTK2.

Perhaps we should first look to FLTK2 to see if this has already been done. I think most of the current FLTK 1.x devs are completely unaware of what's in FLTK2.

MatthiasWM commented 3 years ago

In one of the fading corners of my brain I remember implementing this for fltk2 for Nuke (about 25 years ago). Not sure if it ever made it into the public branch.

Basically I added Fl::eventdevice() to differentiate mouse, pen, eraser, and touch. I had Fl::event*() functions for pressure, angle_x, and angle_y. Also, pens have additional buttons. I did use some of Erco's Waco. code, but I assume that these days we have actual system APIs available.

In private branches I had support for Spaceball and Spacemouse.

pydsigner commented 11 months ago

A number of searches about tablet input were leading me towards Qt, so I took a look at what platform-specific APIs they rely on. What I found is evdev on Linux, Wintab (Wacom only) on Windows, and NSEvent on macOS. Interestingly, Wacom lists some alternatives to Wintab for non-Windows platforms, including the NSEvent approach for macOS and Wayland Tablet Protocol/XInput2 for Linux.

MatthiasWM commented 10 months ago

The API and ABI for this and the touch interface will be in 1.4.0 so we can add the implementation for the remaining platforms in 1.4.1

Albrecht-S commented 9 months ago

@MatthiasWM I'm no longer keen on adding anything related to touch and/or tablet events in 1.4.0 because we can't have a clear specification of events etc. before we implement them.

My take on this is (meanwhile) that we should wait until the release is done and then - after keeping the master branch in 1.4.x for some weeks for potential bug fixes - create the maintenance branch branch-1.4 (like branch-1.3 is now) and concentrate on 1.5.0 in the master (development) branch. That would be the time to implement new ABI breaking features like touch events.

What do you think? Do you agree to go this way?

Albrecht-S commented 9 months ago

Removed from the release milestone. We're getting closer...