Directly to the content


twofing is a daemon which runs in the background and recognizes two-finger gestures performed on a touchscreen and converts them into mouse and keyboard events. This way, such gestures can be used in almost all existing applications (even ones where you wouldn’t expect it, like Wine applications) without having to modify them.

Main development of twofing took place in 2010.

twofing is only an intermediate step which is necessary until proper multitouch support along the whole software stack of a typical Linux-based system is available. It reads raw multitouch events from the kernel, bypassing X, and has to do some dirty things like grabbing the input device so the multi-touch actions are not passed to the applications as normal mouse events. It can hopefully be replaced one day by a proper multitouch framework. But for now, it works reliably, is surprisingly stable and provides some advanced features, like kinetic scrolling.


twofing currently recognizes the following two-fingered gestures: Two-fingered tap, two-fingered scroll, two-fingered zoom, two-fingered rotate. It blocks input so these gestures don't reach the underlying application as normal mouse events. It creates mouse and key events and sends them to the application instead. To be able to do this, the daemon needs different profiles for different applications. Here is what should work at the moment:

  • Eye of Gnome (Ubuntu's default picture viewer): Zoom, scroll, rotate, right click
  • Evince (Ubuntu's default document (PDF) viewer): Zoom, scroll, rotate, right click
  • F-Spot: Zoom, scroll, right click
  • Almost every other application: Scroll, right click, for many (like Firefox, Nautilus, LibreOffice/OpenOffice) also zoom

Unfortunately, applications which use extended input capabilities like Gimp, Xournal or MyPaint don't work correctly with the daemon if extended input is enabled in these applications.

Try it out

To use twofing on your device, please perform the following steps:

  1. Download the source package.
  2. Extract it to a folder of your choice (e.g. your home dir)
  3. Open a terminal and navigate to the extracted folder (e.g. cd ~/twofing-0.1.2 if you extracted it to your home dir)
  4. Install the required packages: sudo apt-get install build-essential libx11-dev libxtst-dev libxi-dev x11proto-randr-dev libxrandr-dev
  5. Compile the daemon by calling make
  6. Install the daemon by calling sudo make install
  7. Reboot
  8. Open a terminal again and call twofing (nothing will seem to happen)
  9. Open your favourite application and perform gestures on the screen with two fingers
  10. Enjoy

To stop the daemon, simply call killall twofing

Add the command twofing --wait to your startup programs to make twofing start automatically after login.

Important: twofing currently only works with the eGalax touchscreen of the Eee PC T101MT. How easy it would be to adapt it to other devices depends on the device; for many, simply altering the udev rule should be enough. As I don’t have any other hardware to test it, I can’t currently do anything about that. If you want to make it work with a different device, please feel free to send me a message.

Wanna contribute?

You find twofing on github:

Or clone the repository right now: git clone

Comments about this page

#1 thermatk complained on Feb 17, 2012 at 09:03:

Twofing is not working in Precise Alpha 2... it's just not starting the daemon.
Please help me)))

#2 Plippo explained on Feb 17, 2012 at 16:55:

Sorry, but currently there is no Precise support in twofing. I usually start updating the tool after the first beta. To find out what the problem is, you can try starting twofing in the terminal with the --debug option.

#3 thermatk said on Feb 17, 2012 at 17:09:

It's not starting anyway:(
Beta will come soon, I will wait=)
Thank you for support!

#4 holzi said on Nov 5, 2013 at 18:04 in German:

Twofing scheint unter Ubuntu 13.10 Probleme zu haben. Mal funktioniert es, mal nicht. Meistens leider letzteres.

#5 Philipp explained on Nov 6, 2013 at 20:02 in German:

Hallo holzi, leider habe ich gerade kein System, auf dem ich das nachvollziehen könnte. Du könntest einmal ein Terminal öffnen und nacheinander folgende beiden Befehle ausführen:

killall twofing
twofing --debug

