[Linux] Fixed keyboard polling
This commit is contained in:
parent
468a8518cb
commit
4406d2db0d
3 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue