java - Injection of touch events using screen driver -


using android-event-injector library, wrote application inject touch event when event triggered. problem need inject touch @ absolute coordinates of given view, following location on screen:

view v = /* find view*/; int [] coords = new int[2]; v.getlocationonscreen(coords); 

this gives me absolute coordinates on screen. problem touch injection doesn't work.

i can inject correctly touches in screen driver, reason coordinates misunderstood , touches injected elsewhere. here examples (my screen 1024x600 landscape oriented):

  • coords (0,0) -> injected in (0,0)
  • coords (0,600) -> injected in (0,351)
  • coords (1024,0) -> not injected (most x out of range)
  • coords (1024,600) -> not injected (most x out of range)
  • coords (640,480) -> not injected (most x out of range)
  • coords (512,300) -> injected in (872,175)
  • coords (100,100) -> injected in (170,58)

based on sample values appears

  1. touchscreen (600, 1024),
  2. mapped (1024,600) display.

to generate touch event @ (x,y)display co-ordinates, (x,y)touch co-ordinates need injected can calculated follows

x(touch) = (600/1024) * x(disp) y(touch) = (1024/600) * y(disp) 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -