Which driver is in charge of headset buttons on my tablet?
OK guys, I'm a bit surprised that I didn't get any answer, but I guess that's because it was more of a stackoverflow question...

Anyway, I continued my research and I found the answer myself, in particular thanks to this PDF which describes in detail "The Android Input Architecture".

The PDF provides all the details, but basically each driver registers input_devices with the Linux Kernel and a device file is created for each event under /dev/input/eventXX. Then there is an Android mechanism to route those events to the applications, but that is not the concern here.

One can use the command getevent to get more information on these events (see also Android documentation):


getevent -li provides a list of the registered input devices with the possible events for each device
getevent -lp prints a new line for each event received (the -l flag displays the events types and names in plain text rather than number)


So for example in the case of my Lenovo tablet, we find that:

add device 6: /dev/input/event1
  bus:      0019
  vendor    0000
  product   0000
  version   0000
  name:     "ACCDET"
  location: ""
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): KEY_VOLUMEDOWN        KEY_VOLUMEUP          KEY_HANGEUL
  KEY_NEXTSONG
                KEY_PLAYPAUSE         KEY_PREVIOUSSONG      KEY_STOPCD
  KEY_SEND
  input props:
    &lt;none&gt;


NOTE: This is only an extract from the complete output, limited to the headset buttons detection.

Thus, the headset buttons handling seems to be done by some "ACCDET" component. Now, I still haven't figured out the "formal" way to know which driver registers this event, but by using the ACCDET and KEY_XX keywords in a source code search, I was able to find the corresponding source file (accdet.c), which contained the other information I was looking for (namely the voltage thresholds for each button detection).

Finally, it is also worth to note that one can simulate events using the sendevents command. So for instance, to simulate pressing (and releasing) the play/pause button, one would use:

sendevent /dev/input/event1 1 164 1; \
sendevent /dev/input/event1 1 164 0; \
sendevent /dev/input/event1 0 0 0


Hope it can help someone else...