Commit graph

532 commits

Author SHA1 Message Date
Peter Hutterer
e0d95cbf2d wacom: Always allow calibration for display tablets
Previously we'd only allow calibration if the "Automatic" monitor
mapping was selected. In cases where that fails (happens here with a
Kamvas 12 connected to a laptop) we need to select the monitor mapping
manually - but we shouldn't lose the ability to calibrate.

So make this dependent on whether the device is a tablet built into a
display.
2024-06-25 20:33:19 +00:00
Peter Hutterer
98674f6ba5 wacom: Enforce a Z-shape sequence of calibration points
Otherwise we could calibrate the device to be upside down by doing a
reverse Z (starting lower-right). If the device is mounted upside-down
this should be fixed elsewhere.
2024-06-18 10:11:46 +10:00
Peter Hutterer
2c45312564 wacom: Fix wrong alignment detection in the calibrator
Our along_axis() helper would compare the input value against both x and
y of the reference point. This can lead to misdetections of the distance
to the desired points, e.g. if the upper-left reference point is 100/100
and the upper-right point is a clearly-wrong 99/2500, the alignment
would succeed because the x-axis is within the threshold.

This would sort itself out later since the lower points are difficult to
get right then, but let's fix this by checking the desired alignment
only. This way a misclick happens on the actual misclick, not on the
next point(s) in the sequence.
2024-06-18 10:11:19 +10:00
Peter Hutterer
8de142c268 wacom: Turn the struct Calib into a proper CcCalibrator GObject 2024-06-18 10:08:56 +10:00
Peter Hutterer
dd119f3cc7 wacom: Simplify the calibrator code
The code was written to (sort-of) accomodate for the four calibration
points to happen in any sequence. Except we don't care about that, we do
it in a Z shape starting top-left - so let's simplify the code to check
for that sequence.
2024-06-18 10:08:56 +10:00
Peter Hutterer
4e68a871b0 wacom: Up the calibrator threshold to 50 pixels
For anyone calibrating the tablet the threshold doesn't really matter,
it's in their own interest to be as precise as possible. Meanwhile, for
testing a larger threshold makes life a lot easier as we don't need to
be that exact to go through the calibration sequence.

Finally, for devices with calibration seriously out of whack a larger
threshold allows those devices to be used.
2024-06-18 10:08:56 +10:00
Peter Hutterer
d389bc0237 wacom: Fix the thresholds passed to the calibrator
The two were swapped, making the calibrator *really* sensitive to
misclicks.
2024-06-18 10:08:56 +10:00
Peter Hutterer
cd850f34da wacom: Make the calibrator code a bit more readable
Lumping the x/y of a single point into a struct and making the array out
of that makes it a bit easier to read than the clicked_x[0] etc.
2024-06-18 10:08:56 +10:00
Peter Hutterer
85b9b0bd47 wacom: Reset the clock after any click on the calibrator
If we click with the right tool, let's reset the clock to make the
calibration process less stressful.
2024-06-18 10:08:56 +10:00
Peter Hutterer
4ae9d83286 wacom: Correct the link to gnome help
Existing tablet help entries are grouped under "wacom-" so let's assume this
will be what we'll end up with.

https://gitlab.gnome.org/GNOME/gnome-user-docs/-/merge_requests/180
2024-06-10 07:56:09 +00:00
Peter Hutterer
b82621a36c wacom: Fall back to the generic tablet provided by libwacom
Whether libwacom knows about a tablet has no effect on whether the
tablet works, only whether we know how to map it, which styli are
available, etc.

Instead of pretending there is no tablet connected let's use the
libwacom fallback tablet instead. As of libwacom 2.11 that defaults to a
built-in tablet (the vast majority of devices these days) which means we
can at least map this to an output, calibrate it etc.
2024-06-04 11:54:22 +00:00
Peter Hutterer
a966a067c1 wacom: If we have two identical monitors, suffix the connector name
Check if any two monitor display names are identical, if so use a
display name like 'Manufacturer 27" (HDMI-1)'.
2024-06-04 09:35:19 +00:00
Peter Hutterer
491c945ca6 wacom: Use CcDisplayMonitor and friends to get monitor names
Remove the gnome_rr_* bindings and substitute them with the respective
calls from the CcDisplayMonitor. This way we get the same monitor names
as the display panel.

Closes #1821
2024-06-04 09:35:19 +00:00
Automeris naranja
d824ed115c wacom: Port "Grip Pen" to AdwDialog 2024-06-03 07:57:16 +00:00
Philip Withnall
b86e0e069b wacom: Fix an uninitialised variable error
This fixes an error when building with `-Werror=maybe-uninitialized`.
It’s a false positive, because the `for` loop conditions ensure that a
`default:` case in the `switch` is never needed. However, compilers are
historically quite bad at static analysis of loop iteration count, so
let’s just initialise the variable to a safe default.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-05-16 14:01:02 +00:00
Peter Hutterer
33c49dc125 wacom: Check for the right output connector name
Otherwise we just return the first output with the corresponding vendor
and serial number.

Fixes: 75ce02e202 ("wacom: Provide connector name for disambiguation")
2024-03-22 13:02:22 +00:00
Peter Hutterer
ebd2b013dd wacom: Accept 4-value output settings
We now store the connector name as fourth value.

Fixes: 75ce02e202 ("wacom: Provide connector name for disambiguation")
2024-03-22 13:02:22 +00:00
Jakub Steiner
6718390123 wacom: adjust graphic
- all the pen assets have no padding inside the SVG itself
- round the shape a little
2024-03-11 16:53:12 +00:00
Peter Hutterer
8b45201b9c wacom: Accept eraser types of button when matching stylus IDs
Unlike tip erasers, styli with eraser buttons (which is the vast
majority anyway) have the same tool ID as the pen so the first
matching stylus we find is the right one.

This avoid a warning when a AES stylus is connected - we're constructing
the stylus based on our cache information which is just ID and serial
but no device - meaning the device lookup cannot work.

Fixes: 42b39cb956 ("wacom: Prefer the stylus over the eraser")
2024-03-11 16:53:12 +00:00
Peter Hutterer
f1cfc55a63 wacom: Add AES styli as separate stylus SVG
These are styli like the Dell Active Pen and most of the styli supplied
with laptops with built-in tablets. We don't always know how many
buttons these have so the SVG has just one large button. They're
typicall slimmer and less rounded than the Wacom pens so let's reflect
this here too.

This requires libwacom 1.4 released June 2020
2024-03-11 16:53:12 +00:00
Peter Hutterer
d8cb742c6d wacom: Remove an outdated ifdef
libwacom 0.27 was released in 2017, I think we can rely on having that
version now.
2024-03-06 09:11:10 +00:00
Automeris naranja
ec30d48a12 wacom: Port "Keep Aspect Ratio" row to AdwSwitchRow 2024-02-29 10:18:47 +00:00
Peter Hutterer
b45550770e wacom: Fix a memleak on error
In the case of an error we allocated the object but returned NULL
without freeing it.
2024-02-29 09:44:22 +00:00
Peter Hutterer
2aa192f8cf wacom: Change a boolean to the enum value it actually is
Happens to be a value of zero so FALSE works, but only because this is C
and nothing is true and everything is permitted.
2024-02-29 09:44:22 +00:00
Peter Hutterer
c348239e92 wacom: Pass the GsdDevice through to the calibrator
The calibrator gets a GdkDevice from the GtkGesture but that device is
the "Logical device for $TABLET", not the actual device. So all our
clicks are discarded as coming from the wrong device.

Fix this by passing the GsdDevice through and comparing against that.