Nach dem zweiten kannst du das Terminal dann minimieren (nicht schließen!) und ganz normal mit twofing arbeiten. Wenn es dann nicht mehr funktioniert, kannst du das Terminal wieder aufrufen, die Ausgabe herauskopieren und mir schicken, dann schaue ich mir das mal an.

#6 Chris said on Apr 29, 2014 at 21:14:

Hi, I just bought a Lenovo Thinkpad with touchscreen. Twofing doesn't start on Ubuntu Precise, any plans to make it work? I'll be willing to do some debugging.. :)

#7 Philipp answered on May 1, 2014 at 21:23:

Hi Chris,

twofing should actually work in Precise, but probably your touch screen is not in the list of supported devices yet. If you send me the output of the following two commands, I'll gladly try to support you with making it work.
First command:
twofing --debug
Second command:

#8 spariant said on Dec 21, 2014 at 19:20:

Hi Philipp.
Great tool. I'm trying to make it work on my HP laptop, Opensuse 13.2, Gnome3.14.
Another user had great success recently (with an Ntrig digitizer):

I get this error with twofing --debug:

twofing, the two-fingered daemon
/dev/twofingtouch: No such file or directory

What is missing?
In any case, my lsusb:
Bus 002 Device 004: ID 04f3:023e Elan Microelectronics Corp.

and cat /proc/bus/input/devices:
I: Bus=0003 Vendor=04f3 Product=023e Version=0110
N: Name="ELAN Touchscreen"
P: Phys=usb-0000:00:14.0-6/input0
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:04F3:023E.0002/input/input14
U: Uniq=
H: Handlers=mouse0 event13
B: EV=b
B: KEY=400 0 0 0 0 0
B: ABS=3273800000000003

#9 Philipp answered on Dec 22, 2014 at 09:18:

Hi spariant,
in the best case there's only an udev rule missing.
You can try that by calling the command
twofing --debug /dev/input/event13
in a root terminal or using sudo. Maybe you need to adjust the event number, that sometimes changes between reboots.
Depending on the result of this I can try to help you further.

#10 spariant responded on Dec 22, 2014 at 12:45:

It's working very well now! debug registers all events!
twofing --debug /dev/input/event14
twofing, the two-fingered daemon

Input device name: "ELAN Touchscreen"
XInput device id is 10.
XInput device id for calibration is 10.
Start calibration
No calibration data found, use default values.
Calibration: MinX: 0; MaxX: 3264; MinY: 0; MaxY: 1856
Invert X Axis: No
Invert Y Axis: No
Swap Axes: No
Calibration Matrix: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
Grab Result: 0
Reading input from device ... (interrupt to exit)
Use default profile.
Start scrolling gesture
Can you point me to where the config files are? I can adjust the scrolling speed etc.

Some problems now:
. in app "epiphany", zoom gesture causes a one-step scroll. Any idea why?
. no input reaches gnome-shell anymore. So 3 and 4 finger gestures (implemented in gnome 3.14) don't work. But this is part of the program, I understand...

#11 Philipp explained on Dec 22, 2014 at 16:20:

Unfortunately there is no config file, you need to change the source code in profiles.h and recompile.
In profiles.h you find profiles for different applications and a default profile that is used for the rest. Here you can change parameters, e.g. for scrolling speed the parameters hscrollStep and vscrollStep.

Regarding epiphany: in the default profile, twofing translates a zoom gesture into ctrl+mouse wheel. Maybe zooming doesnt work with this in epiphany?

Yes, unfortunately twofing doesnt work together with native multitouch in Gnome.

#12 Fabrice said on Nov 3, 2015 at 18:43:


I try to use twofing on a Raspbian wheezy (rpi) and this screen touch :!/14-HDMI-interface-LCD-with-capacitive-touchscreen/p/36248806/category=3094861

the one fin it's ok but when I try twofin --debug the pointer stay on the corner up left ...

have you a ideà ?

#13 Philipp said on Nov 4, 2015 at 20:39 in German:

