From e6aeff7d35493915fe104092156785f59442cf6d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 5 Nov 2009 12:12:29 +0000 Subject: [PATCH] * X11GLNative.cs: Convert from ASCII to the default encoding before generating KeyPress events (allows support for simple scripts that do not use composition.) --- Source/OpenTK/Platform/X11/X11GLNative.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs index 5976246c..fd12e697 100644 --- a/Source/OpenTK/Platform/X11/X11GLNative.cs +++ b/Source/OpenTK/Platform/X11/X11GLNative.cs @@ -105,7 +105,9 @@ namespace OpenTK.Platform.X11 bool _decorations_hidden = false; - readonly byte[] characters = new byte[16]; // Keyboard input + // Keyboard input + readonly byte[] ascii = new byte[16]; + readonly char[] chars = new char[16]; readonly KeyPressEventArgs KPEventArgs = new KeyPressEventArgs('\0'); #endregion @@ -648,14 +650,16 @@ namespace OpenTK.Platform.X11 case XEventName.KeyPress: driver.ProcessEvent(ref e); - int status = Functions.XLookupString(ref e.KeyEvent, characters, characters.Length, null, IntPtr.Zero); + + int status = Functions.XLookupString(ref e.KeyEvent, ascii, ascii.Length, null, IntPtr.Zero); + Encoding.Default.GetChars(ascii, 0, status, chars, 0); EventHandler key_press = KeyPress; if (key_press != null) { for (int i = 0; i < status; i++) { - KPEventArgs.KeyChar = (char)characters[i]; + KPEventArgs.KeyChar = chars[i]; key_press(this, KPEventArgs); } }