Qt 5.11 : Touch input inverted in my application

标签 qt touch qt5 embedded-linux beagleboneblack

我正在将 Qt 应用程序部署到运行 Stretch 的 beaglebone black。我正在尝试使用 linuxfb 和 libinput 来处理触摸事件。触摸屏输入被反转,因此我使用 .conf 文件设置坐标变换矩阵。触摸在桌面上工作正常,但在我的 Qt 应用程序中仍然是反向的。

这是我的 Qt 环境设置:

QT_LOGGING_RULES=*=true
QT_QPA_EGLFS_HEIGHT=600
QT_QPA_EGLFS_PHYSICAL_HEIGHT=92
QT_QPA_EGLFS_PHYSICAL_WIDTH=155
QT_QPA_EGLFS_WIDTH=1024
QT_QPA_FB_DRM=1
QT_QPA_PLATFORM=linuxfb

通过上述设置,应用程序可以正确渲染并响应,但触摸输入是反向的。

以下是使用这些参数运行时的 Qt 控制台输出:

11:24:44: Checking available ports...
11:24:44: Found 101 free ports.
11:24:44: Starting /usr/bin/gdbserver...
11:24:44: Debugging starts

Listening on port 10000
Remote debugging from host 192.168.13.104
Process /home/debian/test created; pid = 1473
qt.qpa.eglfs.kms: Using backend-provided DRM device /dev/dri/card0
qt.qpa.fb: DRM device /dev/dri/card0 opened
qt.qpa.eglfs.kms: Found 1 planes

qt.qpa.eglfs.kms: plane 0: id = 18 countFormats = 2 possibleCrtcs = 0x1 supported formats = XR24 AR24 
qt.qpa.eglfs.kms:   property 0: id = 5 name = 'type'
qt.qpa.eglfs.kms:   type is ENUM, value is 1, possible values are:
qt.qpa.eglfs.kms:     enum 0: Overlay - 0
qt.qpa.eglfs.kms:     enum 1: Primary - 1
qt.qpa.eglfs.kms:     enum 2: Cursor - 2
qt.qpa.eglfs.kms: "LVDS1" mode count: 1 crtc index: 0 crtc id: 19
qt.qpa.eglfs.kms: mode 0 1024 x 600 @ 45 hz
qt.qpa.eglfs.kms: Selected mode 0 : 1024 x 600 @ 45 hz for output "LVDS1"
qt.qpa.eglfs.kms: Physical size is QSizeF(155, 92) mm for output "LVDS1"
qt.qpa.eglfs.kms: Output LVDS1 can use 1 planes: 18 
qt.qpa.fb: Got a new output: LVDS1

qt.qpa.eglfs.kms: Sorted screen list: QVector()
qt.qpa.fb: Got a dumb buffer for size 1024x600 and bpp 32: handle 1, pitch 4096, size 2457600
qt.qpa.fb: FB is 25 (DRM format 0x34325258), mapped at 0xb364d000

qt.qpa.fb: Got a dumb buffer for size 1024x600 and bpp 32: handle 2, pitch 4096, size 2457600
qt.qpa.fb: FB is 26 (DRM format 0x34325258), mapped at 0xb33f5000
qt.qpa.fb: QRect(0,0 1024x600) QSizeF(155, 92) 24 4
qt.qpa.input: libinput: input device 'gpio_keys', /dev/input/event2 is tagged by udev as: Keyboard
qt.qpa.input: libinput: input device 'gpio_keys', /dev/input/event2 is a keyboard
qt.qpa.input: libinput: input device 'tps65217_pwr_but', /dev/input/event0 is tagged by udev as: Keyboard
qt.qpa.input: libinput: input device 'tps65217_pwr_but', /dev/input/event0 is a keyboard
qt.qpa.input: libinput: input device 'DELL Dell USB Entry Keyboard', /dev/input/event3 is tagged by udev as: Keyboard
qt.qpa.input: libinput: input device 'DELL Dell USB Entry Keyboard', /dev/input/event3 is a keyboard

qt.qpa.input: libinput: input device 'SIGMACHIP Usb Mouse', /dev/input/event4 is tagged by udev as: Mouse
qt.qpa.input: libinput: input device 'SIGMACHIP Usb Mouse', /dev/input/event4 is a pointer caps
qt.qpa.input: libinput: input device 'EP0790M09', /dev/input/event1 is tagged by udev as: Touchscreen

qt.qpa.input: libinput: input device 'EP0790M09', /dev/input/event1 is a touch device
qt.qpa.input: Using xkbcommon for key mapping

我也尝试过这些环境设置:

