[嵌入式linux] /dev/input/event会引起qt卡死

[复制链接]
1556|0
 楼主| jinyi7016 发表于 2021-4-23 15:21 | 显示全部楼层 |阅读模式
本帖最后由 jinyi7016 于 2021-4-23 15:23 编辑

有一个Qt程序用的是触摸屏,还做个了button.ko的模块加载。
正常qt运行后,加载ko,
再运行一个小程序,读取button的

当按几次button后,Qt程序会卡死不刷新,触摸也没有用。尤其是按的速度快了,几乎快按时都会卡死,慢按时,有机率卡死。
但button的小程序还正常运行。
下面是btuuon测试的程序
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/ioctl.h>
  5. #include <time.h>
  6. #include <fcntl.h>
  7. #include <linux/input.h>

  8. int main(int argc, char **argv)
  9. {
  10.         int key_state;
  11.         int fd;
  12.         int ret;
  13.         int code;

  14.         struct input_event buf;

  15.         fd = open("/dev/input/event1", O_RDONLY);

  16.         if (fd < 0) {
  17.                 printf("Open Gpio_Keys failed!\n");
  18.                 return -1;
  19.         }

  20.         printf("Open Gpio_Keys successed!\n");

  21.         while(1) {
  22.                 ret = read(fd, &buf, sizeof(struct input_event));
  23.                 if (ret <= 0) {
  24.                         printf("read failed!\n");
  25.                         return -1;
  26.                 }

  27.                 code = buf.code;
  28.                 key_state = buf.value;

  29.                 switch(code)
  30.                 {
  31.                         case KEY_PROG1:
  32.                                 code = '1';
  33.                         break;
  34.                         case KEY_PROG2:
  35.                                 code = '2';
  36.                         break;
  37.                         case KEY_PROG3:
  38.                                 code = '3';
  39.                         break;
  40.                         case KEY_PROG4:
  41.                                 code = '4';
  42.                         break;
  43.                         
  44.                 }

  45.                 if(code != 0)
  46.                         printf("KEY_PROG_%c state= %d.\n", code, key_state);
  47.         }

  48.         printf("Key test finished.\n");

  49.         close(fd);

  50.         return 0;
  51. }




您需要登录后才可以回帖 登录 | 注册

本版积分规则

148

主题

1414

帖子

12

粉丝
快速回复 在线客服 返回列表 返回顶部