Hi Fabrice,
I can't promise you that every touchscreen works with twofing. The tool hasn't really been maintained over the last couple of years. What is the output on your screen when you enter twofing --debug and start moving your fingers on screen?

#14 Fabrice said on Nov 5, 2015 at 08:25:

in fact I have try with jessie and it's work (but I need some software dont comatible with jessie so I need wheezy) can you have and idea witch change between jessie and wheeze ?

in wheezy (now) in fact two fing is "done" if I double tap or sweep ... i see in the debug it's done but the cursor no move and when i kill twofing cursor "re"-move

#15 Philipp said on Nov 8, 2015 at 21:21:

Sorry, I don't know what's changed between the two versions. But again, for me to be able to help you, please post the screen output of twofing --debug. Enter the command, move your fingers on the screen, perform a few gestures and then copy the output in the terminal window here.

#16 güni complimented on Feb 22, 2016 at 20:00 in German:

Hallo, Philipp, vielen Dank für twofing.
Es läuft auf Linux Mint 17.3 XFCE mit einem acer 1825ptz
ausgezeichnet. Endlich kann ich das konvertible mit Linux so nutzen, wie es vorgesehen ist.

#17 Ground0 said on Feb 25, 2016 at 17:27 in German:

Hallo Philipp,
Twofing funktioniert wie vorgesehen und einwandfrei so lange beim Start keine Maus eingesteckt ist ... gerne kann ich dir Infos geben wenn du mir sagst was gebraucht wird.
Habe jetzt mal ein .desktop Autostart hinterlegt so dass es fast bei jedem Desktop mit gestartet wird und es funktioniert :-) Das Tablet erfreut sich nun unter allen Applikationen über die 2finger funktion.

#18 avka said on Mar 27, 2016 at 18:20 in German:

Funktionert twofing auch auf touchpads? Z.B. synaptics?

#19 Philipp answered on Mar 27, 2016 at 18:30 in German:

Nein, leider nur mit absoluten Eingabegeräten, also Touchscreens etc.

#20 onestarblack said on May 30, 2016 at 10:18 in German:

Hi Philipp!
Lässt sich mit diesem Tool auch der mittlere Maus-Button simulieren?
In der "profiles.h" gibt es beim defaultProfile folgenden Eintrag:
.tapAction = { ACTIONTYPE_BUTTONPRESS, 3, 0 }
Wäre es hier schon ausreichend den Wert von 3 auf 2 zu ändern um die einen Klick mit der mittleren Maustaste auszulösen?
Danke und Grüße

#21 Philipp said on May 30, 2016 at 13:07 in German:

Ja das funktioniert, ich weiß nur nicht auswendig was der richtige Wert ist. Probier es am besten einfach mal aus.

#22 Joel Horne said on Jun 26, 2016 at 14:05:

Hi Philipp, I'm trying to install twofing on a 10" waveshare capacitive touchscreen. I type "twofing --debug" and i get "/dev/twofingtouch: No such file or directory". Any help you can provide? I'm a little bit green to programming.

#23 Joel Horne said on Jun 26, 2016 at 14:10:

cat /proc/bus/input/devices

I: Bus=0003 Vendor=0483 Product=5710 Version=0100
N: Name="WWW.PowerMCU.COM Multi Media Development Board V1.0"
P: Phys=usb-3f980000.usb-1.3/input0
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/0003:0483:5710.0001/input/input0
U: Uniq=6D72245C5753e
H: Handlers=mouse0 event0 js0
B: EV=1b
B: KEY=10000 0 0 0 0 0 0 0 0
B: ABS=3
B: MSC=10

I: Bus=0018 Vendor=0000 Product=0000 Version=0000
N: Name="Raspberry Pi Sense HAT Joystick"
P: Phys=rpi-sense-joy/input0
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=kbd event1
B: EV=100003
B: KEY=1680 0 0 10000000


