您的位置:首页 > 移动开发 > Android开发

android系统的自动划屏测试

2012-08-17 10:20 141 查看
查看屏幕touch驱动的信息:adb shell cat /proc/bus/input/devices,每个厂家选择的event号不同

得到事件的格式:adb shell getevent /dev/input/eventx,然后点击屏幕即可捕获到刚才的点击事件

注意:想要模拟一次完整的点击事件,需要再发送一次 up, 不发送表示long touch

#include "stdlib.h"
#include "unistd.h"
#include "stdio.h"

int nowScreen = 2;
int lastScreen = 2;

int leftMax = 0;
int rightMax = 5;
int orientation = 1;

void slipScreen()
{
char command[500];
int x, y;

if (orientation < 0)
{
x = 40;
y = 600;

for (int i=0;i<6;i++)
{
sprintf(command, "sendevent /dev/input/event2 3 53 %d\nsendevent /dev/input/event2 3 54 %d\nsendevent /dev/input/event2 3 48 0\nsendevent /dev/input/event2 3 57 0\nsendevent /dev/input/event2 0 2 0\nsendevent /dev/input/event2 0 0 0", x, y);
x += 120;
system(command);
//usleep(10000);
}
system("sendevent /dev/input/event2 0 2 0\nsendevent /dev/input/event2 0 0 0");
}
else if (orientation > 0)
{
x = 680;
y = 600;

for (int i=0;i<6;i++)
{
sprintf(command, "sendevent /dev/input/event2 3 53 %d\nsendevent /dev/input/event2 3 54 %d\nsendevent /dev/input/event2 3 48 0\nsendevent /dev/input/event2 3 57 0\nsendevent /dev/input/event2 0 2 0\nsendevent /dev/input/event2 0 0 0", x, y);
x -= 120;
system(command);
//usleep(10000);
}
system("sendevent /dev/input/event2 0 2 0\nsendevent /dev/input/event2 0 0 0");
}

}

int main()
{
while(true)
{
nowScreen += orientation;
if (nowScreen > rightMax)
{
orientation = -orientation;
nowScreen = rightMax - 1;
}
else if (nowScreen < leftMax)
{
orientation = -orientation;
nowScreen = leftMax + 1;
}

printf("zealot slip to !!!!! %d\n", nowScreen);
slipScreen();
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: