# Do not report touch event during mouse down
if self.__end == None:
return
if abs(self.__start[0] - self.__end[0]) < 2 and \
abs(self.__start[1] - self.__end[1]) < 2 :
# mouse action: tap
send_touch_event('tap', self.__start[0], self.__start[1])
else:
# mouse action: swipe
send_touch_event('swipe', self.__start[0], self.__start[1], self.__end[0], self.__end[1])
def stop(self):
if DEBUG:
print 'LcdApplication: stop'
self.__keepupdate = False
# screen capture via socket from adb server
def updatelcd_sock(self):
if DEBUG:
print 'LcdApplication: updatelcd_sock'
# Max display area size on label widget
#max_lcd_w = 1024
#max_lcd_h = 600
max_lcd_w = 1440
max_lcd_h = 720
dev_sn = ''
hdrsize = 0
myfb = fb()
refresh_count = 0 # record refresh count
while self.__keepupdate:
# Get device SerialNumber from ADB server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(('127.0.0.1', 5037))
except:
os.system('adb start-server')
time.sleep(2)
continue
req_msg = 'host:devices'
s.sendall('%04x' % len(req_msg))
s.sendall(req_msg)
if readAdbResponse(s):
len_str = s.recv(4)
if len(len_str) < 4:
continue
length = int(len_str, 16)
dev_info = s.recv(length)
if '\t' in dev_info:
dev_sn = dev_info[0:dev_info.index('\t')]
else:
dev_sn = ''
if DEBUG:
print 'dev serial: %s' % dev_sn
s.recv(1024) # receive all rest data
s.close()
if dev_sn == '':
continue
# Get framebuffer from ADB server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 5037))
req_msg = 'host:transport:%s' % dev_sn
s.sendall('%04x' % len(req_msg))
s.sendall(req_msg)
if not readAdbResponse(s):
s.close()
else:
if DEBUG:
print 'ready to transport'
req_msg = 'framebuffer:'
s.sendall('%04x' % len(req_msg))
s.sendall(req_msg)
if not readAdbResponse(s):
s.close()
else:
reply = s.recv(4)
if len(reply) < 4:
continue
fbver = ord(reply[0]) + \
ord(reply[1]) * 0x100 + \
ord(reply[2]) * 0x10000 + \
ord(reply[3]) * 0x1000000
if DEBUG:
print 'fbver: %08x' % fbver