After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740758 - Add getters for device vendor/product IDs
Add getters for device vendor/product IDs
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GdkDevice
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
Carlos Garnacho
Depends on:
Blocks: 742593
 
 
Reported: 2014-11-26 15:05 UTC by Carlos Garnacho
Modified: 2015-01-19 14:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
device: Add property/getters for vendor/product identifiers (5.58 KB, patch)
2014-11-26 15:06 UTC, Carlos Garnacho
reviewed Details | Review
x11: Fetch vendor/product identifiers for input devices (2.87 KB, patch)
2014-11-26 15:06 UTC, Carlos Garnacho
none Details | Review
device: Add property/getters for vendor/product identifiers (5.87 KB, patch)
2014-11-27 15:36 UTC, Carlos Garnacho
reviewed Details | Review
x11: Fetch vendor/product identifiers for input devices (3.10 KB, patch)
2014-11-27 15:36 UTC, Carlos Garnacho
none Details | Review
device: Add property/getters for vendor/product identifiers (6.97 KB, patch)
2015-01-16 11:32 UTC, Carlos Garnacho
committed Details | Review
x11: Fetch vendor/product identifiers for input devices (3.10 KB, patch)
2015-01-16 11:32 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2014-11-26 15:05:47 UTC
I'm attaching a couple of patches to add vendor/product-id properties to GdkDevice, and to fill these in so far in the X11 backend. 

For wayland, the virtual slave keyboard/pointer/touch devices created might need to make this up though (or kept as 0/0)... seeing the lastest drafts around of the tablet protocol it seems this could be satisified for these devices at least, which I think is the primary usecase. And these would be the only non-virtual slave devices on wayland anyway, so it would be more or less consistent.
Comment 1 Carlos Garnacho 2014-11-26 15:06:51 UTC
Created attachment 291555 [details] [review]
device: Add property/getters for vendor/product identifiers

These are a construct only properties, expected to be filled in from
platform specific code.
Comment 2 Carlos Garnacho 2014-11-26 15:06:58 UTC
Created attachment 291556 [details] [review]
x11: Fetch vendor/product identifiers for input devices

These are retrieved from XInput device properties.
Comment 3 Matthias Clasen 2014-11-26 15:27:01 UTC
Review of attachment 291555 [details] [review]:

Are integers really future-proof for this ? I kinda would have expected string
Comment 4 Carlos Garnacho 2014-11-26 16:12:59 UTC
Good point, vid/pid are specified to be 16-bit wide on usb, so we've got some room most usually, not sure for how long though, it might be smarter to go for strings, plus you get the typical hex dump format without the user doing so explicitly.
Comment 5 Carlos Garnacho 2014-11-27 15:36:23 UTC
Created attachment 291665 [details] [review]
device: Add property/getters for vendor/product identifiers

These are a construct only properties, expected to be filled in from
platform specific code.
Comment 6 Carlos Garnacho 2014-11-27 15:36:29 UTC
Created attachment 291666 [details] [review]
x11: Fetch vendor/product identifiers for input devices

These are retrieved from XInput device properties.
Comment 7 Matthias Clasen 2014-11-28 13:53:00 UTC
Review of attachment 291665 [details] [review]:

Documentation could be better. I would expect it to state things like
- the vendor/product ID may be NULL (currently only x11 has them set)
- these IDs are expected to be constant throughout the lifetime of a device
- some advice on using these IDs for storing device-specific configuration, perhaps also about tying the stored configuration to the host system

Out of interest: do input devices generally have something like serial numbers that would let you store configuration for individual devices ?
Comment 8 Matthias Clasen 2014-12-22 23:59:04 UTC
Should we get this landed ?
Comment 9 Carlos Garnacho 2014-12-23 12:41:44 UTC
I realized I forgot to reply to the initial review...

(In reply to comment #7)
> Review of attachment 291665 [details] [review]:
> 
> Documentation could be better. I would expect it to state things like
> - the vendor/product ID may be NULL (currently only x11 has them set)

I agree

> - these IDs are expected to be constant throughout the lifetime of a device

Of the physical device even :), I'll make that point clearer

> - some advice on using these IDs for storing device-specific configuration,
> perhaps also about tying the stored configuration to the host system

Yeah, I agree would be nice, I'll add some little advice.

> 
> Out of interest: do input devices generally have something like serial numbers
> that would let you store configuration for individual devices ?

Most generally yes, there's perhaps not much granularity for eg. bulk mice (many using the same chip, etc), but vid/pid are actually part of the usb protocol AFAIK, so we can most surely expect one, windowing limitations aside.

Common "special" cases are builtin devices though, keyboard/trackball/touchpad devices have suspiciously low IDs there, so I think these are made up by the kernel, they do seem constant across runs anyway though.

You can btw check the IDs on the commandline through xinput list-props <deviceid> | grep "Device Product ID" , I used hexadecimal on the strings

(In reply to comment #8)
> Should we get this landed ?

I'm honestly undecided, as of yet. It's maybe not as pressing on the GTK+ side as it was on the Clutter side (there's no eager users for starters...). 

As for wayland support, I first and foremost throught of this for tablets and alike, the tablet protocol should be made to account for this (the current drafts cater for per-tablet/tool runtime persistence, not across runs). for keyboard/pointer/touch devices it might just be made up, given how little granularity we get there, there's probably not a lot more we can do...

I'll extend docs and update the patches so far.
Comment 10 Carlos Garnacho 2014-12-23 12:45:43 UTC
(In reply to comment #9)
> Common "special" cases are builtin devices though, keyboard/trackball/touchpad

s/trackball/trackpoint/
Comment 11 Emmanuele Bassi (:ebassi) 2015-01-15 17:27:11 UTC
(In reply to comment #9)

> (In reply to comment #8)
> > Should we get this landed ?
> 
> I'm honestly undecided, as of yet. It's maybe not as pressing on the GTK+ side
> as it was on the Clutter side (there's no eager users for starters...). 

Mutter is the only user, and it uses either the X11 or the libinput backends, which expose this information.

applications are going to use the GDK backend, though, so at some point we may want to expose this information.
Comment 12 Carlos Garnacho 2015-01-15 19:41:19 UTC
(In reply to comment #11)
> (In reply to comment #9)
> 
> > (In reply to comment #8)
> > > Should we get this landed ?
> > 
> > I'm honestly undecided, as of yet. It's maybe not as pressing on the GTK+ side
> > as it was on the Clutter side (there's no eager users for starters...). 
> 
> Mutter is the only user, and it uses either the X11 or the libinput backends,
> which expose this information.
> 
> applications are going to use the GDK backend, though, so at some point we may
> want to expose this information.

Indeed :), my point was, the main interest in these properties probably comes from gimp/inkscape/etc, and most likely, mainly for tablets. But there's neither tablet protocol yet, nor GTK+3-based releases of these projects.

But I agree, on wayland don't have this info for the devices we currently support, nor will do in the foreseeable future, and the wl_tablet drafts already provide vid/pid along other info when we come to support these. Plus it can be already useful somewhere else on X11 (g-s-d might be happy to use it for starters).

I'll update the docs in the patches
Comment 13 Carlos Garnacho 2015-01-16 11:32:18 UTC
Created attachment 294669 [details] [review]
device: Add property/getters for vendor/product identifiers

These are a construct only properties, expected to be filled in from
platform specific code.
Comment 14 Carlos Garnacho 2015-01-16 11:32:23 UTC
Created attachment 294670 [details] [review]
x11: Fetch vendor/product identifiers for input devices

These are retrieved from XInput device properties.
Comment 15 Carlos Garnacho 2015-01-19 14:25:35 UTC
Pushing this, it would be positive to have this for g-s-d.

Attachment 294669 [details] pushed as 5e53676 - device: Add property/getters for vendor/product identifiers
Attachment 294670 [details] pushed as 121fddc - x11: Fetch vendor/product identifiers for input devices