if DEBUG:
print cmd_str
adbshellcommand(cmd_str)
elif action == 'swipe':
resp = adbshellcommand('input swipe %d %d %d %d' % (x0, y0, x1, y1))
if 'Error' in resp:
print 'Not support tap command'
# get tp device
tp = get_touch_event()
if tp == None:
return
step = 3
stepx = abs(x1 - x0) / step
stepy = abs(y1 - y0) / step
x = x0
y = y0
for i in range(0, step + 1):
if x0 < x1:
x = x0 + i * stepx
else:
x = x0 - i * stepx
if y0 < y1:
y = y0 + i * stepy
else:
y = y0 - i * stepy
cmd_str = ''
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 3, 53, x)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 3, 54, y)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 3, 57, 0)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 3, 48, 0)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 0, 2, 0)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 1, 330, 1)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 0, 0, 0)
adbshellcommand(cmd_str)
# up
cmd_str = ''
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 1, 330, 0)
cmd_str = cmd_str + 'sendevent %s %d %d %d;' % (tp[1], 0, 2, 0)
cmd_str = cmd_str + 'sendevent %s %d %d %d' % (tp[1], 0, 0, 0)
if DEBUG:
print cmd_str
adbshellcommand(cmd_str)
# Framebuffer Class
# Only record framebuffer attributs
class fb:
fb_bpp = 0
fb_size = 0
fb_width = 0
fb_height = 0
red_offset = 0
red_length = 0
blue_offset = 0
blue_length = 0
green_offset = 0
green_length = 0
alpha_offset = 0
alpha_length = 0
fb_data = None
def __init__(self):
fb_bpp = 0
fb_size = 0
fb_width = 0
fb_height = 0
red_offset = 0
red_length = 0
blue_offset = 0
blue_length = 0
green_offset = 0
green_length = 0
alpha_offset = 0
alpha_length = 0
fb_data = None
# send key thread
class send_key_thread(threading.Thread):
__tkapp = None
__root = None
__key = None
def __init__(self, key):
if DEBUG:
print 'send_key_thread init'
threading.Thread.__init__(self)
self.thread_stop = False
self.__key = key