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
|
@ -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="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>
|
/// <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>
|
/// <returns>true if the predicate returns true for some event, false otherwise</returns>
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XCheckIfEvent")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
internal static extern bool CheckIfEvent(Display display, ref XEvent event_return,
|
internal static extern bool CheckIfEvent(Display display, ref XEvent event_return,
|
||||||
/*[MarshalAs(UnmanagedType.FunctionPtr)] */ CheckEventPredicate predicate, /*XPointer*/ IntPtr arg);
|
/*[MarshalAs(UnmanagedType.FunctionPtr)] */ CheckEventPredicate predicate, /*XPointer*/ IntPtr arg);
|
||||||
|
@ -200,6 +201,10 @@ namespace OpenTK.Platform.X11
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
internal delegate bool CheckEventPredicate(Display display, ref XEvent @event, IntPtr arg);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Pointer and Keyboard functions
|
#region Pointer and Keyboard functions
|
||||||
|
@ -239,7 +244,7 @@ namespace OpenTK.Platform.X11
|
||||||
/// <para>Diagnostics:</para>
|
/// <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>
|
/// <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>
|
/// </remarks>
|
||||||
[DllImport(_dll_name, EntryPoint="XGetKeyboardMapping")]
|
[DllImport(_dll_name, EntryPoint = "XGetKeyboardMapping")]
|
||||||
internal static extern KeySym GetKeyboardMapping(Display display, KeyCode first_keycode, int keycode_count,
|
internal static extern KeySym GetKeyboardMapping(Display display, KeyCode first_keycode, int keycode_count,
|
||||||
ref int keysyms_per_keycode_return);
|
ref int keysyms_per_keycode_return);
|
||||||
|
|
||||||
|
@ -519,8 +524,11 @@ XF86VidModeGetGammaRampSize(
|
||||||
* */
|
* */
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
|
||||||
|
|
||||||
|
[DllImport(_dll_name, EntryPoint = "XLookupKeysym")]
|
||||||
|
internal static extern KeySym LookupKeysym(ref XKeyEvent key_event, int index);
|
||||||
|
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region X11 Structures
|
#region X11 Structures
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
keyboardDriver = new X11Keyboard(window);
|
keyboardDriver = new X11Keyboard(window);
|
||||||
*/
|
*/
|
||||||
|
window = new WindowInfo(parent);
|
||||||
keyboardDriver = new X11Keyboard(parent);
|
keyboardDriver = new X11Keyboard(parent);
|
||||||
API.SelectInput(parent.Display, parent.Handle,
|
API.SelectInput(parent.Display, parent.Handle,
|
||||||
EventMask.KeyReleaseMask | EventMask.KeyPressMask);
|
EventMask.KeyReleaseMask | EventMask.KeyPressMask);
|
||||||
|
@ -124,6 +124,12 @@ namespace OpenTK.Platform.X11
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ProcessEvents()
|
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
|
try
|
||||||
{
|
{
|
||||||
while (API.CheckIfEvent(window.Display, ref e, check, IntPtr.Zero))
|
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());
|
Debug.Print("DANGER: Possible callback exception: {0}", e.ToString());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
API.CheckEventPredicate check = KeyEventPredicate;
|
API.CheckEventPredicate check = KeyEventPredicate;
|
||||||
|
|
|
@ -130,11 +130,13 @@ namespace OpenTK.Platform.X11
|
||||||
/// <returns>True if the event was processed, false otherwise.</returns>
|
/// <returns>True if the event was processed, false otherwise.</returns>
|
||||||
internal bool ProcessKeyboardEvent(X11.XKeyEvent e)
|
internal bool ProcessKeyboardEvent(X11.XKeyEvent e)
|
||||||
{
|
{
|
||||||
int keysym = 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();
|
//int keysym2 = keysyms[(e.keycode - firstKeyCode) * keysyms_per_keycode].ToInt32();
|
||||||
bool pressed = e.type == XEventName.KeyPress;
|
bool pressed = e.type == XEventName.KeyPress;
|
||||||
|
|
||||||
switch (keysym)
|
IntPtr keysym = API.LookupKeysym(ref e, 0);
|
||||||
|
|
||||||
|
switch (keysym.ToInt64())
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
if (keymap.ContainsKey((XKey)keysym))
|
if (keymap.ContainsKey((XKey)keysym))
|
||||||
|
@ -143,7 +145,8 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
else
|
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;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue