android系统的自动划屏测试

来源:互联网 发布:淘宝手机端装修 编辑:程序博客网 时间:2024/04/30 05:33

查看屏幕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;}





原创粉丝点击