gvalkov/python-evdev

Physical device for bluetooth devices returns controller MAC rather than device MAC

Closed this issue · 6 comments

On my dev machine and my raspberry pi, both linux 4.15 / bluez 5.49 / python-evdev 0.7, I've noticed that getting the phys property of an InputDevice returns the MAC of the bluetooth controller, and not the MAC of the device. I suspect this isn't a problem with this library, but I've no idea where else to report it.

This is a problem because I'm trying to deal with hardware that creates multiple nodes in /dev/input (for example, the sony PS4 controller creates three), and it used to be the case I could group nodes by phys attribute. Of course, this now doesn't work because any bluetooth device gets the same phys property.

That's what I figured, but I've no idea how to go about reporting that, or to whom it should be reported. Time to test other kernel versions...

This seems to be the culprit:

https://elixir.bootlin.com/linux/v4.16-rc6/source/net/bluetooth/hidp/core.c#L780

Apparently they are setting the local Mac as the "phys" and the device Mac as the "unique".
No idea why...

Do we ever have access to the unique identifier from evdev?

That looks like the one. It's definitely a kernel issue, tried downgrading BlueZ but no change in behaviour.

Reasonably simple patch to add a new 'uniq' property to InputDevice and pull it out using EVIOCGUNIQ, works for me here.

I've merged @tomoinn's fix and released evdev 0.8.0. Thanks for the fix and the analysis.