Implement Long-Press-to-Right-Click on Touchscreen Linux Device with Xorg or Wayland
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
Peter Cai 350939b8d2
input: remember to clean up timerfd
.gitignore initial commit 9ヶ月前
Makefile initial commit 9ヶ月前 add configuration of whitelist and blacklist in README 9ヶ月前
input.c input: remember to clean up timerfd 9ヶ月前
input.h initial commit 9ヶ月前
rce.c fix some missing newlines 9ヶ月前
rce.h implement custom fuzz 9ヶ月前
uinput.c initial commit 9ヶ月前
uinput.h initial commit 9ヶ月前


A program that solves the problem of right clicks on Linux devices with a touchscreen. It implements the long-press-to-right-click gesture on Linux touchscreen devices while having no specific requirements on the desktop environment, display server or the distribution, which greatly improves the touch experience for users of Linux distributions.

It directly reads from evdev touchscreen input devices, parses the events, and triggers a right click with uinput when it detects a long press from a touchscreen. Since evdev is lower-level than libinput or any other user-space input driver, this program can work regardless of your choice of Xorg or Wayland.

This program started as a Python script that I published on Gist. However, the Python binding of libevdev had some mysterious bugs, and I thought it was not the best idea to run a Python interpreter to read every input event just to implement a simple feature. Thus I rewrote it in C, which is what is contained in this repository.


  • libevdev
  • libevdev headers (for development)

And of course glibc and your Linux kernel.


make all

The compiled program lies in out/evdev-rce.


Simply run


Or you may put this executable anywhere on your file system.

Note: this program needs to read from and write to /dev/input. Make sure the current user has the permission to do so, or you may use root.

There are some tunable options accessible through the following environment variables:

# Required interval in ms for a touch event to be considered a long press
# default = 1000ms
# Allowed margin of error (in px) for a long press event
# i.e. the finger is considered still if its movement is within this range
# Note: the px here is not physical pixels on the screen. It's the physical
# pixels of the touch devices, which may have a different resolution.
# default = 100px
# Uncomment to set a blacklist of devices that `evdev-rce` will not
# listen on for touch events. The names can be retrived by using `xinput`
# or simply by reading the output of `evdev-rce`
# (it will print out the names of all touch devices when starting,
#  e.g. "Found touch screen at <some_path>: <device_name>)
#TOUCH_DEVICE_BLACKLIST="device1 name|device2 name|..."
# Uncomment to set a whitelist of devices that `evdev-rce` will ONLY
# listen on. This overrides the blacklist - when whitelist is present,
# any device not in this list will be ignored.
#TOUCH_DEVICE_WHITELIST="device1 name|device2 name|..."

So you can run the program like


To customize those options.