diff --git a/Source/OpenTK/Platform/X11/API.cs b/Source/OpenTK/Platform/X11/API.cs
index d2eed721..8f3c4818 100644
--- a/Source/OpenTK/Platform/X11/API.cs
+++ b/Source/OpenTK/Platform/X11/API.cs
@@ -133,16 +133,16 @@ namespace OpenTK.Platform.X11
extern internal static void NextEvent(
Display display,
[MarshalAs(UnmanagedType.AsAny)][In, Out]object e);
-
+
[DllImport(_dll_name, EntryPoint = "XNextEvent")]
extern internal static void NextEvent(Display display, [In, Out] IntPtr e);
-
+
[DllImport(_dll_name, EntryPoint = "XPeekEvent")]
extern internal static void PeekEvent(
Display display,
[MarshalAs(UnmanagedType.AsAny)][In, Out]object event_return
);
-
+
[DllImport(_dll_name, EntryPoint = "XPeekEvent")]
extern internal static void PeekEvent(
Display display,
@@ -192,6 +192,7 @@ namespace OpenTK.Platform.X11
/// Specifies the procedure that is to be called to determine if the next event in the queue matches what you want
/// Specifies the user-supplied argument that will be passed to the predicate procedure.
/// true if the predicate returns true for some event, false otherwise
+ [DllImport(_dll_name, EntryPoint = "XCheckIfEvent")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CheckIfEvent(Display display, ref XEvent event_return,
/*[MarshalAs(UnmanagedType.FunctionPtr)] */ CheckEventPredicate predicate, /*XPointer*/ IntPtr arg);
@@ -200,6 +201,10 @@ namespace OpenTK.Platform.X11
[return: MarshalAs(UnmanagedType.Bool)]
internal delegate bool CheckEventPredicate(Display display, ref XEvent @event, IntPtr arg);
+ [DllImport(_dll_name, EntryPoint = "XCheckMaskEvent")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool CheckMaskEvent(Display display, EventMask event_mask, ref XEvent event_return);
+
#endregion
#region Pointer and Keyboard functions
@@ -239,7 +244,7 @@ namespace OpenTK.Platform.X11
/// Diagnostics:
/// BadValue: Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error.
///
- [DllImport(_dll_name, EntryPoint="XGetKeyboardMapping")]
+ [DllImport(_dll_name, EntryPoint = "XGetKeyboardMapping")]
internal static extern KeySym GetKeyboardMapping(Display display, KeyCode first_keycode, int keycode_count,
ref int keysyms_per_keycode_return);
@@ -519,8 +524,11 @@ XF86VidModeGetGammaRampSize(
* */
#endregion
- }
+ [DllImport(_dll_name, EntryPoint = "XLookupKeysym")]
+ internal static extern KeySym LookupKeysym(ref XKeyEvent key_event, int index);
+
+ }
#endregion
#region X11 Structures
diff --git a/Source/OpenTK/Platform/X11/X11Input.cs b/Source/OpenTK/Platform/X11/X11Input.cs
index 176f4983..52841cd4 100644
--- a/Source/OpenTK/Platform/X11/X11Input.cs
+++ b/Source/OpenTK/Platform/X11/X11Input.cs
@@ -79,7 +79,7 @@ namespace OpenTK.Platform.X11
keyboardDriver = new X11Keyboard(window);
*/
-
+ window = new WindowInfo(parent);
keyboardDriver = new X11Keyboard(parent);
API.SelectInput(parent.Display, parent.Handle,
EventMask.KeyReleaseMask | EventMask.KeyPressMask);
@@ -124,6 +124,12 @@ namespace OpenTK.Platform.X11
///
public void ProcessEvents()
{
+ while (API.CheckMaskEvent(window.Display, EventMask.KeyReleaseMask | EventMask.KeyPressMask, ref e))
+ {
+ Debug.Print("Input window received {0} event... ", e.type.ToString());
+ keyboardDriver.ProcessKeyboardEvent(e.KeyEvent);
+ }
+ /*
try
{
while (API.CheckIfEvent(window.Display, ref e, check, IntPtr.Zero))
@@ -136,6 +142,7 @@ namespace OpenTK.Platform.X11
{
Debug.Print("DANGER: Possible callback exception: {0}", e.ToString());
}
+ */
}
API.CheckEventPredicate check = KeyEventPredicate;
diff --git a/Source/OpenTK/Platform/X11/X11Keyboard.cs b/Source/OpenTK/Platform/X11/X11Keyboard.cs
index 3cc87c5f..a6a87344 100644
--- a/Source/OpenTK/Platform/X11/X11Keyboard.cs
+++ b/Source/OpenTK/Platform/X11/X11Keyboard.cs
@@ -130,11 +130,13 @@ namespace OpenTK.Platform.X11
/// True if the event was processed, false otherwise.
internal bool ProcessKeyboardEvent(X11.XKeyEvent e)
{
- int keysym = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32();
- int keysym2 = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32();
+ //int keysym = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32();
+ //int keysym2 = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32();
bool pressed = e.type == XEventName.KeyPress;
- switch (keysym)
+ IntPtr keysym = API.LookupKeysym(ref e, 0);
+
+ switch (keysym.ToInt64())
{
default:
if (keymap.ContainsKey((XKey)keysym))
@@ -143,7 +145,8 @@ namespace OpenTK.Platform.X11
}
else
{
- Debug.Print("Virtual key {0} not mapped. (keysym: {1},{2})", e.keycode, keysym, keysym2);
+ //Debug.Print("Virtual key {0} not mapped. (keysym: {1},{2})", e.keycode, keysym, keysym2);
+ Debug.Print("Virtual key {0} not mapped. (keysym: {1})", e.keycode, keysym);
}
return true;