Reading multitouch using libevdev

我们两清 提交于 2019-12-22 17:23:08

问题


I'm trying to read raw multitouch data from my touchpad, though I'm not getting the results I expect.

I started by identifying what my device ID was, using lsinput:

/dev/input/event0
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x5
   version : 0
   name    : "Lid Switch"
   phys    : "PNP0C0D/button/input0"
   bits ev : EV_SYN EV_SW

/dev/input/event1
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x1
   version : 0
   name    : "Power Button"
   phys    : "PNP0C0C/button/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event2
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x1
   version : 0
   name    : "Power Button"
   phys    : "LNXPWRBN/button/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event3
   bustype : BUS_I8042
   vendor  : 0x1
   product : 0x1
   version : 43907
   name    : "AT Translated Set 2 keyboard"
   phys    : "isa0060/serio0/input0"
   bits ev : EV_SYN EV_KEY EV_MSC EV_LED EV_REP

/dev/input/event4
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x6
   version : 0
   name    : "Video Bus"
   phys    : "LNXVIDEO/video/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event5
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x6
   version : 0
   name    : "Video Bus"
   phys    : "LNXVIDEO/video/input0"
   bits ev : EV_SYN EV_KEY

/dev/input/event6
   bustype : BUS_I8042
   vendor  : 0x2
   product : 0x7
   version : 433
   name    : "SynPS/2 Synaptics TouchPad"
   phys    : "isa0060/serio1/input0"
   bits ev : EV_SYN EV_KEY EV_ABS

/dev/input/event7
   bustype : BUS_HOST
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "Ideapad extra buttons"
   phys    : "ideapad/input0"
   bits ev : EV_SYN EV_KEY EV_MSC

/dev/input/event8
   bustype : BUS_USB
   vendor  : 0x4f2
   product : 0xb57e
   version : 34624
   name    : "EasyCamera: EasyCamera"
   phys    : "usb-0000:00:14.0-6/button"
   bits ev : EV_SYN EV_KEY

/dev/input/event9
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH Mic"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event10
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH Headphone"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event11
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH HDMI/DP,pcm=3"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event12
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH HDMI/DP,pcm=7"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event13
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH HDMI/DP,pcm=8"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event14
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH HDMI/DP,pcm=9"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

/dev/input/event15
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH HDMI/DP,pcm=10"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

Since I could see none of the devices listed here, I decided to choose /dev/input/event6 (SynPS/2 Synaptics TouchPad) which seemed the closest to what I was looking for.

Now, I've written a dead-simple code to try and get the max number of MT points from it:

int main(void)
{
    struct libevdev *dev;
    int fd;
    int rc;

    fd = open("/dev/input/event6", O_RDONLY|O_NONBLOCK);
    if (fd < 0)
        fprintf(stderr, "error: %d %s\n", errno, strerror(errno));

    rc = libevdev_new_from_fd(fd, &dev);

    if (rc < 0)
        fprintf(stderr, "error: %d %s\n", -rc, strerror(-rc));

    int n = libevdev_get_num_slots(dev);
    printf("%d\n", n);

    return 0;
}

I can compile it using gcc -levdev myfile.c and run it properly, but I only get 2.

Does that mean that my touchpad only handles two points ? This is weird, since it can handle (at least) 4 on Windows.

Do you have any ideas about this?

Small update : using libinput-debug-events, I get the following output

When using 1 finger:

event6   POINTER_MOTION    +0.79s     0.00/ -6.22
event6   POINTER_MOTION    +0.80s     0.00/-11.26
event6   POINTER_MOTION    +0.81s     0.00/ -9.93
event6   POINTER_MOTION    +0.82s     1.69/ -9.05

When using 2 fingers:

event6   POINTER_AXIS      +0.60s   vert -9.27* horiz 1.19* (finger)
event6   POINTER_AXIS      +0.62s   vert -13.25* horiz 2.03* (finger)
event6   POINTER_AXIS      +0.65s   vert -15.89* horiz 2.03* (finger)

When using 3 fingers:

event6   GESTURE_PINCH_UPDATE  +0.68s   4  1.42/-1.54 ( 5.49/-5.97 unaccelerated)  0.99 @  0.15
event6   GESTURE_PINCH_UPDATE  +0.71s   4  0.00/-0.31 ( 0.00/-0.89 unaccelerated)  0.99 @  0.07
event6   GESTURE_PINCH_UPDATE  +0.73s   4  1.03/-3.44 ( 3.20/-10.74 unaccelerated)  0.98 @  0.74

When using 4 fingers:

event6   GESTURE_SWIPE_UPDATE  +0.80s   4  0.00/-0.89 ( 0.00/-6.86 unaccelerated)
event6   GESTURE_SWIPE_UPDATE  +0.82s   4  0.00/-1.18 ( 0.00/-7.16 unaccelerated)
event6   GESTURE_SWIPE_UPDATE  +0.84s   4  0.68/-3.48 ( 3.20/-16.40 unaccelerated)

So it does seem that there's something on my system that is capable of detecting and reading at least up to four fingers... But for some reason, I can't get them with libevdev...

来源:https://stackoverflow.com/questions/50268899/reading-multitouch-using-libevdev

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!