binarybird
Posts: 3
Joined: Mon Sep 21, 2015 9:55 am

JavaFX and the official Raspberry Pi touch screen

Mon Sep 21, 2015 10:39 am

Alright, I spent 3 days trying to figure out how to get the stock image of NOOBS/Raspbian working with JavaFX and the official Raspberry Pi touch screen. I dont know if this has been discussed before/else where but I though Id share my findings to help out others. Sorry for the wall of text!

The major issue was that Raspbian's stock version of JavaFX was not seeing any working touch events with the official Raspberry Pi touch screen.

The first thing I tried was upgrading the version of Java that came with the Raspberry Pi. However, Oracle completely dropped support for JavaFX on ARM with all versions of java except the version bundled with Raspbian. No luck there.

The next thing I did was look in to /dev/input for which event was the touch screen event. Long story short, I found that JavaFX only looks at /dev/input/event0 for its input. If you plug in or have ANY usb/input devices, the events in /dev/input are destroyed and recreated resulting in arbitrary event names. In my case, plugging in my mouse caused the touch screen events to be moved from /dev/input/event0 to /dev/input/event2.

However, you can create a script to move/rename the events so the touch screen events are always /dev/input/event0. All you need to do is figure out which event is the touch screen event (cat /dev/input/eventN) then run "ls -l /dev/input" to get the major and minor numbers of the touch screen event device. After all that, follow the instructions here http://www.jensd.de/wordpress/?p=845

So, now JavaFX in the stock image of Raspbian can see touch screen events. Awesome. However, the stock version of JavaFX still will not recognize ANY touch screen events and will throw the error "lens_input_pointerEvents_handleSync: malformed multi touch event".

The problem here is that the version of JavaFX included with Raspbian is old/has bugs/does not recognize many touch screens. To fix this problem, an upgrade to JavaFX is needed (Lens in JavaFX needs to be upgraded to Monocle). Because Oracle has no updates for JavaFX on ARM we need to use the OpenFX updated implementation. To do that, just follow the instructions here http://harmoniccode.blogspot.co.uk/2014 ... float.html

Thats about it. Also, for the new players here, JavaFX runs in its own framebuffer. Its does not run in a widget/window in X11. You cannot run both X11 and your JavaFX app at the same time. For my purposes this is fine as I have my JavaFX app run in full screen mode (My raspberry pi and its touch screen is a terminal for home management).

[EDIT]
To get JavaFXs native touch screen keyboard AND have the above new OpenFX libs work, start your JavaFX app with the following commands. For proper crypto (OpenFX jar interferes with proper crypto libs - ex javax mail will not work/connect) Ive added in sunjce_provider lib explicitly.

sudo java -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.vk.adjustwindow=true -Dcom.sun.javafx.virtualKeyboard=javafx -Djava.ext.dirs=/home/pi/armv6hf-sdk/rt/lib/ext -cp .:$JAVA_HOME/jre/lib/ext/sunjce_provider.jar:/home/pi/Downloads/com.your.app.here.jar some.class.path.Main
Have fun!
Last edited by binarybird on Fri Dec 11, 2015 9:43 am, edited 1 time in total.

bogusman
Posts: 2
Joined: Fri Sep 25, 2015 9:58 pm

Re: JavaFX and the official Raspberry Pi touch screen

Fri Sep 25, 2015 10:02 pm

Thanks for the helpful hints at getting this running. Unfortunately I'm receiving the following error

Udev: Failed to write to /sys/class/input/mice/uevent
Check that you have permissions to access input devices

I wonder if you've seen that particular error and if so, what the fix is?

Pi A+, updated Raspbian dist, other config as specified in your post/links.

bogusman
Posts: 2
Joined: Fri Sep 25, 2015 9:58 pm

Re: JavaFX and the official Raspberry Pi touch screen

Fri Sep 25, 2015 10:49 pm

I actually solved my own problem. Turns out the java app has to run as root in order to see the touch screen inputs. That is truly unfortunate - it is horribly bad practice to run any user-space app as root, and especially those that run with a huge framework under the covers. As an aside, it seems very odd that reading touch screen input should require root, but maybe it's a java thing in this case.

Perhaps there's a way to make this stuff work w/o root access. In the absence of such a mechanism, no Java for me.

BigBowlerAL
Posts: 1
Joined: Mon Dec 14, 2015 7:13 pm

Re: JavaFX and the official Raspberry Pi touch screen

Mon Dec 14, 2015 8:01 pm

I am getting JavaFX to load with the JavaFX keyboard, but touch doesn't respond at different times in the application. Once touch stops responding, I can't get it back, but the physical mouse and keyboard still work just fine. Touch seems to be fine without the javafx keyboard, other than it freezes on the first tap once in awhile. I have tried your updated suggestion with the VM options and the lib explicitly, but still no luck on consistent touch with the keyboard. I am on Raspbian Wheezy with all of the updates and the Java release that came with it build(1.8.0-b132). I am using Netbeans 8.1 with JDK 8u65. Any suggestions that I could try? I appreciate it.

Thanks for your time

Return to “Official Foundation Display”