add btn_left hang and screen detect

This commit is contained in:
qiurui 2024-06-18 09:26:43 +08:00
parent 62c82474b7
commit 79cdf1ae63
1 changed files with 51 additions and 3 deletions

View File

@ -89,6 +89,8 @@
#define NAME_ELEMENT(element) [element] = #element
#define DEBUG 0
enum evtest_mode {
MODE_CAPTURE,
MODE_QUERY,
@ -110,6 +112,10 @@ static const struct query_mode {
static int grab_flag = 0;
static char* progname;
static volatile sig_atomic_t stop = 0;
//鼠标左键长按状态
static int hang = 0;
//鼠标左键点击状态
static int detect = 0;
static void interrupt_handler(int sig)
{
@ -1239,23 +1245,65 @@ static int print_events(int fd)
type = ev[i].type;
code = ev[i].code;
printf("Event: time %ld.%06ld, ", ev[i].input_event_sec, ev[i].input_event_usec);
if (type == EV_SYN) {
#ifndef DEBUG
printf("Event: time %ld.%06ld, ", ev[i].input_event_sec, ev[i].input_event_usec);
if (code == SYN_MT_REPORT)
printf("++++++++++++++ %s ++++++++++++\n", codename(type, code));
else if (code == SYN_DROPPED)
printf(">>>>>>>>>>>>>> %s <<<<<<<<<<<<\n", codename(type, code));
else
printf("-------------- %s ------------\n", codename(type, code));
#endif
} else {
#ifndef DEBUG
printf("Event: time %ld.%06ld, ", ev[i].input_event_sec, ev[i].input_event_usec);
printf("type %d (%s), code %d (%s), ",
type, typename(type),
code, codename(type, code));
#endif
if (type == EV_MSC && (code == MSC_RAW || code == MSC_SCAN))
{
#ifndef DEBUG
printf("value %02x\n", ev[i].value);
#endif
}
else if (type == EV_ABS )
{
if(detect == 1)
{
hang = 1;
}
if((code == ABS_X && ev[i].value < 30) || ( code == ABS_Y && ev[i].value < 30) || (code == ABS_X && ev[i].value > 65500) || ( code == ABS_Y && ev[i].value > 65500))
{
printf("Event: time %ld.%06ld, ", ev[i].input_event_sec, ev[i].input_event_usec);
printf("type %d (%s), code %d (%s), ",
type, typename(type),
code, codename(type, code));
printf("value %d", ev[i].value);
printf(" test\n");
}
}
else if (type == EV_KEY && code == BTN_LEFT)
{
if (ev[i].value == 1)
{
//判断是否进行了鼠标左键点击
detect = 1;
}
else if(hang == 1 && ev[i].value == 0)
{
//释放鼠标左键点击状态和长按状态
hang = 0;
detect = 0;
}
}
else
printf("value %d\n", ev[i].value);
{
#ifndef DEBUG
printf("value %d\n", ev[i].value);
#endif
}
}
}