[Linux] Fixed keyboard polling
authorthefiddler <stapostol@gmail.com>
Tue, 15 Jul 2014 20:54:04 +0000 (22:54 +0200)
committerthefiddler <stapostol@gmail.com>
Wed, 16 Jul 2014 12:28:27 +0000 (14:28 +0200)
Source/OpenTK/Platform/Linux/Bindings/Evdev.cs
Source/OpenTK/Platform/Linux/Bindings/Poll.cs
Source/OpenTK/Platform/Linux/LinuxInput.cs

index 9b457c1..f60834f 100644 (file)
@@ -135,7 +135,7 @@ namespace OpenTK
             Key.Keypad0,
             Key.KeypadPeriod,
             Key.Unknown,
-            Key.Unknown, // Zzenkakuhankaku
+            Key.Unknown, // zenkakuhankaku
             Key.Unknown, // 102ND
             Key.F11,
             // 88-95
index 60a7bb8..f78d6d7 100644 (file)
@@ -34,7 +34,7 @@ namespace OpenTK.Platform.Linux
 {
     partial class Libc
     {
-        [DllImport(lib, CallingConvention = CallingConvention.Cdecl)]
+        [DllImport(lib, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
         public static extern int poll(ref PollFD fd, IntPtr fd_count, int timeout);
 
         public static int poll(ref PollFD fd, int fd_count, int timeout)
index 28000a3..b3b54d2 100644 (file)
@@ -193,11 +193,10 @@ namespace OpenTK.Platform.Linux
                     ProcessEvents(input_context);
                 }
 
-                if ((poll_fd.revents & (PollFlags.Hup | PollFlags.Error | PollFlags.Invalid)) != 0)
+                if (ret < 0 || (poll_fd.revents & (PollFlags.Hup | PollFlags.Error | PollFlags.Invalid)) != 0)
                 {
-                    // An error has occurred
-                    Debug.Print("[Input] Exiting input thread {0} due to error [ret:{1} events:{2}]",
-                        input_thread.ManagedThreadId, ret, poll_fd.revents);
+                    Debug.Print("[Input] Exiting input loop {0} due to poll error [ret:{1} events:{2}]. Error: {3}.",
+                        input_thread.ManagedThreadId, ret, poll_fd.revents, Marshal.GetLastWin32Error());
                     Interlocked.Increment(ref exit);
                 }
             }
@@ -268,7 +267,6 @@ namespace OpenTK.Platform.Linux
 
                 IntPtr device = LibInput.GetDevice(pevent);
                 InputEventType type = LibInput.GetEventType(pevent);
-                Debug.Print(type.ToString());
 
                 lock (Sync)
                 {
@@ -334,6 +332,11 @@ namespace OpenTK.Platform.Linux
                     key = KeyMap[raw];
                 }
 
+                if (key == Key.Unknown)
+                {
+                    Debug.Print("[Linux] Unknown key with code '{0}'", raw);
+                }
+
                 keyboard.State.SetKeyState(key, e.KeyState == KeyState.Pressed);
             }
             else