[Linux] Disabled TTY keyboard driver in favor of libinput
authorthefiddler <stapostol@gmail.com>
Mon, 14 Jul 2014 21:35:30 +0000 (21:35 +0000)
committerthefiddler <stapostol@gmail.com>
Wed, 16 Jul 2014 12:28:27 +0000 (14:28 +0200)
The TTY keyboard driver requires a robust cleanup method to avoid
hogging the keyboard/console after the process exists. Without
this, it does not make sense to use enable this driver.

Source/Examples/Main.cs
Source/OpenTK/Platform/Linux/LinuxFactory.cs
Source/OpenTK/Platform/Linux/LinuxKeyboardTTY.cs

index eb86bd0..c23e99b 100644 (file)
@@ -101,6 +101,23 @@ namespace Examples
         public static void Main(string[] args)
         {
             Trace.Listeners.Add(new ConsoleTraceListener());
+            using (Toolkit.Init())
+            {
+                while (true)
+                {
+                    var state = OpenTK.Input.Keyboard.GetState();
+                    if (!state.IsConnected)
+                    {
+                        break;
+                    }
+                    else if (state.IsKeyDown(OpenTK.Input.Key.Escape))
+                    {
+                        break;
+                    }
+                }
+            }
+            return;
+
             Tests.GameWindowStates.Main();
             return;
 
index 8d0d8e2..943e9dc 100644 (file)
@@ -48,6 +48,7 @@ namespace OpenTK.Platform.Linux
 
         IJoystickDriver2 JoystickDriver;
         IKeyboardDriver2 KeyboardDriver;
+        IMouseDriver2 MouseDriver;
 
         const string gpu_path = "/dev/dri"; // card0, card1, ...
 
@@ -216,9 +217,7 @@ namespace OpenTK.Platform.Linux
         {
             lock (this)
             {
-                KeyboardDriver = KeyboardDriver ??
-                    // Todo: use LinuxInput driver if available?
-                    (IKeyboardDriver2)new LinuxKeyboardTTY();
+                KeyboardDriver = KeyboardDriver ?? new LinuxInput();
                 return KeyboardDriver;
             }
         }
index d9c0c6b..63b8095 100644 (file)
@@ -35,6 +35,11 @@ using OpenTK.Input;
 
 namespace OpenTK.Platform.Linux
 {
+    // Todo: this has terrible side-effects on process exit
+    // (the keyboard remains tied up.) We need to find a
+    // proper way to clean up after ourselves, even in case
+    // of a crash.
+    #if EXPERIMENTAL
     class LinuxKeyboardTTY : IKeyboardDriver2, IDisposable
     {
         const int stdin = 0; // STDIN_FILENO
@@ -552,5 +557,6 @@ namespace OpenTK.Platform.Linux
 
         #endregion
     }
+    #endif
 }