From 4406d2db0d1c8f75f57459dbbea1cd97f23029d6 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Tue, 15 Jul 2014 22:54:04 +0200 Subject: [PATCH] [Linux] Fixed keyboard polling --- Source/OpenTK/Platform/Linux/Bindings/Evdev.cs | 2 +- Source/OpenTK/Platform/Linux/Bindings/Poll.cs | 2 +- Source/OpenTK/Platform/Linux/LinuxInput.cs | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/OpenTK/Platform/Linux/Bindings/Evdev.cs b/Source/OpenTK/Platform/Linux/Bindings/Evdev.cs index 9b457c14..f60834f4 100644 --- a/Source/OpenTK/Platform/Linux/Bindings/Evdev.cs +++ b/Source/OpenTK/Platform/Linux/Bindings/Evdev.cs @@ -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 diff --git a/Source/OpenTK/Platform/Linux/Bindings/Poll.cs b/Source/OpenTK/Platform/Linux/Bindings/Poll.cs index 60a7bb8f..f78d6d73 100644 --- a/Source/OpenTK/Platform/Linux/Bindings/Poll.cs +++ b/Source/OpenTK/Platform/Linux/Bindings/Poll.cs @@ -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) diff --git a/Source/OpenTK/Platform/Linux/LinuxInput.cs b/Source/OpenTK/Platform/Linux/LinuxInput.cs index 28000a34..b3b54d22 100644 --- a/Source/OpenTK/Platform/Linux/LinuxInput.cs +++ b/Source/OpenTK/Platform/Linux/LinuxInput.cs @@ -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