get android sendevent coordinates scale factor -


i trying write script test application when use sendevent x , y coordinates wrong. when check getevent output can see coordinates multiplied 1.65 how scale factor programmaticly ?

on motorola defy cyanogenmod 7.2 (android 2.3.7) can min , max values scanner coordinates returned touch device (and other event types too) through call of getevent -p /dev/input/event3:

~ # getevent -p /dev/input/event3 getevent -p /dev/input/event3 add device 1: /dev/input/event3   name:     "qtouch-touchscreen"   events:     syn (0000): 0000  0001  0003     key (0001): 0066  008b  009e  00d9  0102  014a     abs (0003): 0000  value 0, min 21, max 1003, fuzz 0 flat 0                 0001  value 0, min 0, max 941, fuzz 0 flat 0                 0010  value 0, min 21, max 1003, fuzz 0 flat 0                 0011  value 0, min 21, max 1003, fuzz 0 flat 0                 0018  value 0, min 0, max 255, fuzz 2 flat 0                 001c  value 0, min 0, max 20, fuzz 2 flat 0                 0030  value 0, min 0, max 255, fuzz 2 flat 0                 0032  value 0, min 0, max 20, fuzz 2 flat 0                 0035  value 0, min 21, max 1003, fuzz 0 flat 0                 0036  value 0, min 0, max 941, fuzz 0 flat 0 

as can see defy's min , max values coordinates of scanner (events 0035 & 0036) xmin=21, xmax=1003, ymin=0, ymax=941.

with these , given resolution of screen in pixels, pixel coordinates can transformed scanner coordinates. in shell script (screen resolution of moto defy = 480 x 854 px):

let xscanner=$(( $xpix * ($xmax-$xmin) / 479 + $xmin )) let yscanner=$(( $ypix * ($ymax-$ymin) / 853 + $ymin )) 

works me.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -