linux evdev 触摸屏 镜像,树莓派(Linux 系统)触摸屏翻转显示以及触摸翻转

树莓派(Linux 系统)触摸屏翻转显示以及触摸翻转

树莓派(Linux 系统)触摸屏翻转显示以及触摸翻转

问题:未使用的Pi官方屏幕,所以使用HDMI屏幕显示的时候,显示旋转的同时,触摸没有旋转目的:旋转屏幕显示的同时,使得触摸也跟随旋转操作总流程:旋转90度操作翻转显示:1.sudo nano /boot/config.txt2.在文件末尾加入display_rotate=0display_rotate=1//90°display_rotate=2//180°display_rotate=3//270°ctrl + o 保存文档 重启即可。注:以下操作皆为SSH操作,所以每条指令前都加了DISPLAY=:0,如果本机操作删掉即可。1.安装xinputsudo apt-get install xinput2.列出所有输入设备信息 远程操作时,使用xinput指令需要加入DISPLAY=:0DISPLAY=:0 xinput --list3.列出目标设备属性DISPLAY=:0 xinput --list-props 74.旋转触摸的坐标轴1)所以先交换x、y轴DISPLAY=:0 xinput --set-prop '7' 'Evdev Axes Swap' 12)然后反转y轴DISPLAY=:0 xinput --set-prop '7' 'Evdev Axis Inversion' 0 1显示旋转修改之后需要重启。而触摸旋转不需要重启。详细操作方法:1.安装xinputsudo apt-get install xinput描述:xinput - utility to configure and test X input devicesxinput-用于配置和测试X输入设备的实用程序xinput is a utility to list available input devices,xinput是一个实用程序,可以列出可用的输入设备、query information about a device and change input device settings.关于设备的查询信息和更改输入设备设置2.列出所有输入设备信息xinput --list如果远程操作记得在命令前加DISPLAY=:0得到以下信息:[email protected]:~ $ DISPLAY=:0 xinput --list? Virtual core pointer                          id=2    [master pointer  (3)]?   ? Virtual core XTEST pointer                id=4    [slave  pointer  (2)]?   ? Logitech USB Optical Mouse                id=6    [slave  pointer  (2)]?   ? WaveShare WaveShare Touchscreen           id=7    [slave  pointer  (2)]? Virtual core keyboard                         id=3    [master keyboard (2)]? Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]? Logitech USB Keyboard                     id=8    [slave  keyboard (3)]? Logitech USB Keyboard                     id=9    [slave  keyboard (3)]3.列出目标设备属性由于所使用的触摸屏幕是微雪7寸屏幕,由以上信息可以得到微雪的触摸屏对应的ID为7所以,接下来看这款输入设备的属性,[email protected]:~ $ DISPLAY=:0 xinput --list-props 7Device 'WaveShare WaveShare Touchscreen':Device Enabled (115):   1Coordinate Transformation Matrix (116): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000Device Accel Profile (240):     0Device Accel Constant Deceleration (241):       1.000000Device Accel Adaptive Deceleration (242):       1.000000Device Accel Velocity Scaling (243):    10.000000Device Product ID (244):        3823, 5Device Node (245):      "/dev/input/event3"Evdev Axis Inversion (246):     0, 0Evdev Axis Calibration (247):   Evdev Axes Swap (248):  0Axis Labels (249):      "Abs MT Position X" (267), "Abs MT Position Y" (268), "Abs MT Pressure" (269), "None" (0), "None" (0), "None" (0)Button Labels (250):    "Button Unknown" (233), "Button Unknown" (233), "Button Unknown" (233), "Button Wheel Up" (121), "Button Wheel Down" (122)Evdev Scrolling Distance (251): 0, 0, 0Evdev Middle Button Emulation (252):    0Evdev Middle Button Timeout (253):      50Evdev Third Button Emulation (254):     0Evdev Third Button Emulation Timeout (255):     1000Evdev Third Button Emulation Button (256):      3Evdev Third Button Emulation Threshold (257):   20Evdev Wheel Emulation (258):    0Evdev Wheel Emulation Axes (259):       0, 0, 4, 5Evdev Wheel Emulation Inertia (260):    10Evdev Wheel Emulation Timeout (261):    200Evdev Wheel Emulation Button (262):     4Evdev Drag Lock Buttons (263):  0这块屏幕正常显示和触摸的信息如上。如果执行到这一步,发现并没有以上的Evdev等属性项,请跳转第2种方法。现在需要达到的目的是在屏幕显示反转的同时,使得触摸也随显示翻转。屏幕显示为翻转90度。/boot/config.txt设置为display_rotate=1上述信息中Evdev Axis Inversion 项是每条轴的旋转设置项,后面第一个参数是x,第二个参数是y.Evdev Axes Swap项对应的是两条轴的交换。0为不翻转,1为翻转例如。x轴原本是朝向右的,当把Evdev Axis Inversion的第一个参数设置为1,即x轴朝向左。4.旋转触摸的坐标轴现在目的是要触摸旋转90度,从坐标轴理解:即目的x轴正向为初始y轴的反向。目的y轴的正方向为初始x轴的正向。1)所以先交换x、y轴DISPLAY=:0 xinput --set-prop '7' 'Evdev Axes Swap' 12)然后反转y轴DISPLAY=:0 xinput --set-prop '7' 'Evdev Axis Inversion' 0 1这样即可完成触摸旋转90度。若要旋转其他角度,推理一下即可。显示旋转修改之后需要重启。而触摸旋转不需要重启。第二种方法如果查询到的信息如下DISPLAY=:0 xinput --list-props 6Device 'WaveShare WaveShare Touchscreen':Device Enabled (114):   1Coordinate Transformation Matrix (115): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000libinput Calibration Matrix (246):      0.000000, 1.000000, 0.000000, -1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000libinput Calibration Matrix Default (247):      1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000libinput Send Events Modes Available (248):     1, 0libinput Send Events Mode Enabled (249):        0, 0libinput Send Events Mode Enabled Default (250):        0, 0Device Node (251):      "/dev/input/event0"Device Product ID (252):        3823, 5可以看到该驱动方式采用的是libinput,查看/usr/share/X11/xorg.conf.d/目录下是否有40-libinput.conf这个文件。无 则需要安装sudo apt-get install xserver-xorg-input-libinput下一步安装完成后ls一下,就可以看到在/usr/share/X11/xorg.conf.d/目录下存在该文件,下一步复制该文件到/etc/X11/xorg.conf.d/目录下。一开始xorg.conf.d这个目录在/etc/X11可能没有,需要自己创建。sudo mkdir xorg.conf.d下一步复制到xorg.conf.d 目录下即可。sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/下一步进入/etc/X11/xorg.conf.d/目录下修改40-libinput.conf 文件cd /etc/X11/xorg.conf.d/sudo nano 40-libinput.conf找到touchscreen sectionSection "InputClass"Identifier "libinput touchscreen catchall"MatchIsTouchscreen "on"MatchDevicePath "/dev/input/event*"Driver "libinput"EndSection添加一行  Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1结果为Section "InputClass"Identifier "libinput touchscreen catchall"Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1MatchIsTouchscreen "on"MatchDevicePath "/dev/input/event*"Driver "libinput"

EndSection

然后重启生效这样的修改也是同样修改为翻转90度,如果需要修改为其他角度,请参考libinput的算法https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html第三种方法是微雪官方给的建议,修改input子系统的代码,然后重新编译内核,即可完成详细操作没有给出,给了一个操作文档,在此也写出来,希望有操作成功的可以分享下。

06e7b96a10d70b4f696f55cabd529b3e.png

树莓派(Linux 系统)触摸屏翻转显示以及触摸翻转相关教程

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值