Skip to content

API for pressure-sensitive pens + XInput2 & Wayland implementations #5481

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

Closed
wants to merge 1 commit into from

Conversation

creichen
Copy link
Contributor

@creichen creichen commented Apr 1, 2022

This pull request adds support for pressure-sensitive pens to SDL. It is intended to maintain backward compatibility, and adds new events to provide more detailed information for pen movement.

(Last updated 2022-06-17)

Description

This pull request adds support for pressure-sensitive pens to SDL:

  • Extensions to the event API:
    • two new event types (PenMotion, PenButton)
    • float- typed x, y positions
    • reports on pressure, tilt, and other pen axes
    • discriminate "pen" and "eraser" events, different pen IDs (if tracked by device-- probably Wacom-only for now)
  • API for querying pens SDL_pen.h)
  • Implementation for XInput2, incl. hotplugging support
  • Implementation for Wayland, incl. hotplugging support
  • Automatic test suite (testautomation_pen.c)
  • Demo program (testpen)
  • Hints to guide pen-as-mouse emulation:
    • SDL_HINT_PEN_NOT_MOUSE allows either entirely suppressing mouse events for pen events, or sending pen movement/button updates without moving the mouse position.
    • SDL_HINT_PEN_DELAY_MOUSE_BUTTON (default) reports mouse button presses when the pen touches/leaves the tablet, with the mouse button determined by which pen button is pressed when the pen first touches the surface. If disabled, pen buttons translate to mouse buttons even if the pen is just hovering, and the pen tip acts as left mouse button.
  • [NEW] Support for multi-tablet setups is only experimental for this PR. In particular, pen GUIDs may change in the future if needed to improve cross-tablet tracking.

Design Rationale

Abstractly speaking, Pens are similar to mice, except that they provide additional information (pressure, tilt). In practice, they are particularly useful for writing / drawing, for which it is valuable to have sub-pixel position resolution.

To adapt to SDL conventions, the API reports normalised data:

  • pressure: 0.0f .. 1.0f
  • tilt: -1.0f .. 1.0f (0.0f as centre), reporting the tilt vector (rather than the tilt angle, as Wayland does)
  • rotation: -1.0f .. 1.0f (0.0f as centre), representing barrel rotation. Multiply with 180 for degrees or pi to get radians.
  • distance: 0.0f .. 1.0f
  • slider: -1.0f .. 1.0f (0.0f as centre) or 0.0f .. 1.0f (untested)
  • PenMotion with pressure greater than 0 has button 1 pressed, which simulates current MouseMotion behaviour
  • Mouse events report which as SDL_PEN_MOUSEID (analogously to SDL_TOUCH_MOUSEID)

Design alternatives:

  • Extending MouseMotion and MouseButton instead of introducing new events
    • Pro: Fewer event types
    • Con: Would add six fields to this event or require changing type of x, y fields
    • Con: Would spam programs that don't care about pens with sub-pixel position / pressure / tilt updates
  • Using the joystick API
    • Pro: Joysticks have a notion of multiple axes
    • Con: Unclear where screen positions should go (Joysticks / gamepads have no screen position)
  • Open-ended list of axes:
    • Pro: More flexible
    • Con: Harder to use in the common case; the current ones seem standard, though. If needed, the API might allow axis index remapping in the future.
  • Represent pens differently than by SDL_PenID:
    • Option: SDL_PenGUID: unique across sessions, but more data to pass around, can't print / compare / hash as easily
    • Option: pen index, starting at 0: complicates enumerating active pens (client must always check if disabled), event handler must track extra state to recover index
    • Option: pointer to opqaue SDL_Pen*: largely the same as SDL_PenID, but requires clients to go through extra steps when making pen API calls during event processing, unless we pass pointers in event structures.

Backward Compatibility

Pens still report mouse events via which = SDL_PEN_MOUSEID. They should thus work the same as before
to clients who are unaware of pen events.

[EDIT]: Updates. Next Steps, and Limitations (updates summarised here)

