Android, reproducing physical buttons click for HTC Desire

Hello Everybody,

I have investigated how to click harware buttons, such a power button, unlock screen button, menu etc 🙂

It is very simple, all hard clicks are going through event5 interface on HTC Desire, you can use:

~$ adb shell getevent

And you will get list of supported interfaces:

add device 1: /dev/input/event9
name: “compass”
add device 2: /dev/input/event8
name: “curcial-oj”
add device 3: /dev/input/event7
name: “dummy_keypad”
add device 4: /dev/input/event6
name: “lightsensor-level”
add device 5: /dev/input/event5
name: “bravo-keypad”
add device 6: /dev/input/event4
name: “proximity”
add device 7: /dev/input/event3
name: “synaptics-rmi-touchscreen”
add device 8: /dev/input/event2
name: “projector-Keypad”
add device 9: /dev/input/event1
name: “projector_input”
add device 10: /dev/input/event0
name: “h2w headset”

So, you know, that hardware keys are on event5 interface, lets use it:

~$ adb shell getevent | grep event5

And now, just click power button on your HTC Desire, you will get following output:

/dev/input/event5: 0001 0074 00000001
/dev/input/event5: 0001 0074 00000000

Menu button is:

/dev/input/event5: 0001 008b 00000001
/dev/input/event5: 0001 008b 00000000

Home button is:

/dev/input/event5: 0001 0066 00000001
/dev/input/event5: 0001 0066 00000000

Back button is:

/dev/input/event5: 0001 009e 00000001
/dev/input/event5: 0001 009e 00000000

Search button is:

/dev/input/event5: 0001 00d9 00000001
/dev/input/event5: 0001 00d9 00000000

Please pay attention 00000001 means key is pressed, 00000000 means key is released.

To use these event for clicking buttons do not forget to convert them from HEXA to decimal representation.

Using shell to click the screen tutorial.

Happy hard clicking (:

Best regards,