Solved: eGalax Touch Screen issues with JavaFX (on Raspberry Pi)

In a former post I wrote about my trouble getting touch support up an running with my eGalax Touch Display, JavaFX and the Raspberry Pi.
Today Simon gave me a hint how he solved that touch event issues with JavaFX.

Many Kudos to Simon Ritter (@speakjava)!

The Clue

It turns out that the screen driver actually creates two event devices in /dev/input: event0 and event1. JavaFX sees /dev/input/event0 and assumes that events come from that, but for some unknown reason no events are actually sent: they all go to /dev/input/event1.

The Cure

Recreate /dev/input/event0 with the same device as /dev/input/event1, so JavaFX gets the information it needs:


Make it suitability for daily usage

Create an init-script to apply the patch at start-up:
Required-Start: $all‘ tells insserv to start the script after all the other scripts, at the end of the boot sequence:

#! /bin/sh
# Provides:          egalax-patch
# Required-Start:    $all
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description:
# Description:       Recreates event0 with the same device as event1, so JavaFX gets the information it needs.

. /lib/lsb/init-functions

rm -f /dev/input/event0
mknod /dev/input/event0 c 13 65

log_success_msg "eGalax Touch Screen patch for JavaFX applied."

You can load it here.

  • copy the script to /etc/init.d/
  • make sure it’s executable: sudo chmod 755 egalax_patch
  • then enable the script: sudo insserv egalax-patch

One last thing

The event devices are re-created by the driver when the USB connection was interrupted.
In this case you will have to reboot the Raspi or (much better) execute the script manually:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

11 thoughts on “Solved: eGalax Touch Screen issues with JavaFX (on Raspberry Pi)”

  1. did you have any issues with JavaFX 2.2, JDK 1.8.0-ea build 123 and inverted x&y on your touchscreen? I have mine working fine in X11 but my javafx apps have no luck and I can not find a seeting that affects it.

      1. yea, the JAVA FX app is running directly in the FrameBuffer no X manager involved. also, my /dev/input/event* is coming in on event2 and it is getting picked up correctly by my app and the system as an HID. interesting thing is I had to set evdev to invertY and invertX as well as swapXY in the 10-evdev.conf file to get it to work in X but being that JavaFX is running in its own fb it seems to bypass this configuration and go straight to the device. I am running the latest JDK 8 from oracle as well as the latest FX (I thought 2.2)

    1. peanut butter but always thought that it took some kind of special grinder. Thankfully Stacy over at Delighting In The Days  posted a recipe for homemade peanut butter made in a food processor. I don’t have a food

  2. I savor, cause I discovered exactly what I was having a look for.
    You’ve ended my four day long hunt! God Bless you
    man. Have a great day. Bye

  3. Hi Jens nicely written blog, I am using following configuration:
    RPi 3b+, OS- Buster, 7 inch HDMI- touch (USB touch) screen. I am using JavaFX 11 with Intellij Idea as IDE. In my case screen driver actually creates two event devices in /dev/input: “event0” and “mouse0”. I applied the same solution as yours but that didn’t work. I am able use onscreen matchbox keypad, so i am sure hardware is fine. Even I am able to use the touch as mouse click events.
    Its been a week long I am searching the internet. It will be helpful if you could give me some direction in this matter. Thanks.
    I have written one small java GUI code for one button and one label. It is expected to display the message “Wow, this works!!!” in a label when “Show” button is touched. (as it works on any touch-enabled device like android phone or tab). Note that code works perfect on mouse (click) events, but not for touch events.

    public class Main extends Application {
    Button showButton;
    Label label;

    public void start(Stage primaryStage) throws Exception{
    String appTitle = “JavaFx Touch Demo App”;
    String labelShowTextMsg = “Wow, this works!!!”;


    label = new Label();

    showButton = new Button();
    showButton.setOnTouchReleased(e -> label.setText(labelShowTextMsg));

    StackPane layout = new StackPane();
    layout.getChildren().addAll(showButton, label);
    primaryStage.setScene(new Scene(layout, 300, 275));;

    public static void main(String[] args) {