PeterCxy / evdev-right-click-emulation

Implement Long-Press-to-Right-Click on Touchscreen Linux Devices with Xorg or Wayland
Do What The F*ck You Want To Public License
90 stars 32 forks source link

Adds detection of finger tap to emulate left button action #1

Open ixnewton opened 5 years ago

ixnewton commented 5 years ago

This may be useful to extend the functionality to left click on tap which is less than the long click timeout. Using KDE plasma 5 this added function makes tablet interaction possible. The default action is focus/select which is less useful for touch interaction.

For better tap behaviour It may be better to also use a timer for "tap" definition. To improve the focus behaviour on right click menu(s) in Plasma desktop the menu item highlight should follow the finger touch. This may be that the pointer focus needs to be updated somehow? Normal menus and context menus in applications follow the touch focus OK so this may be a Plasma/QT issue for the desktop.

PeterCxy commented 5 years ago

Would this register a double-tap for applications that support tap-as-click normally?

ixnewton commented 5 years ago

You are right we should consider all use scenarios. So: 1) A single tap must be constrained by a simple time value say TAP_CLICK_INTERVAL 2) A double tap must satisfy the same time constraint twice i.e. 2 taps. It is up to the application to decide what to do with this? 3) A touch which then moves before being released. This should be interpreted as a scroll in the dominant direction of travel. It gets more complex here as I realise this is duplicating some functionality provided by the Wacom tablet controller on my installation. Maybe the touch and hold and tap functions should be merged with this project? For now getting 1 & 2 working nicely here will be a step forward?

PeterCxy commented 5 years ago

No what I meant is that this tap-to-click conversion might trigger an extra click for those applications that already support touch-as-click conversion.

ixnewton commented 5 years ago

Checking with web browsers this does not seem to be a problem. Chrome is the most touch-friendly out of the box and responds as expected on page links and buttons. Gimp seems to manage its own touch integration and ignores evdev input. I'm not sure what is going on but it relies on the Wacom input. All QT based apps respond to evdev so evdev-rce is fine.

ixnewton commented 5 years ago

Working quite nicely with TAP_CLICK_INTERVAL set to 250ms. A single tap does not seem to result in double click in touch activated apps like Chrome. If it is useful in your setup you may want to merge and maybe update on AUR? My setup is Manjaro (Arch) on Lenovo Yoga 920 which reports "Wacom HID 5113 Finger" as the touch device.

PeterCxy commented 5 years ago

Seems good to me. Could you please remove some unnecessary commented-out lines and re-format the code?

ixnewton commented 5 years ago

Works now when "Evdev touch input" enabled in Gimp

ixnewton commented 5 years ago

Merged to master for your review?

vvpnet commented 4 years ago

it doesn’t work for me. I get an error in the Xorg.log

[ 10593.799] (II) config/udev: Adding input device Simulated Right Button (/dev/input/event12)
[ 10593.799] (II) No input driver specified, ignoring this device.
[ 10593.799] (II) This device may have been added with another device file.

Run

# ./evdev-rce
Found touch screen at /dev/input/event11: HONGSHU USB Device

Tell me, what am I doing wrong?

ixnewton commented 4 years ago

Maybe you are missing an input device being setup. In my case the touch screen shows up in the graphic desktop input device control panel as a Wacom HD5113. What device do you have? You may have to install Wacom support.

vvpnet commented 4 years ago

I have an infrared touch screen. udevadm


P: /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0006/input/input18/event9
N: input/event9
S: input/by-id/usb-HONGSHU_USB_Device-event-if00
S: input/by-path/pci-0000:00:1a.0-usb-0:1.2:1.0-event
E: DEVLINKS=/dev/input/by-id/usb-HONGSHU_USB_Device-event-if00 /dev/input/by-path/pci-0000:00:1a.0-usb-0:1.2:1.0-event
E: DEVNAME=/dev/input/event9
E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0006/input/input18/event9
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_TOUCHSCREEN=1
E: ID_MODEL=USB_Device
E: ID_MODEL_ENC=USB\x20Device
E: ID_MODEL_ID=5866
E: ID_PATH=pci-0000:00:1a.0-usb-0:1.2:1.0
E: ID_PATH_TAG=pci-0000_00_1a_0-usb-0_1_2_1_0
E: ID_REVISION=0100
E: ID_SERIAL=HONGSHU_USB_Device
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
E: ID_USB_INTERFACES=:030102:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=HONGSHU
E: ID_VENDOR_ENC=HONGSHU
E: ID_VENDOR_ID=0f68
E: MAJOR=13
E: MINOR=73
E: SUBSYSTEM=input
E: USEC_INITIALIZED=26965391

P: /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0007/input/input20/mouse0
N: input/mouse0
E: DEVNAME=/dev/input/mouse0
E: DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0007/input/input20/mouse0
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_TOUCHSCREEN=1
E: ID_MODEL=USB_Device
E: ID_MODEL_ENC=USB\x20Device
E: ID_MODEL_ID=5866
E: ID_PATH=pci-0000:00:1a.0-usb-0:1.2:1.0
E: ID_PATH_TAG=pci-0000_00_1a_0-usb-0_1_2_1_0
E: ID_REVISION=0100
E: ID_SERIAL=HONGSHU_USB_Device
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
E: ID_USB_INTERFACES=:030102:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=HONGSHU
E: ID_VENDOR_ENC=HONGSHU
E: ID_VENDOR_ID=0f68
E: MAJOR=13
E: MINOR=32
E: SUBSYSTEM=input
E: USEC_INITIALIZED=11688308 

