From 69730a274ef91ee6e4a3b0b7ed237e5e1461a938 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 5 Aug 2007 18:10:08 +0000 Subject: [PATCH] Added preliminary key handling to X11Keyboard. Removed stupid hack in WinRawKeyboard. --- .../OpenTK/Platform/Windows/WinRawKeyboard.cs | 2 -- Source/OpenTK/Platform/X11/X11Keyboard.cs | 22 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs index b877e68e..2810943f 100644 --- a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs +++ b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs @@ -297,12 +297,10 @@ namespace OpenTK.Platform.Windows if (!WinRawKeyboard.KeyMap.ContainsKey(rin.Data.Keyboard.VKey)) { Debug.Print("Virtual key {0} not mapped.", rin.Data.Keyboard.VKey); - OpenTK.OpenGL.GL.ClearColor(1.0f, 0.3f, 0.3f, 0.0f); } else { keyboards[0][WinRawKeyboard.KeyMap[rin.Data.Keyboard.VKey]] = pressed; - OpenTK.OpenGL.GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); } break; } diff --git a/Source/OpenTK/Platform/X11/X11Keyboard.cs b/Source/OpenTK/Platform/X11/X11Keyboard.cs index 8d42be60..d0614fb0 100644 --- a/Source/OpenTK/Platform/X11/X11Keyboard.cs +++ b/Source/OpenTK/Platform/X11/X11Keyboard.cs @@ -4,6 +4,7 @@ using System.Text; using OpenTK.Input; using System.Runtime.InteropServices; +using System.Diagnostics; namespace OpenTK.Platform.X11 { @@ -117,7 +118,7 @@ namespace OpenTK.Platform.X11 keyboards.Add(kb); } - #region internal bool ProcessKeyboardEvent(API.RawInput rin) + #region internal bool ProcessKeyboardEvent(X11.KeyEvent e) /// /// Processes X11 KeyEvents. @@ -126,6 +127,25 @@ namespace OpenTK.Platform.X11 /// True if the event was processed, false otherwise. internal bool ProcessKeyboardEvent(X11.KeyEvent e) { + int keysym = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32(); + int keysym2 = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32(); + bool pressed = e.type == EventType.KeyPress; + + switch (keysym) + { + default: + if (keymap.ContainsKey((XKey)keysym)) + { + keyboards[0][keymap[(XKey)keysym]] = pressed; + } + else + { + Debug.Print("Virtual key {0} not mapped. (keysym: {1},{2})", e.keycode, keysym, keysym2); + } + return true; + + } + return false; /*API.e.keycode switch (rin.Header.Type)