Resolved all crash bugs on X11Input.X11Keyboard
Working on X11 key mapping.
This commit is contained in:
parent
4f35768779
commit
cbb1c1a0d9
3 changed files with 28 additions and 10 deletions
|
@ -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
|
|||
/// <param name="predicate">Specifies the procedure that is to be called to determine if the next event in the queue matches what you want</param>
|
||||
/// <param name="arg">Specifies the user-supplied argument that will be passed to the predicate procedure.</param>
|
||||
/// <returns>true if the predicate returns true for some event, false otherwise</returns>
|
||||
[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
|
|||
/// <para>Diagnostics:</para>
|
||||
/// <para>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.</para>
|
||||
/// </remarks>
|
||||
[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
|
||||
|
|
|
@ -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
|
|||
/// </summary>
|
||||
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;
|
||||
|
|
|
@ -130,11 +130,13 @@ namespace OpenTK.Platform.X11
|
|||
/// <returns>True if the event was processed, false otherwise.</returns>
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue