Hooked up Keyboard event handling in X11Input

Added ProcessEvents() function to IInputDriver. Does nothing on WinRawInput, but is needed by X11Input
This commit is contained in:
the_fiddler 2007-08-05 18:26:14 +00:00
parent 0531e20287
commit 6ccbfb266e
5 changed files with 32 additions and 29 deletions

View file

@ -280,6 +280,7 @@ namespace OpenTK
public void ProcessEvents()
{
glWindow.ProcessEvents();
driver.ProcessEvents();
}
#endregion

View file

@ -7,7 +7,7 @@ namespace OpenTK.Input
public interface IInputDriver : IKeyboardDriver, IMouseDriver
{
IList<IInputDevice> InputDevices { get; }
//void ProcessEvents
void ProcessEvents();
//IEnumerable<IMouse> Mice { get; }
//IEnumerable<IHid> Hids { get; }
}

View file

@ -47,6 +47,11 @@ namespace OpenTK
get { return inputDriver.Mouse; }
}
public void ProcessEvents()
{
inputDriver.ProcessEvents();
}
#endregion
}
}

View file

@ -57,33 +57,6 @@ namespace OpenTK.Platform.Windows
}
}
/*
/// <summary>
/// Gets a value indicating whether the Device list has changed, for example
/// by removing or adding a device.
/// </summary>
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

View file

@ -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
}
}