Closes #1871
2024-02-19 12:47:09 +01:00
Peter Hutterer
430585eed0 wacom: Fix a few indentation/whitespace issues 2024-02-19 12:46:06 +01:00
Peter Hutterer
1d8f9a3504 wacom: Switch dialog to a AdwPreferencesRow 2024-02-11 08:48:38 +01:00
Peter Hutterer
fcab974558 wacom: Add mnemonics to the stylus button assignments 2024-02-11 08:48:38 +01:00
Peter Hutterer
ad63caf442 wacom: Switch to using a dialog for stylus button assignments
This moves the wacom stylus button assignments from a dropdown to an
external dialog, in preparation for adding keyboard shortcuts to this
list.
2024-02-11 08:48:37 +01:00
Peter Hutterer
605914911a wacom: Clear the stylus highlight after a timeout 2024-02-10 21:55:41 +00:00
Peter Hutterer
c5ee557eb9 wacom: Highlight the currently active stylus
This duplicates the SVG images for the styli with the only change being
the fill colour (#d3d7cf to #3584e4).

Closes #2464
2024-02-10 21:55:41 +00:00
Peter Hutterer
9770c6f382 wacom: Give proper ids and classes to the stylus SVG components
The images for the styli include a stylus and some buttons, so
creatively name the components after that.
2024-02-10 21:55:41 +00:00
Peter Hutterer
e5172d04bd wacom: Update struct field indentation
Preparation for a new field that requires this indentation, split out to
make the actual patch easier to review.
2024-02-10 21:55:41 +00:00
Peter Hutterer
2365a6fa07 wacom: Sort the gresources stylus SVGs alphabetically-ish 2024-02-10 21:55:41 +00:00
Peter Hutterer
f6d1ae869d wacom: Cast to GTK_WIDGET, keep the CcWacomStylusPage type 2024-02-10 21:55:41 +00:00
Carlos Garnacho
75ce02e202 wacom: Provide connector name for disambiguation
Provide the connector name as the fourth value in the
tablet's output setting. With recent Mutter, this will
allow disambiguating the mapped output if there happens
to be multiple outputs with the same EDID data.
2024-02-06 09:20:01 +00:00
Monster
045e9cd28d wacom: Remove periods from descriptions 2024-02-05 10:54:29 +00:00
Carlos Garnacho
dac9065dc3 wacom: Drop list to handle pads
This has effectively become a group of one. We can
keep the pad device pointer as well.
2024-02-05 09:49:21 +00:00
Carlos Garnacho
d4d0c60fc7 wacom: Pair only builtin pads with tablets
Pad and tablet grouping has become more irrelevant to the
Settings UI since commit 39402f21ba, as the EKR is the only
known case of an additional pad with distinct vendor/product
that is tied to another device.

But we preserved the grouping of pads (for the tablet EKRs
get paired with), thus possibly still requesting the pad OSD
to be shown on one of these arbitrarily.

In order to ensure that each "Map Buttons..." button in the
UI goes to the right pad being mapped, drop this grouping of
tablets, and make a CcWacomPage only observe a stylus/pad
pair in the same group (i.e. belonging to the same device, if
multiple similar ones are plugged) and with the same vendor+product
(i.e. coming from the same device).

Closes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2876
2024-02-05 09:49:21 +00:00
Peter Hutterer
cc7aff9cb2 wacom: Add missing mnemonics
Partially fixes #2541
2024-02-05 09:12:57 +00:00
Peter Hutterer
95248cd906 wacom: Return has_eraser again as libwacom intended
libwacom_has_eraser tells us if this non-eraser tool has an
associated eraser (same serial, different tool id)
libwacom_is_eraser tells us if the current tool is an eraser device.

Now that we always have the stylus for the tool in proximity (see the
previous commit), switch this back to the has_eraser function and
rename it in the process so it's more obviously not the seemingly
obvious interpretation.

This reverts commit 9bd0b94527.
2024-02-05 08:30:26 +00:00
Peter Hutterer
42b39cb956 wacom: Prefer the stylus over the eraser
Pens with an integrated eraser share the serial number with the
corresponding pen but differ in the tool ID. libwacom provides a
"paired_id" mapping to look up one from the other.

If the user brings the eraser into proximity the very first time the
tool is seen, the eraser's tool ID is stored in the keyfile instead of
the associated stylus id. This leads to otherwise wrong behavior since
erasers share the serial number with the stylus but don't have any
buttons, don't have any erasers themselves, etc.

Fix this by looking up a matching stylus when we see an eraser. This
effectively filters our CcWacomTool to always be the pen, which is an
inadvertent assumption anyway.
2024-02-05 08:30:26 +00:00
Peter Hutterer
c5dc74f8b6 wacom: The only stylus with rotation is the Art pen 2024-01-24 09:50:15 +00:00
Peter Hutterer
e8c1e0e778 wacom: Don't call the standard styli "Standard stylus"
The overwhelmingly vast majority of users will never see anything else
than a "Standard" (i.e. pen-shaped) stylus. And there's a mismatch
between e.g. the Pro Pen 3 being labeled as "Standard stylus" when users
spent money on getting a Pro pen.

Let's drop the "Standard" prefix, it adds nothing in this context.
2024-01-24 09:50:15 +00:00
Hari Rana
d0bcdc9645 wacom: Port to AdwSwitchRow 2024-01-22 09:08:43 +00:00
Peter Hutterer
e53cc1f69b wacom: Mark the center-point of the stylus pressure curve 2023-12-21 09:23:49 +00:00
Peter Hutterer
815bd93943 wacom: Simplify the algorithm a bit
Now that our first and last configuration points are 0/100 and 100/0
respectively, we can simplify the calculation a bit. Doubly so because
p2 is just a mirror of p1.

That with extending the slider range to 200 means we get a value for
each integer combination on our pressurecurves - which in turn means
that for any of our generated curves we get a slider value return.
2023-12-21 09:23:49 +00:00
Peter Hutterer
b76a7e06b2 wacom: Extend the pressurecurve range by 25% in each direction
Now that we have a smooth range of curves we can extend the curve
into the maximum range we can support given 0 < x|y < 100.
2023-12-21 09:23:49 +00:00
Peter Hutterer
7814309ee9 wacom: Generate a smooth pressure curve instead of just 7
Our previously hardcoded pressurecurves follow a predictable
pattern so we can generate the value on-the-fly based on that pattern.
The slider now uses a range of 100 (integer) values and calculates the
matching pressure curve based on that. The actual pressure curve remains
the same for previous values.

However, the functions are lossy thanks to CLAMP() so figuring out
a slider position from points requires heuristics: for each of the four
coordinates we calculate a slider value. Then we calculate the points
for that slider value and if those calculated points match ours then we
have a winner.
2023-12-21 09:23:49 +00:00
Peter Hutterer
2bfd36c362 wacom: Use the ExpressKey Remote name for the EKR
There's only one device like this that we support so we might as well
use its name as-is instead of a more confusing "External Pad device"
which isn't very descriptive unless you work with tablets and know what
a "pad" is in this context.

Anyone who owns this device will have bought it under the name
ExpressKey remote.

Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2044
2023-11-08 08:51:56 +00:00