添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Taken from the source file itself :

#define ABS_MT_POSITION_X   0x35    /* Center X ellipse position */
#define ABS_MT_POSITION_Y   0x36    /* Center Y ellipse position */

So when I get an output:

/dev/input/event2: 0003 0039 00000cc7
/dev/input/event2: 0001 014a 00000001
/dev/input/event2: 0001 0145 00000001
/dev/input/event2: 0003 0035 00000a2d  //<---- X coordinate
/dev/input/event2: 0003 0036 00000e6c  //<---- Y coordinate
/dev/input/event2: 0003 0030 00000008
/dev/input/event2: 0003 0031 00000008
/dev/input/event2: 0003 003e 0001017e
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0003 003e 00000000
/dev/input/event2: 0003 0039 ffffffff
/dev/input/event2: 0001 014a 00000000
/dev/input/event2: 0001 0145 00000000
/dev/input/event2: 0000 0000 00000000

a2d to decimal is 2605 and e6c is 3692. The position, actually was (670,2141) on the screen. How can I convert the getevent coordinates to actual usable coordinates.

Plus, what exactly does "Center X ellipse position" and "Center Y ellipse position" mean?

Any help is appreciated.

EDIT: I touched the right bottom of the screen and the getevent output was:

/dev/input/event2: EV_ABS       ABS_MT_TRACKING_ID   00000d4f
/dev/input/event2: EV_KEY       BTN_TOUCH            DOWN
/dev/input/event2: EV_KEY       BTN_TOOL_FINGER      DOWN
/dev/input/event2: EV_ABS       ABS_MT_POSITION_X    00000f86 #<---X coordinate
/dev/input/event2: EV_ABS       ABS_MT_POSITION_Y    00000f9d //<---Y coordinate
/dev/input/event2: EV_ABS       003e                 0001017e
/dev/input/event2: EV_SYN       SYN_REPORT           00000000
/dev/input/event2: EV_ABS       003e                 00000000
/dev/input/event2: EV_ABS       ABS_MT_TRACKING_ID   ffffffff
/dev/input/event2: EV_KEY       BTN_TOUCH            UP
/dev/input/event2: EV_KEY       BTN_TOOL_FINGER      UP
/dev/input/event2: EV_SYN       SYN_REPORT           00000000

Here, f86 = 3974and f9d = 3997. And the actual size of the screen is around (1057,2366) (approximately).

So I thought maybe it just uses proportions, instead of actual values. So basically if we do (co-ordinate given by getevent/ max coordinate size for getevent) * (Actual coordinate size), we might get the correct value.

And I did exactly that, and got correct values. (2905/3974)*1057 = 692 and (3692/3997)*2366 = 2185, both of which are close to the actual values.

So now the question becomes, is the canvas size always equal to (4000,4000)?

In order to use the X,Y coordinates provided by getevent into input tap x y, we need to do the following things:

  • Find out max X,Y for getevent by getevent -il /dev/input/event2 | grep ABS_MT_POSITION. That gave be (4000,4000)
  • Find out the actual screen size by adb shell wm size this gave me (1080,2400)
  • Now convert getevent (x,y) into (x*1080/4000,y*2400/4000) to get the actual results, which can be used with input tap x y.
  •