Issue
I am trying to write a script to test my application but when I use sendevent the x and y coordinates are wrong. when I check the getevent output I can see that the coordinates are multiplied by 1.65 how do I get this scale factor programmaticly ?
Solution
On my Motorola Defy with CyanogenMod 7.2 (Android 2.3.7) I can get the min and max values for the scanner coordinates returned by the touch device (and for all other event types too) through a 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 you can see Defy's min and max values for the coordinates of the scanner (events 0035 & 0036) are xMin=21, xMax=1003, yMin=0, yMax=941.
With these and the given resolution of the screen in pixels, any pixel coordinates can be easily transformed into scanner coordinates. In a shell script this would look like this (screen resolution of Moto Defy = 480 x 854 px):
let xScanner=$(( $xPix * ($xMax-$xMin) / 479 + $xMin ))
let yScanner=$(( $yPix * ($yMax-$yMin) / 853 + $yMin ))
Works perfectly for me.
Answered By - Jpsy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.