androidadbscreen-sizenexus-4

Adb shell getevent method returns twice the value for X and Y on Nexus 4


I am currently trying to generate a complex gesture via the sendevent command of adb shell. In order to replay a gesture, I recorded the events via the getevent method of adb. Here is a sample of a simple tap on the bottom right of my Nexus 4 screen.

/dev/input/event2: 0003 0039 00000059
/dev/input/event2: 0003 0035 000005ff
/dev/input/event2: 0003 0036 000008e6
/dev/input/event2: 0003 003a 0000002d
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0003 0039 ffffffff
/dev/input/event2: 0000 0000 00000000

Converted into decimal values (for the sendevent method), it makes:

/dev/input/event2: 3 57 89
/dev/input/event2: 3 53 1535
/dev/input/event2: 3 54 2278
/dev/input/event2: 3 58 45
/dev/input/event2: 0 0 0
/dev/input/event2: 3 57 -1
/dev/input/event2: 0 0 0

As you can see, the value for X (ie the 53 code on line 2) is 1535 and the value for Y (the code 54 on line 3) is 2278.

How can this be possible, as my Nexus 4 screen size is only of 768*1280 ? It seems to be multiplied by a factor 2 comparing to the actual size... This is not happening when I do the same thing on a Nexus 5.

Thanks for the help on this one, it drives me crazy ! ^^


Solution

  • Those are input device (i.e. touch screen) coordinates. Touch screen is a separate device which may have a different resolution from the display.

    To check the resolution of your touch screen do

    getevent -il /dev/input/event2 | grep ABS_MT_POSITION
    

    and look at the max values