Skip to content
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

Add support for styli from vendors other than Wacom #759

Merged
merged 4 commits into from
Oct 4, 2024

Conversation

whot
Copy link
Member

@whot whot commented Aug 21, 2024

This adds support for styli that aren't implicitly wacom styli.

Right now our API supports two types of styli: the few generic ones with IDs that wacom doesn't (hopefully won't ever) use. And all other real styli with actual ids but those are assumed to be Wacom styli - if any other vendor starts using IDs (possibly the one in #636 but it's not fully clear whether it is a true stylus id) we are running into issues because we won't be able to differentiate.

This patch adds a vendor id to the WacomStylus and the associated APIs. The generic pens have a vendor id of 0, everything else defaults to 0x56a unless explicitly specified otherwise.
The current set of APIs is deprecated and replaced with an API that returns a WacomStylus instead of just an id, e.g. const int * libwacom_get_supported_styli() is superseded by const WacomStylus ** libwacom_get_styli() and the same approach for the get_paired API.

Unlike the previous APIs the return value is an allocated list that must be freed by the caller (but not the list contents). It's IMO the better API and clients should switch to that because "here is $thing" is a lot more sane than "here's a magic number, now look it up so I can give you $thing" even if the actual functionality doesn't matter for now :)

Closes #639


Not 100% if returning this as const WacomStylus is the right idea, it effectively prohibits us from ever doing anything with the stylus in the future, even if it's just wacom_stylus_ref() (if we add this). OTOH doing even that would require a major rework of libwacom's internals and the use of that is quite limited - callers can copy the few properties that they need.

@whot whot marked this pull request as ready for review September 2, 2024 05:45
@whot whot force-pushed the wip/vendor-styli branch from 173b144 to 42106d0 Compare October 4, 2024 04:05
whot added 2 commits October 4, 2024 14:09
This is preparation work to add a vendor ID for styli in the future.
Rename the current single-item "id" to "tool_id" for a future
vid/tool_id pair.
@whot whot force-pushed the wip/vendor-styli branch 2 times, most recently from 568ade6 to 545ea96 Compare October 4, 2024 04:36
whot added 2 commits October 4, 2024 14:46
We need to free the list returned
The current API uses tool IDs that are bound to Wacom devices
(currently only wacom devices use those). If we have styli from other
vendors that use the same tool ID we cannot currently express this
without having duplicates.

This patch introduces an internal WacomStylusId struct with vid and
tool_id and switches the internal code over to use that.
It deprecates the current stylus id functions and replaces them with
a set that returns the WacomStylus pointer to the caller instead of just
the id. Where the id is actually used, the caller can then query that
struct.

A special case are the @Generic styli which are assigned a VID of zero.

Internal behaviour treats Wacom styli still special: styli with the
0x56a vendor id will not have a vid prefix but just the default tool id.
Likewise, the legacy functions libwacom_get_supported_styli() only returns
Wacom and the generic styli.
@whot whot force-pushed the wip/vendor-styli branch from 545ea96 to 6f45269 Compare October 4, 2024 04:47
@whot whot merged commit 884d423 into linuxwacom:master Oct 4, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libwacom needs to differentiate between Wacom and non-Wacom styli
1 participant