Bus 001 Device 006: ID 7392:7822 Edimax Technology Co., Ltd
Bus 001 Device 005: ID 0483:5710 STMicroelectronics Joystick in FS Mode
Bus 001 Device 004: ID 0b05:17cb ASUSTek Computer, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

#24 Philipp answered on Jun 29, 2016 at 17:42 in German:

Hi Joel, if you know the event device file of your touchpad, you can try manually starting twofing with the following command
sudo twofing --debug /dev/input/event13
where event13 is the name of the event device. From your console output above I can't really tell which one is your touchscreen. But if it is correctly recognized by the kernel, you can just try out the different available event devices from event0 on until you find one that works.

#25 Thad said on Sep 24, 2016 at 04:52:

Hi Philipp - I got twofing to work on my raspberry pi 7" touchscreen, however I run a 270 degree rotated display and I can't figure out how to correctly configure twofing to compensate for this. I imagine I just need to adjust the MaxX and MaxY correctly (480 and 800 respectively)? Thanks!

twofing, the two-fingered daemon

Input device name: "FT5406 memory based driver"
XInput device id is 6.
XInput device id for calibration is 6.
Start calibration
No calibration data found, use default values.
Calibration: MinX: 0; MaxX: 800; MinY: 0; MaxY: 480
Invert X Axis: Yes
Invert Y Axis: No
Swap Axes: Yes
Calibration Matrix: 1.000000 0.000000 0.000000
0.000000 1.000000

#26 Stuart Longland said on Nov 12, 2016 at 06:28:

Hi, Just found your package whilst trying to get a right-click solution going on the Raspberry Pi touchscreen.

I was unable to get the usual solutions working, but yours does work.
I saw someone had forked your package and added Debian build files, I've tweaked this a bit, adding some scripts into Xsession and Xreset to start and stop twofing automatically and adding a Udev rules file for the Raspberry Pi touchscreen.
My fork is here if you or anyone else here is interested:

#27 Phil King said on Feb 3, 2017 at 16:17:

It was working great, but sadly no longer since I upgraded Raspbian to the latest version (2017-01-11).

#28 FlipPI76 said on Apr 21, 2017 at 14:12:

Everyone who is having problems with Jessie and the debug message "No valid axis inversion data found".

I think I found a workaround:

# Install packages
sudo apt-get update && sudo apt-get install build-essential libx11-dev libxi-dev x11proto-randr-dev libxrandr-dev libxtst-dev xserver-xorg-input-evdev

# Install twofing
cd ~
tar -xvzf twofing-0.1.2.tar.gz
cd twofing-0.1.2
make && sudo make install

# create a new rule-file
sudo nano /etc/udev/rules.d/70-touchscreen-raspberrypi.rules

# add the following line
KERNEL=="event*",ATTRS{name}=="FT5406 memory based driver",SYMLINK+="twofingtouch",MODE="0440"

# modify X11 config
sudo nano /usr/share/X11/xorg.conf.d/40-libinput.conf

# add the following lines at the end of the file
Section "InputClass"
Identifier "calibration"
Driver "evdev"
MatchProduct "FT5406 memory based driver"

Option "EmulateThirdButton" "1"
Option "EmulateThirdButtonTimeout" "750"
Option "EmulateThirdButtonMoveThreshold" "30"

# Reboot your device
sudo reboot

# Check if twofing is working
twofing --debug

# Add twofing to autostart
nano ~/.config/lxsession/LXDE-pi/autostart

# add the line at the end

# Cleanup
cd ~
rm -rf ~/twofing-0.1.2

#29 Michael Krantz said on Mar 14, 2017 at 10:27 in German:

Hallo Philipp, I have a 10" WaveShare WS170120 on my Pi3. Twofing --debug reports:
Twofing, the two-fingered daemon
Input device name: "WaveShare WS170120"
XInput device id is 8.
XInput device id for calibration is 8.
Start calibration
No calibration data found, use default values.
No valid axis inversion data found.

