[Linux] Fixed keyboard polling

This commit is contained in:
thefiddler 2014-07-15 22:54:04 +02:00
parent 468a8518cb
commit 4406d2db0d
3 changed files with 10 additions and 7 deletions

View file

@ -135,7 +135,7 @@ namespace OpenTK
Key.Keypad0, Key.Keypad0,
Key.KeypadPeriod, Key.KeypadPeriod,
Key.Unknown, Key.Unknown,
Key.Unknown, // Zzenkakuhankaku Key.Unknown, // zenkakuhankaku
Key.Unknown, // 102ND Key.Unknown, // 102ND
Key.F11, Key.F11,
// 88-95 // 88-95

View file

@ -34,7 +34,7 @@ namespace OpenTK.Platform.Linux
{ {
partial class Libc 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 extern int poll(ref PollFD fd, IntPtr fd_count, int timeout);
public static int poll(ref PollFD fd, int fd_count, int timeout) public static int poll(ref PollFD fd, int fd_count, int timeout)

View file

@ -193,11 +193,10 @@ namespace OpenTK.Platform.Linux
ProcessEvents(input_context); 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 loop {0} due to poll error [ret:{1} events:{2}]. Error: {3}.",
Debug.Print("[Input] Exiting input thread {0} due to error [ret:{1} events:{2}]", input_thread.ManagedThreadId, ret, poll_fd.revents, Marshal.GetLastWin32Error());
input_thread.ManagedThreadId, ret, poll_fd.revents);
Interlocked.Increment(ref exit); Interlocked.Increment(ref exit);
} }
} }
@ -268,7 +267,6 @@ namespace OpenTK.Platform.Linux
IntPtr device = LibInput.GetDevice(pevent); IntPtr device = LibInput.GetDevice(pevent);
InputEventType type = LibInput.GetEventType(pevent); InputEventType type = LibInput.GetEventType(pevent);
Debug.Print(type.ToString());
lock (Sync) lock (Sync)
{ {
@ -334,6 +332,11 @@ namespace OpenTK.Platform.Linux
key = KeyMap[raw]; key = KeyMap[raw];
} }
if (key == Key.Unknown)
{
Debug.Print("[Linux] Unknown key with code '{0}'", raw);
}
keyboard.State.SetKeyState(key, e.KeyState == KeyState.Pressed); keyboard.State.SetKeyState(key, e.KeyState == KeyState.Pressed);
} }
else else