Changelog

  • DONE: cmake support not yet adpated (was already working in first commit...)
  • DONE: Extend testmouse for mouse wheels in preparation for the next item (-> Add visualisation for mouse wheel testing to test/testmouse #5486 )
  • DONE: XInput2: Doesn't currently filter out duplicate X11 Motion/ButtonPress/ButtonRelease events
  • DONE: Not currently filtering out duplicate MouseMotion events caused by pens
  • DONE: Hot-plugging
  • DONE: General-purpose pen API, make events more easily extensible with more/flexible axes
  • DONE: Test program runs in a tight loop
  • DONE: XInput2: Implementation is currently limited to 4 pen and/or eraser devices
  • DONE: Stop pen movement from updating default pointer position, toggled via SDL_HINT_PEN_NOT_MOUSE
  • 2022-04-28: DONE: Additional axes: courtesy of detailed information from @Pinglinux at Wacom, the code might now work with (and auto-detect) most if not all Wacom pens
  • 2022-04-28: Automated unit tests: inspired by Install tests, and run a subset non-interactively #5525 , the API is now tested against mock pen backends
  • 2022-04-28: Backend API is now more incrementalised, to better support Wayland-style "push" updates
  • 2022-05-01: Wayland implementation
  • 2022-05-02: Wayland pen behaviour now global default, added SDL_HINT_PEN_DELAY_MOUSE_BUTTON to toggle
  • 2022-05-28: Wayland fixes for button and axis reporting when libinput doesn't provide updates for everything.
  • 2022-06-04: Wacom Art Pen rotation fixes
  • 2022-06-04: Fix: Track button releases / lifting up the pen when the pen leaves the window
  • 2022-06-04: Pen hot-swapping on X11 now correctly tracks older pens (Wayland worked fine)
  • 2022-06-04: Pen identification now prefers the more detailed Wacom names on X11, if available
  • 2022-06-04: Fixed a bug that would erroneously identify some Wacom pens as unsupported/older on Linux (more precisely: fixed a bug in a workaround for a known platform-specific difference in pen device types on Linux)

No plans to fix in this PR:

  • XInput2: Eraser detection currently uses Wacom-specific information and otherwise checks for the device name, to see if it contains the string "eraser".
    • Technique adapted (and extended, for Wacom) from GDK
  • Pens and erasers aren't currently connected in the API (treated as separate devices or as one device that changes its type).
  • [EDIT] Pen pressure threshold for button 1 is 0, would be nice to default to higher value / configure via SDL hint
  • Windows support: API documentation seems to be here. I can't personally test this and don't currently plan on working on it.
  • OS X support: Wacom have a description of how they hook into the cocoa event system and I have no idea about other tablet providers (though I suspect Apple at least will report events similarly to Wacom for iOS devices, seeing how there is some overlap with what Wacom describe). Otherwise same situation as Windows support.
  • [NEW] Multi-tablet setups may work (as suggested by current testing) but isn't official yet.
  • [NEW] No support for reporting on tablet devices (including which screen areas are mapped to which tablet), physical on-tablet buttons or paired devices ("Wacom ExpressKey").

Missing testing

Below are scenarios that are difficult for me to test:

  • Touch input unchanged?
  • Non-X11/Wayland systems unchanged?
  • X11 systems without XInput2 support unchanged?
  • Pens with wheels, three buttons?

Existing Issue(s)

Acknowledgements and Thanks

  • Wacom generously donated an Art Pen to help with testing
  • @Pinglinux provided substantial and detailed help on how Wacom devices work on Linux and in XInput2, and some the information from his libwacom is now (in compressed form) part of the pull request.
  • @whot for technical advice on Wayland and X11 integration and libinput testing
  • @sp1ritCS testing and detailed feedback, esp. wrt Wayland
  • @sanette for testing Huion hardware and reporting bugs
  • @sezero for uncannily quick turnaround on portability and SDLishness fixes
  • @remjey for bug fixes for older and non-Wacom tablets, including XP-PEN

@creichen creichen changed the title API for pressure-sensitive pens + XInput2 implementation [WIP] API for pressure-sensitive pens + XInput2 implementation Apr 1, 2022
@flibitijibibo
Copy link
Collaborator

For the Wayland side, see #5344. The protocol is in place for the bare minimum support, just needs to be fully implemented.

@sezero
Copy link
Contributor

sezero commented Apr 1, 2022

Got the following build errors on an old setup:

src/video/x11/SDL_x11pen.c: In function ‘X11_InitPen’:
src/video/x11/SDL_x11pen.c:65: error: ‘bool’ undeclared (first use in this function)
src/video/x11/SDL_x11pen.c:65: error: (Each undeclared identifier is reported only once
src/video/x11/SDL_x11pen.c:65: error: for each function it appears in.)
src/video/x11/SDL_x11pen.c:65: error: expected ‘;’ before ‘is_pen_or_eraser’
src/video/x11/SDL_x11pen.c:66: error: ISO C90 forbids mixed declarations and code
src/video/x11/SDL_x11pen.c:86: error: ‘is_pen_or_eraser’ undeclared (first use in this function)

src/video/x11/SDL_x11xinput2.c: In function ‘X11_HandleXinput2Event’:
src/video/x11/SDL_x11xinput2.c:230: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pressed’
src/video/x11/SDL_x11xinput2.c:230: error: ‘pressed’ undeclared (first use in this function)
src/video/x11/SDL_x11xinput2.c:230: error: (Each undeclared identifier is reported only once
src/video/x11/SDL_x11xinput2.c:230: error: for each function it appears in.)

Easily fixed by:

diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c
index f95e647..5a95804 100644
--- a/src/video/x11/SDL_x11pen.c
+++ b/src/video/x11/SDL_x11pen.c
@@ -64,3 +64,3 @@ X11_InitPen(_THIS)
         /* Check for pen or eraser and set properties suitably */
-        bool is_pen_or_eraser = False;
+        SDL_bool is_pen_or_eraser = SDL_FALSE;
         struct SDL_X11Pen pen_device;
@@ -85,3 +85,3 @@ X11_InitPen(_THIS)
                     /* pressure-sensitive is the sole requirement for being pen or eraser */
-                    is_pen_or_eraser = True;
+                    is_pen_or_eraser = SDL_TRUE;
 
diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c
index b402270..a5c3127 100644
--- a/src/video/x11/SDL_x11xinput2.c
+++ b/src/video/x11/SDL_x11xinput2.c
@@ -229,3 +229,3 @@ X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
             const int button = xev->detail;
-            const bool pressed = cookie->evtype == XI_ButtonPress;
+            const SDL_bool pressed = (cookie->evtype == XI_ButtonPress) ? SDL_TRUE : SDL_FALSE;
 

Additional note: your changes to configury, if any, are not understandable from the patchset.
If there are any changes to configury/build system, please include your changes to configure.ac
and CMakeLists.txt - the generated files can be done later here.

@creichen
Copy link
Contributor Author

creichen commented Apr 1, 2022

@sezero : Thank you! Tried out and pushed your patch.

Can you elaborate on the configuration changes, please? I already pushed the (minor) CMakeLists.txt and Makefile.in bits, but I can revert the configure scripts back to main, e.g. if that helps with reviewing or automated checks (though at the cost of breaking the direct build [EDIT] correction: the build was not affected)?

I had changes to configure.ac in earlier commits but reverted them after finding a simpler solution. I can squash the commits and submit a fresh pull-request instead of this one, if that helps?

@sezero
Copy link
Contributor

sezero commented Apr 1, 2022

Yes: if there are no changes to configure.ac, please revert changes to generated configure.
Yes: Squashing into a single commit and force-pushing into this PR would make reviewing easier.

Thanks.

@creichen creichen force-pushed the pen-api branch 2 times, most recently from c7b69ed to dc30f5d Compare April 1, 2022 21:10
@sp1ritCS
Copy link
Contributor

sp1ritCS commented Apr 2, 2022

[EDIT] Could help fix mouse clicks reported for pen position issue from #5344 if still open

its still affected, but this PR doesn't currently do the tablet api for wayland. You can take inspiration from 9125b24 which does (as @flibitijibibo said) some basic functionality that tablets can act as mice input devices.

@creichen
Copy link
Contributor Author

creichen commented Apr 4, 2022

Quick process question: since some of the next steps will conflict with #5382 (which seems to be pretty much accepted), should I merge #5382 into this PR before continuing?

@slouken
Copy link
Collaborator

slouken commented Apr 5, 2022

Quick process question: since some of the next steps will conflict with #5382 (which seems to be pretty much accepted), should I merge #5382 into this PR before continuing?

No, let's keep this separate for now.

@creichen
Copy link
Contributor Author

I merged against main to keep up to date, but this adds a lot of commits to this PR. Do you prefer that I rebase against main and force-push either the entire PR or the delta relative to the previous review?
(Sorry about the process questions, but I'm not familiar with this workflow. Any process description I can read up on?)

@sezero
Copy link
Contributor

sezero commented Apr 10, 2022

I merged against main to keep up to date, but this adds a lot of commits to this PR. Do you prefer that I rebase against main and force-push either the entire PR or the delta relative to the previous review? (Sorry about the process questions, but I'm not familiar with this workflow. Any process description I can read up on?)

Speaking for myself, I'd prefer a rebase against main + force-push.

@creichen
Copy link
Contributor Author

I started on some testautomation tests but can't seem to find a clean way to expose internal APIs, which I would need to simulate pen attachment / removal.
Is there some clever mechanism available for this (e.g., a mock event subsystem or a general-purpose exported API function for exposing function pointers to suitably registered internal operations)?

@creichen
Copy link
Contributor Author

All squashed into a single commit, as per @sezero 's preference.

I hope that the most recent changes also address the XWayland issue that @sp1ritCS ran into. I've kept the most recent history at https://github.com/creichen/SDL/tree/pen-api-history for those who want to check today's changes.

Marking "Ready for review" now. If there is a good solution for the testautomation issue I mentioned, I will push tests later.

@creichen creichen marked this pull request as ready for review April 10, 2022 19:08
@creichen creichen changed the title [WIP] API for pressure-sensitive pens + XInput2 implementation API for pressure-sensitive pens + XInput2 implementation Apr 10, 2022
@flibitijibibo
Copy link
Collaborator

Will let the others review the X side, but for an API like this it seems like a good idea to take a page from Khronos' book and require a second implementation before we lock this down. I'm biased and would like to see Wayland support but I know pen/tablet events are something that pop up in the existing Windows video backend as well.

@sezero
Copy link
Contributor

sezero commented Apr 10, 2022

For most compatibility with many compilers, testpen.c can lose C99'isms

--- testpen.c~
+++ testpen.c
@@ -46,7 +46,8 @@ DrawScreen(SDL_Renderer *renderer)
     if (last_was_eraser) {
-        SDL_Rect rect = {
-            .x = last_x - 10,
-            .y = last_y - 10,
-            .w = 21,
-            .h = 21 };
+        SDL_Rect rect;
+
+        rect.x = last_x - 10;
+        rect.y = last_y - 10;
+        rect.w = 21;
+        rect.h = 21;
 
@@ -128,3 +129,2 @@ dump_state()
 
-
         guid2.data[15] = 0;
@@ -156,6 +156,4 @@ process_event(SDL_Event event)
 #if VERBOSE
-	int x, y;
-
+    {   int x, y;
 	SDL_GetMouseState(&x, &y);
-
 	if (event.type == SDL_MOUSEMOTION) {
@@ -172,3 +170,3 @@ process_event(SDL_Event event)
 	}
-
+    }
 #endif
--- test/Makefile.os2~
+++ test/Makefile.os2
@@ -25,3 +25,3 @@
           testviewport.exe testwm2.exe torturethread.exe checkkeys.exe &
-          checkkeysthreads.exe testmouse.exe &
+          checkkeysthreads.exe testmouse.exe testpen.exe &
           controllermap.exe testhaptic.exe testqsort.exe testresample.exe &

@sp1ritCS
Copy link
Contributor

I hope that the most recent changes also address the XWayland issue that @sp1ritCS ran into.

it did.

it seems like a good idea to take a page from Khronos' book and require a second implementation before we lock this down. I'm biased and would like to see Wayland support

seconded, alternatively I'd biased towards an libinput/evdev implantation around the compositor for lower latency (assuming the user has permission to read the device)

@creichen
Copy link
Contributor Author

creichen commented Apr 11, 2022

Thank you! Merged @sezero's patch.

Let me know if you'd prefer that I split out SDL_pen.h into a later, separate PR; I assume that's the more contentious bit?

Pen event reporting should work fine without it (with a couple of #defines and moved to SDL_event.h and typedefs removed or flattened). The internal event reporting API in SDL_pen_c.h is all that the alternative implementations would see anyway, so SDL_event.h shouldn't matter to them for purposes of exploring portability. (This is also a counter-argument for what I proposed, but either way I can put the option on the table.)

I'm not currently planning to add more features to this PR, unless I get my hands on new pen input hardware or find time to set up Wayland (unlikely for at least a couple of weeks).
([EDIT] To avoid confusion: I will of course happily maintain this PR, including merging new features. I consider it feature complete for the environment that I have in front of me / can work and test with at the moment, though.)

@flibitijibibo
Copy link
Collaborator

No worries on the timeline - I believe we're in the middle of a freeze since 2.0.22 is coming up, so it'll be a while before we start working on new features again.

@sezero sezero mentioned this pull request Apr 11, 2022
@slouken
Copy link
Collaborator

slouken commented Sep 10, 2022

Let's get an initial Windows implementation in as well.

@creichen
Copy link
Contributor Author

@slouken, are you referring to you wanting to merge in @PJB3005's PR creichen#1 ? That one is promising but still WIP, as far as I know.

@slouken
Copy link
Collaborator

slouken commented Sep 14, 2022

@PJB3005, I'd like to include your implementation in this PR. Can you finish it up and add it here?

@PJB3005
Copy link
Contributor

PJB3005 commented Oct 21, 2022

Yeah I should get off my butt and finish this PR. Guess I'll look into it tonight/

@slouken slouken modified the milestones: 2.26.0, 3.0 Oct 21, 2022
@sezero
Copy link
Contributor

sezero commented Oct 29, 2022

@PJB3005, I'd like to include your implementation in this PR. Can you finish it up and add it here?

@slouken: it doesn't look like this will happen soon. May I suggest merging this as is, and windows and others may follow later on top of it?

@slouken
Copy link
Collaborator

slouken commented Oct 29, 2022

This isn't going in until SDL3, so we have some time.

@sezero
Copy link
Contributor

sezero commented Oct 29, 2022

This isn't going in until SDL3, so we have some time.

Ah, didn't notice the milestone change. (Pity though.)

@PJB3005
Copy link
Contributor

PJB3005 commented Nov 10, 2022

"Alright time to get off my butt and get the Windows side over the finish line this weeke-"

This isn't going in until SDL3, so we have some time.

oh god should I feel guilty about this

@slouken
Copy link
Collaborator

slouken commented Nov 11, 2022

No, just finish it and we'll merge it, if you're done before SDL4 😆

@whot
Copy link

whot commented Nov 16, 2022

apologies for the delay, I was on a long leave away from the computer.

XI2: check pen/window association on every movement/button event, to work around XI2 not reporting "Enter" events when a Wacom stylus with eraser is flipped around without leaving the window (not sure if this is new behaviour).

Enter events in X are tied to the cursor, so unless the cursor moves out of the window you won't get a leave event. In XI 1.x there was the ProximityIn/Out event to track the state but it didn't make it into XI2 (for rather embarrassing reasons). So yeah, you really can't track this :(

@creichen
Copy link
Contributor Author

@PJB3005 No worries from my side! :-) I will be too busy with work to merge/re-validate until mid-December anyway (and have been for a bit).

@slouken slouken modified the milestones: 3.x, 3.2.0 Nov 23, 2022
@slouken
Copy link
Collaborator

slouken commented Jan 10, 2023

@PJB3005, any update on this?

@PJB3005
Copy link
Contributor

PJB3005 commented Jan 28, 2023

Alright I'm finally gonna try to push this over now. Working on rebasing my first commit on top of the new branch and then seeing what issues I still had to fix.

I think I'm probably gonna give up on the idea of getting Wacom GUIDs and distance values for now. In the future we could probably make a switchable wintab backend if those are deemed important enough.

@PJB3005
Copy link
Contributor

PJB3005 commented Jan 29, 2023

Currently hammering away at the flickering cursor problem in the test app. Sporadic mouse events erroneously sent into the app due to bugs cause this, as the test app re-shows the cursor on mouse events.

The first issue I ran into with that was easy enough. Apparently pen input also fires WM_TOUCH (from Windows 7) so I had to ignore them if they were pen (easy).

The second problem however is a "god damn, Windows is just broken" scenario. There appear to just be bogus WM_MOUSEMOVE messages fired that I can't see any practical way to filter. When you move the pointer over the edge of the window, it sends a single WM_MOUSEMOVE (the rest is all WM_POINTERUPDATE like expected) with the edge coordinates. This isn't too big a deal on its own. But after this happens the first time, any time you create a button event, Windows seems to re-fire this same buggy WM_MOUSEMOVE message! It doesn't even change the coordinates in any way based on the actual cursor.

There also appears to be some sort of internal SDL2 bug where it keeps re-setting the cursor. This happens to me during testing: I have a button rigged to turn off the ShowCursor(SDL_ENABLE) logic but after turning it on and off (doesn't happen initially), SDL still seems to be messing with the cursor internally on various events. Might be related to mouse capture or something.

@Svintaj
Copy link

Svintaj commented Jan 30, 2023

@PJB3005, if you are trying to grab the edge of the window to resize it on Windows, then it's most likely related to this issue: #1059 (comment)

@creichen
Copy link
Contributor Author

@PJB3005 Would it help you if I were to re-base the current patch onto the most recent SDL?

As for messing with the cursor:
The pen API treats pens as mice by default, unless SDL_HINT_PEN_NOT_MOUSE is set to 1 or 2 (cf. https://github.com/creichen/SDL/blob/pen-api/include/SDL_hints.h#L1187). This might be related to what you are seeing.

This default behaviour is for backward compatibility; I'd prefer to have 2 as the default but worry that it might break too many existing programs that people are today merrily using with their pens.

@creichen creichen closed this Jul 30, 2023
@creichen creichen deleted the pen-api branch July 30, 2023 12:46
@sezero
Copy link
Contributor

sezero commented Jul 30, 2023

Pity that this had been neglected.

@creichen
Copy link
Contributor Author

Hmm, I think I messed up-- I wanted to rename the branch on my local fork to pen-api-SDL2 and push an updated version as a fresh pen-api branch, naively assuming that the PR would then point to the new branch (https://github.com/creichen/SDL/tree/pen-api). That is not what happened.
Any ideas how to fix this? Should I create a new PR?

@sezero
Copy link
Contributor

sezero commented Jul 30, 2023

New PR would be easiest I'd guess

@madebr
Copy link
Contributor

madebr commented Jul 30, 2023

If GitHub doesn't show a button to recreate the branch, a new PR is the way to go.

@creichen
Copy link
Contributor Author

#8058 replaces this PR (same original code base).
Sorry for the inconvenience!

MingcongBai pushed a commit to AOSC-Tracking/libinput that referenced this pull request Nov 12, 2024
Tools default to 1% lower threshold (tip up) and 5% upper threshold (tip
down). But our distance vs pressure exclusion would reset the distance
for *any* pressure value, regardless how low that value was and how high
distance was in comparison.

A very low pressure value of less than 1% would then result in a
normalized pressure of 0, so we'd effectively just reset the distance to
zero and do nothing with the pressure. This can cause distance jumps
when the tool arbitrarily sends low pressure values while hovering as
seen in libsdl-org/SDL#5481 (comment)

Commit 61bdc05 from Dec 2017
  "tablet: set the tip-up pressure threshold to 1%"
was presumably to address this but no longer (?) works.

Fix this by addressing multiple issues at the same time:
- anything under that 1% threshold is now considered as zero pressure
  and any distance value is kept as-is. Once pressure reaches 1%,
  distance is always zero.
- axis normalization is now from 1% to 100% (previously: upper threshold
  to 100%). So a tip down event should always have ~4% pressure and we
  may get tablet motion events with nonzero pressure before the tip down
  event.
  From memory, this was always intended anyway since a tip event should
  require some significant pressure, maybe too high compared to e.g.
  pressure-sensitive painting
- where a tablet has an offset, add the same 1%/5% thresholds, on top of
  that offset. And keep adjusting those thresholds as we change the
  offset. Assuming that the offset is the absolute minimum a worn-out
  pen can reach, this gives us the same behaviour as a new pen. The
  calculation here uses a simple approach so the actual range is
  slightly larger than 5% but it'll do.

  Previously, the lower threshold for an offset pen was the axis minimum
  but that can never be reached. So there was probably an undiscovered
  bug in there.

And fix a bunch of comments that were either wrong, confusing or
incomplete, e.g. the pressure thresholds were already in device
coordinates.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.