【问题标题】:Linux - How to program for a touchscreen outside of X WindowsLinux - 如何在 X Windows 之外为触摸屏编程
【发布时间】:2013-06-13 06:29:43
【问题描述】:

我有一个带触摸控制的小型 TFT,连接到 Raspberry Pi。触摸屏在 X 窗口中运行良好。

我希望能够在 X windows 之外使用触摸屏。 一些简单的东西,比如屏幕上的两个按钮。

我有使用 C 和使用 SDL 写入帧缓冲区的经验。或者直接记忆。

我不知道如何检测触摸屏的输入,我希望有人能指出我正确的方向。

我将触摸屏视为 /dev/input/event0

【问题讨论】:

    标签: linux raspberry-pi framebuffer touchscreen


    【解决方案1】:

    您似乎只是看到了一个常规事件设备。到目前为止你做了什么?例如,您可以试试 Linux Journal 上的 Using the Input Subsystem 文章。

    你首先应该尝试的应该是:

    /* how many bytes were read */
    size_t rb;
    /* the events (up to 64 at once) */
    struct input_event ev[64];
    
    rb=read(fd,ev,sizeof(struct input_event)*64);
    
    if (rb < (int) sizeof(struct input_event)) {
        perror("evtest: short read");
        exit (1);
    }
    
    for (yalv = 0;
         yalv < (int) (rb / sizeof(struct input_event));
         yalv++)
    {
        //if (EV_KEY == ev[yalv].type)
            printf("%ld.%06ld ",
                   ev[yalv].time.tv_sec,
                   ev[yalv].time.tv_usec,
            printf("type %d code %d value %d\n",
                   ev[yalv].type,
                   ev[yalv].code, ev[yalv].value);
    }
    

    然后你应该注意,正在发出什么事件类型,然后进一步使用它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      相关资源
      最近更新 更多