When working with Android key layout files you need to know the (USB) vendor and product ID to place your map file at the correct path of /system/usr/keylayout/Vendor_XXXX_Product_XXXX.kl.
This does not only work for USB but also for Bluetooth devices.
dmesg on the Android phone will contain lines like that when an USB controller is connected:
input: OUYA Game Controller as /devices/virtual/misc/uhid/input14 hid-generic 0005:2836:0001.0002: input: BLUETOOTH HID v1.04 Gamepad [OUYA Game Controller] ...
This lines contain all you need:
But you don't always want to watch dmesg. An input device directory was created; the path given in dmesg is relative to /sys - /sys/devices/virtual/misc/uhid/input14/.
It contains files that give us the same information as the dmesg line above.
$ cat /sys/devices/virtual/misc/uhid/input14/name OUYA Game Controller $ cat /sys/devices/virtual/misc/uhid/input14/id/bustype 0005 $ cat /sys/devices/virtual/misc/uhid/input14/id/vendor 2836 $ cat /sys/devices/virtual/misc/uhid/input14/id/product 0001 $ cat /sys/devices/virtual/misc/uhid/input14/id/version 0104
The possible numbers in the bustype file are enumerated in /usr/include/linux/input.h:
$ grep BUS_ /usr/include/linux/input.h #define BUS_PCI 0x01 #define BUS_ISAPNP 0x02 #define BUS_USB 0x03 #define BUS_HIL 0x04 #define BUS_BLUETOOTH 0x05 #define BUS_VIRTUAL 0x06 #define BUS_ISA 0x10 #define BUS_I8042 0x11 #define BUS_XTKBD 0x12 #define BUS_RS232 0x13 #define BUS_GAMEPORT 0x14 #define BUS_PARPORT 0x15 #define BUS_AMIGA 0x16 #define BUS_ADB 0x17 #define BUS_I2C 0x18 #define BUS_HOST 0x19 #define BUS_GSC 0x1A #define BUS_ATARI 0x1B #define BUS_SPI 0x1C
So if you want to list all bluetooth input devices on your Android phone from the adb shell, iterate over /sys/devices/virtual/misc/uhid/input*/ and check which bustype file contains 5.
Own bluetooth MAC address
To obtain the phone's own bluetooth MAC address, use the following command:
$ settings get secure bluetooth_address 22:22:CE:82:A8:C5