Added preliminary key handling to X11Keyboard.

Removed stupid hack in WinRawKeyboard.
This commit is contained in:
the_fiddler 2007-08-05 18:10:08 +00:00
parent 22c3eb187f
commit 69730a274e
2 changed files with 21 additions and 3 deletions

View file

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

View file

@ -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)
/// <summary>
/// Processes X11 KeyEvents.
@ -126,6 +127,25 @@ namespace OpenTK.Platform.X11
/// <returns>True if the event was processed, false otherwise.</returns>
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)