DISPLAY=:0
QT_LOGGING_RULES=*=true
QT_QPA_EGLFS_HEIGHT=600
QT_QPA_EGLFS_INTEGRATION=eglfs_x11
QT_QPA_EGLFS_PHYSICAL_HEIGHT=92
QT_QPA_EGLFS_PHYSICAL_WIDTH=155
QT_QPA_EGLFS_WIDTH=1024
XAUTHORITY=/home/debian/.Xauthority

使用此配置,我只能在 beaglebone 运行裸 xsession 时运行该应用程序。该应用程序渲染正确,但有延迟,并且触摸仍然是反向的。

以下是此配置的 Qt 控制台输出:

11:26:52: Checking available ports...
11:26:52: Found 101 free ports.
11:26:52: Starting /usr/bin/gdbserver...
11:26:52: Debugging starts

Listening on port 10001
Remote debugging from host 192.168.13.104
Process /home/debian/test created; pid = 1893
qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_emu", "eglfs_kms_egldevice", "eglfs_kms", "eglfs_x11")
qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_x11", "eglfs_emu", "eglfs_kms_egldevice", "eglfs_kms")
qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_x11"

qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_x11"
libEGL warning: DRI2: failed to authenticate
qt.qpa.input: libinput: input device 'gpio_keys', /dev/input/event2 is tagged by udev as: Keyboard
qt.qpa.input: libinput: input device 'gpio_keys', /dev/input/event2 is a keyboard
qt.qpa.input: libinput: input device 'tps65217_pwr_but', /dev/input/event0 is tagged by udev as: Keyboard
qt.qpa.input: libinput: input device 'tps65217_pwr_but', /dev/input/event0 is a keyboard

qt.qpa.input: libinput: input device 'DELL Dell USB Entry Keyboard', /dev/input/event3 is tagged by udev as: Keyboard
qt.qpa.input: libinput: input device 'DELL Dell USB Entry Keyboard', /dev/input/event3 is a keyboard

qt.qpa.input: libinput: input device 'SIGMACHIP Usb Mouse', /dev/input/event4 is tagged by udev as: Mouse
qt.qpa.input: libinput: input device 'SIGMACHIP Usb Mouse', /dev/input/event4 is a pointer caps

qt.qpa.input: libinput: input device 'EP0790M09', /dev/input/event1 is tagged by udev as: Touchscreen
qt.qpa.input: libinput: input device 'EP0790M09', /dev/input/event1 is a touch device
qt.qpa.input: Using xkbcommon for key mapping


Running on a software rasterizer (LLVMpipe), expect limited performance.
qt.opengl.diskcache: GL_ARB_get_program_binary support = 1
qt.opengl.diskcache: Supported binary format count = 0
qt.opengl.diskcache: Shader cache supported = 0

这是我应用于触摸屏的 .conf:

Section "InputClass"
    Identifier      "calibration"
    MatchProduct    "EP0790M09"
    MatchDevicePath "/dev/input/event*"
    Driver  "libinput"
    Option          "TransformationMatrix"  "-1.0 0.0 1.0 0.0 -1.0 1.0 0.0 0.0 1.0"
EndSection

以下是 xinput 列出的设备属性:

Device 'EP0790M09':
Device Enabled (115):   1
Coordinate Transformation Matrix (116): -1.000000, 0.000000, 1.000000, 0.000000, -1.000000, 1.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix (270):  1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix Default (271):  1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Send Events Modes Available (272): 1, 0
libinput Send Events Mode Enabled (273):    0, 0
libinput Send Events Mode Enabled Default (274):    0, 0
Device Node (236):  "/dev/input/event1"
Device Product ID (235):    0, 0

版本信息:

$lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.5 (stretch)
Release:    9.5
Codename:   stretch

$ uname -a
Linux beaglebone 4.4.9 #2 SMP Thu Mar 22 13:59:11 CDT 2018 armv7l GNU/Linux

如何反转 qt 应用程序中的触摸输入?

最佳答案

最终的解决方案是在我的应用中使用 evdev touch 并使用 QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS 来修复输入事件。

我的最终运行环境是:

QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event1:rotate=180
QT_QPA_FB_NO_LIBINPUT=1
QT_QPA_PLATFORM=linuxfb

关于Qt 5.11 : Touch input inverted in my application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52826172/

相关文章:

css - 如何停止 :hover state from being active on a touchscreen?

c++ - "error: within this context"在Qt 5中安装QFtp

未找到 QtVLC 插件

qt - 在 ubuntu 22.04 上启动 spyder 时出错

c++ - 类型特征以匹配不同类的成员函数的签名

javascript - 移动 Firefox 中的触摸事件未触发

c++ - 如何使用 Qt/C++ 加密和解密文件?

android - 在 android 中,如何在 ACTION_POINTER_UP 事件中获取哪个指针向上?

c++ - 单击标题时 QTableView C++ 排序

c++ - 关于 qtestmouse 中的 fallthrough 的警告?