dmesg

[ 2410.598562] usb 1-1.2: USB disconnect, device number 6
[ 2411.794508] usb 1-1.2: new low-speed USB device number 7 using ehci-pci
[ 2411.879240] usb 1-1.2: New USB device found, idVendor=0f68, idProduct=5866
[ 2411.879245] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2411.879249] usb 1-1.2: Product: USB Device
[ 2411.879252] usb 1-1.2: Manufacturer: HONGSHU
[ 2411.893476] input: HONGSHU USB Device as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0007/input/input20
[ 2411.946170] hid-multitouch 0003:0F68:5866.0007: input,hiddev0,hidraw1: USB HID v1.00 Mouse [HONGSHU USB Device] on usb-0000:00:1a.0-1.2/input0 

xorg.0.log


[  1702.558] (II) config/udev: Adding input device HONGSHU USB Device (/dev/input/mouse1)
[  1702.558] (**) HONGSHU USB Device: Applying InputClass "calibration"
[  1702.558] (II) No input driver specified, ignoring this device.
[  1702.558] (II) This device may have been added with another device file.
[  1702.578] (II) config/udev: Adding input device HONGSHU USB Device (/dev/input/event5)
[  1702.579] (**) HONGSHU USB Device: Applying InputClass "evdev touchscreen catchall"
[  1702.579] (**) HONGSHU USB Device: Applying InputClass "libinput touchscreen catchall"
[  1702.579] (**) HONGSHU USB Device: Applying InputClass "calibration"
[  1702.579] (II) Using input driver 'libinput' for 'HONGSHU USB Device'
[  1702.579] (**) HONGSHU USB Device: always reports core events
[  1702.579] (**) Option "Device" "/dev/input/event5"
[  1702.579] (**) Option "_source" "server/udev"
[  1702.631] (II) input device 'HONGSHU USB Device', /dev/input/event5 is tagged by udev as: Touchscreen
[  1702.631] (II) input device 'HONGSHU USB Device', /dev/input/event5 is a touch device
[  1702.647] (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0005/input/input16/event5"
[  1702.647] (II) XINPUT: Adding extended input device "HONGSHU USB Device" (type: TOUCHSCREEN, id 10)
[  1702.647] (**) Option "AccelerationScheme" "none"
[  1702.647] (**) HONGSHU USB Device: (accel) selected scheme none/0
[  1702.647] (**) HONGSHU USB Device: (accel) acceleration factor: 2.000
[  1702.647] (**) HONGSHU USB Device: (accel) acceleration threshold: 4
[  1702.699] (II) input device 'HONGSHU USB Device', /dev/input/event5 is tagged by udev as: Touchscreen
[  1702.699] (II) input device 'HONGSHU USB Device', /dev/input/event5 is a touch device
[  1734.945] (II) config/udev: removing device HONGSHU USB Device
[  1734.951] (II) UnloadModule: "libinput"
[  1752.682] (II) config/udev: Adding input device HONGSHU USB Device (/dev/input/mouse1)
[  1752.682] (**) HONGSHU USB Device: Applying InputClass "calibration"
[  1752.682] (II) No input driver specified, ignoring this device.
[  1752.682] (II) This device may have been added with another device file.
[  1752.757] (II) config/udev: Adding input device HONGSHU USB Device (/dev/input/event5)
[  1752.757] (**) HONGSHU USB Device: Applying InputClass "evdev touchscreen catchall"
[  1752.757] (**) HONGSHU USB Device: Applying InputClass "libinput touchscreen catchall"
[  1752.757] (**) HONGSHU USB Device: Applying InputClass "calibration"
[  1752.757] (II) Using input driver 'libinput' for 'HONGSHU USB Device'
[  1752.757] (**) HONGSHU USB Device: always reports core events
[  1752.757] (**) Option "Device" "/dev/input/event5"
[  1752.757] (**) Option "_source" "server/udev"
[  1752.810] (II) input device 'HONGSHU USB Device', /dev/input/event5 is tagged by udev as: Touchscreen
[  1752.810] (II) input device 'HONGSHU USB Device', /dev/input/event5 is a touch device
[  1752.825] (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0F68:5866.0006/input/input18/event5"
[  1752.825] (II) XINPUT: Adding extended input device "HONGSHU USB Device" (type: TOUCHSCREEN, id 10)
[  1752.825] (**) Option "AccelerationScheme" "none"
[  1752.825] (**) HONGSHU USB Device: (accel) selected scheme none/0
[  1752.825] (**) HONGSHU USB Device: (accel) acceleration factor: 2.000
[  1752.825] (**) HONGSHU USB Device: (accel) acceleration threshold: 4
[  1752.877] (II) input device 'HONGSHU USB Device', /dev/input/event5 is tagged by udev as: Touchscreen
[  1752.877] (II) input device 'HONGSHU USB Device', /dev/input/event5 is a touch device
vvpnet commented 4 years ago

I have installed Watсom 0.34 version

ixnewton commented 4 years ago

If your device is recognised by the Wacom driver and can be used as a touch device you should be good to go. This project only makes use of evdev input events BTN_LEFT and BTN_RIGHT to simulate mouse clicks. This will not resolve issues at a driver level.