The file is generated by xinput_calibrator /usr/share/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
Identifier "calibration"
MatchProduct "WaveShare WS170120"
Option "MinX" "30"
Option "MaxX" "65531"
Option "MinY" "1017"
Option "MaxY" "65951"
Option "SwapXY" "0" # unless it is already set to 1
Option "InvertX" "0" # unless it was already set
Option "InvertY" "0" # unless it was already set
The daemon twofing does not start. Where can I enter the calibrations data?
I do not know any more.
Many Thanks.

#30 Stefan Vorkoetter said on Apr 26, 2017 at 03:30:

I'm using twofing on a Raspberry Pi (Raspbian Jessie), and it works great, except when Chromium is running. Chromium has its own gesture recognition (drag scrolling, long press for right-click, two-finger zoom, etc.), and these no longer work when twofing is running. Is there a way to write a profile (in profiles.h) to completely disable twofing in chromium?

#31 Philipp said on Apr 27, 2017 at 11:16:

No I'm sorry, as twofing bypasses the default gesture input system there is no way to use built-in gestures while twofing is running.

#32 Stefan Vorkoetter mentioned on Jun 13, 2017 at 02:47:

Interestingly, after updating to the latest version of Chromium (56.0.2924.84), my wish has come true. Both twofing's gestures and the "standard" gestures now work in Chromium. And twofing works great with everything else I've tried too.

#33 Stefan Vorkoetter said on Jun 18, 2017 at 16:58:

Please ignore my previous comment. It seems that the standard gestures worked in Chromium because twofing had stopped working due to an update, with the "No valid axis inversion data found" message. I was able to fix that using the advice in post #28 above.

#34 alican said on Dec 22, 2017 at 09:32:

only these codes do not continue
pi@raspberrypi:~ $ twofing --debug
twofing, the two-fingered daemon

Input device name: "FT5406 memory based driver"
XInput device id is 9.
XInput device id for calibration is 9.
Start calibration
No calibration data found, use default values.
No valid axis inversion data found.
pi@raspberrypi:~ $

#35 Flynx jubilated on Mar 28, 2018 at 00:10:

Works great with the elan touchscreen on my asus transformer t102ha. Many thanks!

#36 Jonnie Cache said on May 24, 2018 at 13:49:

I had the same problem as @alican. I ran xinput_calibrator and copied the data into both /etc/X11/xorg.conf.d/99-calibration.conf and /usr/share/X11/xorg.conf.d/01-input.conf. I'm also using the FT5406 with the 7" Raspberry Pi TouchScreen. Any assistance is appreciated!

#37 Sam S said on May 25, 2018 at 15:48:

Is it possible to do a right click on a file with this?

#38 Philipp said on May 29, 2018 at 07:07:

I'm sorry, this project isn't maintained any more.

#39 René L said on Jan 31, 2019 at 22:43 in German:

Great work to provide "twofing"! Unfortunately I cannot get it run on my Raspberry 3B+ with official 7 inch touch screen. Compile was successful and config files are adopted as mentioned above (the 40-libinput.conf and the70-touchscreen-egalax.rules). But when restarting I get following error in the Xorg.0.log, while the Raspberry itself works fine with the screen:

[ 11.968] (II) LoadModule: "evdev"
[ 11.968] (II) Loading /usr/lib/xorg/modules/input/
[ 11.982] (II) Module evdev: vendor="X.Org Foundation"
[ 11.982] compiled for 1.19.0, module version = 2.10.5
[ 11.982] Module class: X.Org XInput Driver
[ 11.982] ABI class: X.Org XInput driver, version 24.1
[ 11.982] (II) Using input driver 'evdev' for 'FT5406 memory based driver'
[ 11.982] (**) FT5406 memory based driver: always reports core events
[ 11.982] (**) evdev: FT5406 memory based driver: Device: "/dev/input/event0"
[ 11.983] (--) evdev: FT5406 memory based driver: Vendor 0 Product 0
[ 11.983] (--) evdev: FT5406 memory based driver: Found absolute axes
[ 11.983] (--) evdev: FT5406 memory based driver: Found absolute multitouch axes
[ 11.983] (II) evdev: FT5406 memory based driver: No buttons found, faking one.
[ 11.983] (--) evdev: FT5406 memory based driver: Found x and y absolute axes
[ 11.983] (--) evdev: FT5406 memory based driver: Found absolute touchscreen
[ 11.983] (II) evdev: FT5406 memory based driver: Configuring as touchscreen
[ 11.984] (**) Option "EmulateThirdButton" "1"
[ 11.984] (**) Option "EmulateThirdButtonTimeout" "750"
[ 11.984] (**) Option "EmulateThirdButtonMoveThreshold" "30"
[ 11.984] (**) evdev: FT5406 memory based driver: YAxisMapping: buttons 4 and 5
[ 11.984] (**) evdev: FT5406 memory based driver: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
[ 11.984] (**) Option "config_info" "udev:/sys/devices/virtual/input/input0/event0"
[ 11.984] (II) XINPUT: Adding extended input device "FT5406 memory based driver" (type: TOUCHSCREEN, id 6)
[ 11.985] (II) evdev: FT5406 memory based driver: initialized for absolute axes.
[ 11.986] (**) FT5406 memory based driver: (accel) keeping acceleration scheme 1
[ 11.986] (**) FT5406 memory based driver: (accel) acceleration profile 0
[ 11.986] (**) FT5406 memory based driver: (accel) acceleration factor: 2.000
[ 11.986] (**) FT5406 memory based driver: (accel) acceleration threshold: 4
[ 11.988] (II) config/udev: Adding input device FT5406 memory based driver (/dev/input/mouse0)
[ 11.988] (**) FT5406 memory based driver: Applying InputClass "calibration"
[ 11.988] (II) Using input driver 'evdev' for 'FT5406 memory based driver'
[ 11.988] (**) FT5406 memory based driver: always reports core events
[ 11.988] (**) evdev: FT5406 memory based driver: Device: "/dev/input/mouse0"
[ 11.988] (EE) evdev: FT5406 memory based driver: Unable to query fd: Inappropriate ioctl for device
[ 12.080] (EE) PreInit returned 2 for "FT5406 memory based driver"
[ 12.080] (II) UnloadModule: "evdev"

Since the module gets unloaded automatically, the twofing fails at startup time with:

$ twofing --debug
twofing, the two-fingered daemon

Input device name: "FT5406 memory based driver"
ERROR: Input device not found in XInput device list!

The mentioned device seems to created at boot time automatically:

$ ls -l /dev/input/mouse0
crw-rw---- 1 root input 13, 32 Jan 31 22:01 /dev/input/mouse0

but might be somehow wrong or the Raspbian is not what you expected for twofing:

$ uname -a
Linux himbeere 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

Any idea would be welcome here.

Best regards,

#40 Philipp said on Feb 2, 2019 at 08:01 in German:

Hi René, I think the problem is due to the xinput driver not being loaded correctly, so twofing sees no device. But I'm sorry I can't tell what is the problem with the driver

#41 René described on Mar 16, 2019 at 02:37 in German:

Hi Philipp,
just to tell you... Finally, I started a new try from scratch. This time I used a new Raspbian from scratch (version "stretch" from Nov 2018), but no NOOBS. In addition, I also found following entry in the Raspberry Pi forum which is based on your description plus some small extras ( Now it works. Thanks.

#42 Philipp jubilated on Mar 16, 2019 at 06:41 in German:

Hi René, great to hear that! I hope you enjoy it!

#43 MBu complimented on Aug 12, 2019 at 10:54:

Thank you for this great tool. It works perfect for my Chromium Kiosk-System on a Raspherry Pi 3+ / Raspian 9.9 Stretch / Acer T230H Touch-Monitor. I tried serveral ways in several nights, but TwoFing was the only way I found that does everything out of the box. Thanks for your very good work.

Write a comment

Caution, all information entered will be transferred without encryption!

Back to the top