From 453f80e38bcb0945e7eac27a5917dce9bdc6446b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 30 Nov 2019 06:38:01 +0100 Subject: Bug 1156: LinuxKeyEventTracker, LinuxMouseTracker: Adding property to disable each LinuxKeyEventTracker also disable the eventX reading by default, but can be enabled via new property. The 'return bug' (crash due to underlying console) is indeed not occuring when using a VT w/o running console application underneath. As Xerxes showed, one may use chvt to a free known VT or openvt. --- .../newt/driver/linux/LinuxKeyEventTracker.java | 33 ++++++++++++++++------ .../newt/driver/linux/LinuxMouseTracker.java | 23 +++++++++++---- 2 files changed, 42 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java index 402ad0051..b6503c1ed 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java @@ -47,6 +47,7 @@ import jogamp.newt.driver.KeyTracker; import com.jogamp.common.nio.StructAccessor; import com.jogamp.common.os.Platform; import com.jogamp.common.util.InterruptSource; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.WindowEvent; @@ -55,13 +56,13 @@ import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.newt.event.KeyEvent; /** - * Experimental native key event tracker thread for GNU/Linux. + * Native key event tracker thread for GNU/Linux. *

* Implementation attempts to read one of the following input event files *

    *
  1. try /dev/input/by-path/*-event-kbd
  2. *
  3. try /dev/input/by-id/*-event-kbd
  4. - *
  5. try /dev/input/event* (Warning: Unreliable due to fiddling with all native input events !)
  6. + *
  7. try /dev/input/event* Disabled by default! Warning: Unreliable due to fiddling with all native input events!
  8. *
*

*

@@ -72,20 +73,36 @@ import com.jogamp.newt.event.KeyEvent; * The last method is used if all former methods fails and it brute * force uses all first 32 event files, which can cause overall stability issues! *

+ *

+ * The last method must be enabled by setting the property newt.enable.LinuxKeyEventTracker.eventx. + *

+ *

+ * This tracker can be completely disabled by setting property newt.disable.LinuxKeyEventTracker. + *

*/ public class LinuxKeyEventTracker implements WindowListener, KeyTracker { + private static final boolean DISABLE; + private static final boolean ENABLE_PLAIN_EVENTX; + private static final String linuxDevInputByEventXRoot = "/dev/input/"; private static final String linuxDevInputByIDRoot = "/dev/input/by-id/"; private static final String linuxDevInputByPathRoot = "/dev/input/by-path/"; - private static final LinuxKeyEventTracker ledt; + private static final LinuxKeyEventTracker ledt; static { - ledt = new LinuxKeyEventTracker(); - final Thread t = new InterruptSource.Thread(null, ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager"); - t.setDaemon(true); - t.start(); + DISABLE = PropertyAccess.isPropertyDefined("newt.disable.LinuxKeyEventTracker", true); + ENABLE_PLAIN_EVENTX = PropertyAccess.isPropertyDefined("newt.enable.LinuxKeyEventTracker.eventx", true); + + if( !DISABLE ) { + ledt = new LinuxKeyEventTracker(); + final Thread t = new InterruptSource.Thread(null, ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager"); + t.setDaemon(true); + t.start(); + } else { + ledt = null; + } } public static LinuxKeyEventTracker getSingleton() { @@ -212,7 +229,7 @@ public class LinuxKeyEventTracker implements WindowListener, KeyTracker { } // 3) try /dev/input/event* (Warning: Unreliable due to fiddling with all native input events !) - { + if( ENABLE_PLAIN_EVENTX ) { final File devInputByEventX = new File(linuxDevInputByEventXRoot); while(!stop){ for( final String path : devInputByEventX.list() ) { diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index a92f6c363..c49defe11 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -38,6 +38,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.MouseTracker; import com.jogamp.common.util.InterruptSource; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseEvent; @@ -46,19 +47,29 @@ import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; /** - * Experimental native mouse tracker thread for GNU/Linux - * just reading /dev/input/mice + * Native mouse tracker thread for GNU/Linux. + *

+ * Implementation is reading /dev/input/mice * within it's own polling thread. + *

+ * This tracker can be completely disabled by setting property newt.disable.LinuxMouseTracker. + *

*/ public class LinuxMouseTracker implements WindowListener, MouseTracker { + private static final boolean DISABLE; private static final LinuxMouseTracker lmt; static { - lmt = new LinuxMouseTracker(); - final Thread t = new InterruptSource.Thread(null, lmt.mouseDevicePoller, "NEWT-MouseTracker"); - t.setDaemon(true); - t.start(); + DISABLE = PropertyAccess.isPropertyDefined("newt.disable.LinuxMouseTracker", true); + if(!DISABLE) { + lmt = new LinuxMouseTracker(); + final Thread t = new InterruptSource.Thread(null, lmt.mouseDevicePoller, "NEWT-MouseTracker"); + t.setDaemon(true); + t.start(); + } else { + lmt = null; + } } public static LinuxMouseTracker getSingleton() { -- cgit v1.2.3