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
Graphics tablet input #403
Comments
Can it be treated like a joystick and use that API? It also seems similar to multitouch input, except that typically doesn't have extra degrees of freedom like pressure and tilt. |
Treating a stylus as a joystick would be odd to say the least. Stylus rotation support might also be something to consider (Wacom's art pens use it, for example), if that information is easily available. |
I know stylus's are usually treated as a mouse with an axis for pressure or angles. Having raw input from a graphics tablet would be highly useful (and would make this library much more beneficial to use than others). |
Since this isn't mentioned already, I would highly recommend looking at and considering Pointer Events that Microsoft has worked on and brought forward as a W3C recommendation for browsers. |
For future reference, I was able to get pressure readings working under Windows in a GLFW app by implementing the suggestions on this blog post: http://backworlds.com/under-pressure/ Note that the links to the code samples on that page are broken, and the correct link seems to be: I do not know if this is the best or most efficient method, just one that worked. |
has there been any work done for tablet support yet? and how is this related to the touch branch regarding touch events/gestures from touchpads. (If I understand PointerEvents correctly this would be a standard for both tablet-events (wacom) and touch-events (trackpads, surface, ipad) I have been looking through the examples by wacom to read out additional data from mouse events and it seems like an easy way to get out pressure (and maybe tilt) information from the events received in the mouseDown callback that is already implemented in However I am not sure about the complexity to get this working cross-platform. |
Has anyone work with GLFW and Wintab? I'm struggling the last few days to make it, but not Easytab or any library can't work with GLFW. Guys, need your help. For example Easytab needs Winapi's parameters like WPARAM, LPARAM, MESSAGE and another. How can I get it? HWND I get from glfwGetWin32Window(). |
I will check what is the status of APIs available to add this support on X11, Wayland and Windows. Gdk does provide events to check tablet inputs (pressure, tilt, rotation, and tablet buttons). What I'm not sure is the nature of the dependencies (on X11 seems to be just the extended input protocol, so not a big deal, but I'm not sure). Wayland has support for tablet input (seems to be recent). As for Windows, if Wintab is a requirement, what is the license (is it a third party or is it part of the win32 API)? If not, it would be simpler to just use the events. I have a tablet (wacom), so I can make and test some implementations. |
Windows is going to be interesting as I believe as of Windows 10 Anniversary, you're supposed to use the Ink API (or whatever it's called), whereas for previous versions of Windows you should use wintab (as apparently older versions of the Ink API suck). IIRC some newer graphics tablets don't even have wintab drivers? Fun. I actually tried my hand at a wintab implentation a couple years ago and got a partial implementation working. Unfortunately I developed it in a VM and no longer have that VHD. It would probably be a good idea to come up with an API design. I didn't bother with explicit support for the tablet itself, just the stylus; usually the tablet buttons are mapped to hotkeys anyway. Maybe mapping and absolute/relative coordinates settings could be exposed though? Some stylus-specific things that should be supported:
Would this need a separate stylus position callback (for backwards compatibility reasons)? A drawback to having a separate callback is that some people actually use the mouse that some tablets come with; does that use the stylus position callback or the cursor position callback? From the standpoint of the tablet, both of these are tablet input devices but the programmer would probably conceptually treat them as completely different things. Or a separate callback could be abandoned and the user would instead need to call the getters for pressure, tilt, etc. IMO it would be nice if GLFW 4 unified mouse, stylus, and maybe even touch under a single input API, with the concept of "pressed" and "unpressed" being generalized as pressure where the former is 1.0 and the latter 0.0, along with sane defaults for things like tilt that are currently only used by styluses. Especially if there are ever plans to support peripherals like the Surface Dial. |
Which raises the question: what about other tablets? I wonder if they are detectable by the Wacom API (maybe they were built to be). I'm trying to start the work on X11, but the lack of documentation is slowing me down. I found I think the tablet support should be enabled/disabled by a flag (disabled by default) at build time, because not all computers have the (dynamic) libraries installed.
I don't know how this would work with support for multiple mouse, though (#827). |
Since we talk about unified api, wouldn't be logical to handle multiple mouse the same way multi-touch is handled? |
Wintab's supposed to be the de-facto cross-vendor tablet API, but again the rift in tablet input APIs on Windows complicates things; realistically we'd want a variety of tablets to test with.
You should just be able to try loading the libraries, and if that fails then you don't get tablet input; I don't think this requires any compile-time handling. Also, unified input discussion should probably go into its own issue; that was just an aside. |
@elmindreda Support for pen/tablet can be added easily, but it will only be supported with Windows 8 and later, is that OK for you ? |
@eloraiby You mean |
For those interested, here is one way to get tablet pressure without modifying glfw's code for Windows and Linux. You will need glfw3native.h and easytab.h.
I'm not sure how to do the same for OSX without modifying cocoa_window.m (need to access [event pressure]). Also this code can only read the first event in the queue. |
@anael-seghezzi, @RajaLehtihet has already integrated the windows support: pull request. I think, she's waiting on @elmindreda to proceed with other platforms. |
@elmindreda is there a way to access all native events ? Because even with glfw3native I can only access the first event from the queue. If not what do you recommend would be the minimal code change I could do ? |
For reference: edit: |
Will this feature be supported in the future? Last comment is over a year old. |
I managed to get this working with easytab by peeking at a specific message range before the glfw event polling. First, after creating the GLFWwindow:
Then:
The positions are incorrect (scaled wrong and/or offset), though, so I still need to figure that out, but at least I'm getting input. |
@jitspoe |
Honestly, I completely forgot I even did this. I might have missed something. Here's my whole main function:
Maybe you're missing a call to wintab_loop();? |
@jitspoe |
Apparently it does nothing, so that wasn't relevant at all. Sorry, I thought it was part of one of the libraries.
|
Rats, I thought that seemed too easy. To better describe my problem: I can acquire one message at the start of the program: an EASYTAB_EVENT_NOT_HANDLED. If I PM_REMOVE, I only get the one instance of the message and then nothing, as if the message queue is not being replenished (?) (but I don't know why that would be). At this point I'm lost, so I'm just posting for others with a similar issue. |
You should try this pull request if you want good multi-platform tablet support in glfw: Or here as a fork (the pull request is not added yet to the official repo, so use at your own risk): |
It works! Thanks a ton - you're the MVP of GLFW art programs. Looking forward to incorporation into 3.4. |
Position, pressure, tilt and buttons.
The text was updated successfully, but these errors were encountered: