diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index 23ff4e51..dbba713b 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -280,6 +280,7 @@ namespace OpenTK public void ProcessEvents() { glWindow.ProcessEvents(); + driver.ProcessEvents(); } #endregion diff --git a/Source/OpenTK/Input/IInputDriver.cs b/Source/OpenTK/Input/IInputDriver.cs index 89c73c7b..d69dd889 100644 --- a/Source/OpenTK/Input/IInputDriver.cs +++ b/Source/OpenTK/Input/IInputDriver.cs @@ -7,7 +7,7 @@ namespace OpenTK.Input public interface IInputDriver : IKeyboardDriver, IMouseDriver { IList InputDevices { get; } - //void ProcessEvents + void ProcessEvents(); //IEnumerable Mice { get; } //IEnumerable Hids { get; } } diff --git a/Source/OpenTK/InputDriver.cs b/Source/OpenTK/InputDriver.cs index 4ffcec29..f2d51aa9 100644 --- a/Source/OpenTK/InputDriver.cs +++ b/Source/OpenTK/InputDriver.cs @@ -47,6 +47,11 @@ namespace OpenTK get { return inputDriver.Mouse; } } + public void ProcessEvents() + { + inputDriver.ProcessEvents(); + } + #endregion } } diff --git a/Source/OpenTK/Platform/Windows/WinRawInput.cs b/Source/OpenTK/Platform/Windows/WinRawInput.cs index b6f2a688..e93449e9 100644 --- a/Source/OpenTK/Platform/Windows/WinRawInput.cs +++ b/Source/OpenTK/Platform/Windows/WinRawInput.cs @@ -57,33 +57,6 @@ namespace OpenTK.Platform.Windows } } - /* - /// - /// Gets a value indicating whether the Device list has changed, for example - /// by removing or adding a device. - /// - internal static bool DeviceListChanged - { - get - { - uint count = 0; - if (API.GetRawInputDeviceList(null, ref count, API.RawInputDeviceListSize) == 0) - { - if (deviceCount == count) - return true; - - deviceCount = count; - return false; - } - else - { - throw new ApplicationException(String.Format( - "Could not retrieve the count of Keyboard devices. Windows error: {0}", - Marshal.GetLastWin32Error())); - } - } - } - */ #region protected override void WndProc(ref Message msg) int size = 0; @@ -166,6 +139,12 @@ namespace OpenTK.Platform.Windows get { throw new Exception("The method or operation is not implemented."); } } + public void ProcessEvents() + { + // Do nothing, the WndProc is automatically notified of new events. + } + + #endregion #region IMouseDriver Members diff --git a/Source/OpenTK/Platform/X11/X11Input.cs b/Source/OpenTK/Platform/X11/X11Input.cs index 2f322256..9bf7e136 100644 --- a/Source/OpenTK/Platform/X11/X11Input.cs +++ b/Source/OpenTK/Platform/X11/X11Input.cs @@ -14,6 +14,11 @@ namespace OpenTK.Platform.X11 internal sealed class X11Input : IInputDriver { private X11Keyboard keyboardDriver; + private WindowInfo window; + + Event e = new Event(); + KeyEvent keyEvent = new KeyEvent(); + #region --- Constructors --- @@ -44,7 +49,7 @@ namespace OpenTK.Platform.X11 CreateWindowMask cw_mask = CreateWindowMask.CWEventMask; - WindowInfo window = new WindowInfo(parent); + window = new WindowInfo(parent); window.Handle = API.CreateWindow( window.Display, @@ -110,6 +115,19 @@ namespace OpenTK.Platform.X11 #endregion + public void ProcessEvents() + { + API.PeekEvent(window.Display, e); + switch (e.Type) + { + case EventType.KeyPress: + case EventType.KeyRelease: + API.NextEvent(window.Display, keyEvent); + keyboardDriver.ProcessKeyboardEvent(keyEvent); + break; + } + } + #endregion } }