diff options
author | Sven Gothel <[email protected]> | 2019-11-30 06:38:01 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-11-30 06:38:01 +0100 |
commit | 453f80e38bcb0945e7eac27a5917dce9bdc6446b (patch) | |
tree | f769dad2b6e42c0856989d76ce5ed117d13193ec /src/newt | |
parent | 3ab7bd61dc8370e579c827ebc75e45dc1eb611a1 (diff) |
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.
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/linux/LinuxKeyEventTracker.java | 33 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java | 23 |
2 files changed, 42 insertions, 14 deletions
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. * <p> * Implementation attempts to read one of the following input event files * <ol> * <li>try /dev/input/by-path/*-event-kbd</li> * <li>try /dev/input/by-id/*-event-kbd</li> - * <li>try /dev/input/event* (Warning: Unreliable due to fiddling with all native input events !)</li> + * <li>try /dev/input/event* <i>Disabled by default! Warning: Unreliable due to fiddling with all native input events!</i></li> * </ol> * </p> * <p> @@ -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! * </p> + * <p> + * The last method must be enabled by setting the property <code>newt.enable.LinuxKeyEventTracker.eventx</code>. + * </p> + * <p> + * This tracker can be completely disabled by setting property <code>newt.disable.LinuxKeyEventTracker</code>. + * </p> */ 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 <code>/dev/input/mice</code> + * Native mouse tracker thread for GNU/Linux. + * <p> + * Implementation is reading <code>/dev/input/mice</code> * within it's own polling thread. + * <p> + * This tracker can be completely disabled by setting property <code>newt.disable.LinuxMouseTracker</code>. + * </p> */ 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() { |