Short version: By using udev I'm able to get the manufacturer and product IDs! See
commit.
People of Linux, please test and let me know how this works for you.
Long version:
I spent some time digging through the SDL joystick implementation and reading up on iotcl and this is what I've found. SDL looks for joysticks in
/dev/input/event while SFML looks in
/dev/input/js. This means SDL must use the "EV" iotcls like
EVIOCGNAME while SFML must use the "JS" ioctls like
JSIOCGNAME. When attempting to mix and match I get
EINVAL errors (
EVIOCGNAME fails with an
EINVAL error in SFML but it's JS counterpart
JSIOCGNAME works great).
Unfortunately there is not a JS version of
EVIOCGID, the ioctl used for retrieve an
input_id struct, and hence the vendor and product IDs. SFML could switch to use
/dev/input/event rather than
/dev/input/js but it's my understanding that "js" is the more modern way of handling joysticks (also, my install of Ubuntu would get a "permission denied" error when attempting to read "event" which is odd since SDL worked...).
Enter
libudev. I had seen mention of udev before in the tracker (
here) in which Laurent posted a
tutorial for udev. Using it is pretty straightforward and it looks to be the standard way for working with hardware devices on Linux systems. It also provides a really easy way to read vendor and product IDs. The downside is that we've introduced another dependency for the Linux implementation of SFML.
The
commit with the udev update uses udev to retrieve the vendor (manufacturer) and product IDs and the
JSIOCGNAME ioctl to get the joystick name. It also updates Cmake to link udev when compiling SFML on Linux.
While the Cmake update works I'm not really sure it's the best way to do it. A cursory google yields a
FindUDev.cmake file. Honestly, I don't know enough about Cmake to know the best way so I guess reading up on that is next