mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-08 23:15:41 +00:00
Renamed OpenTK.Input.Keys to OpenTK.Input.Key.
Added keymap to X11/X11Keyboard.cs (not complete). Added GetKeyboardMapping(), DisplayFlags() and XKey enum to OpenTK.Platform.X11.API.cs
This commit is contained in:
parent
95d5db5347
commit
22d4f1b3ce
|
@ -81,14 +81,14 @@ namespace Examples.Tutorial
|
|||
/// </remarks>
|
||||
public override void OnUpdateFrame()
|
||||
{
|
||||
if (Keyboard[0][OpenTK.Input.Keys.Escape])
|
||||
if (Keyboard[0][OpenTK.Input.Key.Escape])
|
||||
{
|
||||
this.Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Keyboard[0][OpenTK.Input.Keys.LeftAlt] || Keyboard[0][OpenTK.Input.Keys.RightAlt]) &&
|
||||
Keyboard[0][OpenTK.Input.Keys.Enter])
|
||||
if ((Keyboard[0][OpenTK.Input.Key.AltLeft] || Keyboard[0][OpenTK.Input.Key.AltRight]) &&
|
||||
Keyboard[0][OpenTK.Input.Key.Enter])
|
||||
{
|
||||
Fullscreen = !Fullscreen;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace Examples.Tutorial
|
|||
{
|
||||
base.OnUpdateFrame();
|
||||
|
||||
if (Keyboard[0][OpenTK.Input.Keys.Escape])
|
||||
if (Keyboard[0][OpenTK.Input.Key.Escape])
|
||||
{
|
||||
this.Exit();
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace Examples.Tutorial
|
|||
/// </remarks>
|
||||
public override void OnUpdateFrame()
|
||||
{
|
||||
if (Keyboard[0][OpenTK.Input.Keys.Escape])
|
||||
if (Keyboard[0][OpenTK.Input.Key.Escape])
|
||||
{
|
||||
this.Exit();
|
||||
return;
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace Examples.Tutorial
|
|||
{
|
||||
base.OnUpdateFrame();
|
||||
|
||||
if (Keyboard[0][OpenTK.Input.Keys.Escape])
|
||||
if (Keyboard[0][OpenTK.Input.Key.Escape])
|
||||
{
|
||||
this.Exit();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace OpenTK.Input
|
|||
{
|
||||
public interface IKeyboard : IInputDevice
|
||||
{
|
||||
bool this[Keys k] { get; }
|
||||
bool this[Key k] { get; }
|
||||
int NumberOfKeys { get; }
|
||||
int NumberOfFunctionKeys { get; }
|
||||
int NumberOfLeds { get; }
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace OpenTK.Input
|
|||
public class Keyboard : IKeyboard
|
||||
{
|
||||
//private IKeyboard keyboard;
|
||||
private bool[] keys = new bool[(int)Keys.MaxKeys];
|
||||
private bool[] keys = new bool[(int)Key.MaxKeys];
|
||||
private string description;
|
||||
private int numKeys, numFKeys, numLeds;
|
||||
private long devID;
|
||||
|
@ -49,7 +49,7 @@ namespace OpenTK.Input
|
|||
|
||||
#region --- IKeyboard members ---
|
||||
|
||||
public bool this[Keys k]
|
||||
public bool this[Key k]
|
||||
{
|
||||
get { return keys[(int)k]; }
|
||||
internal set
|
||||
|
@ -117,25 +117,26 @@ namespace OpenTK.Input
|
|||
}
|
||||
}
|
||||
|
||||
#region public enum Keys : int
|
||||
#region public enum Key : int
|
||||
|
||||
/// <summary>
|
||||
/// The available keyboard keys.
|
||||
/// </summary>
|
||||
public enum Keys : int
|
||||
public enum Key : int
|
||||
{
|
||||
// Modifiers
|
||||
LeftShift = 0,
|
||||
RightShift,
|
||||
LeftControl,
|
||||
RightControl,
|
||||
LeftAlt,
|
||||
RightAlt,
|
||||
LeftApp,
|
||||
RightApp,
|
||||
ShiftLeft = 0,
|
||||
ShiftRight,
|
||||
ControlLeft,
|
||||
ControlRight,
|
||||
AltLeft,
|
||||
AltRight,
|
||||
WinLeft,
|
||||
WinRight,
|
||||
Menu,
|
||||
|
||||
// Function keys (hopefully enough for most keyboards - mine has 26)
|
||||
// <keysymdef.h> on X11 reports up to 35 function keys.
|
||||
F1, F2, F3, F4,
|
||||
F5, F6, F7, F8,
|
||||
F9, F10, F11, F12,
|
||||
|
@ -144,6 +145,7 @@ namespace OpenTK.Input
|
|||
F21, F22, F23, F24,
|
||||
F25, F26, F27, F28,
|
||||
F29, F30, F31, F32,
|
||||
F33, F34, F35,
|
||||
|
||||
// Direction arrows
|
||||
Up,
|
||||
|
|
|
@ -2243,7 +2243,7 @@ namespace OpenTK.Platform.Windows
|
|||
public enum VirtualKeys : short
|
||||
{
|
||||
/*
|
||||
* Virtual Keys, Standard Set
|
||||
* Virtual Key, Standard Set
|
||||
*/
|
||||
LBUTTON = 0x01,
|
||||
RBUTTON = 0x02,
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace OpenTK.Platform.Windows
|
|||
private List<Keyboard> keyboards = new List<Keyboard>();
|
||||
private IntPtr windowHandle;
|
||||
|
||||
#region internal static Dictionary<API.VirtualKeys, Input.Keys> KeyMap
|
||||
#region internal static Dictionary<API.VirtualKeys, Input.Key> KeyMap
|
||||
|
||||
internal static Dictionary<API.VirtualKeys, Input.Keys> KeyMap =
|
||||
new Dictionary<API.VirtualKeys, Input.Keys>((int)API.VirtualKeys.Last);
|
||||
internal static Dictionary<API.VirtualKeys, Input.Key> KeyMap =
|
||||
new Dictionary<API.VirtualKeys, Input.Key>((int)API.VirtualKeys.Last);
|
||||
|
||||
private static bool keyMapExists;
|
||||
/// <summary>
|
||||
/// Initializes the map between VirtualKeys and OpenTK.Keys
|
||||
/// Initializes the map between VirtualKeys and OpenTK.Key
|
||||
/// </summary>
|
||||
private static void InitKeyMap()
|
||||
{
|
||||
|
@ -38,81 +38,81 @@ namespace OpenTK.Platform.Windows
|
|||
{
|
||||
try
|
||||
{
|
||||
KeyMap.Add(API.VirtualKeys.ESCAPE, Input.Keys.Escape);
|
||||
KeyMap.Add(API.VirtualKeys.ESCAPE, Input.Key.Escape);
|
||||
|
||||
// Function keys
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.F1 + i), Input.Keys.F1 + i);
|
||||
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.F1 + i), Input.Key.F1 + i);
|
||||
}
|
||||
|
||||
// Number keys (0-9)
|
||||
for (int i = 0; i <= 9; i++)
|
||||
{
|
||||
KeyMap.Add((API.VirtualKeys)(0x30 + i), Input.Keys.Number0 + i);
|
||||
KeyMap.Add((API.VirtualKeys)(0x30 + i), Input.Key.Number0 + i);
|
||||
}
|
||||
|
||||
// Letters (A-Z)
|
||||
for (int i = 0; i < 26; i++)
|
||||
{
|
||||
KeyMap.Add((API.VirtualKeys)(0x41 + i), Input.Keys.A + i);
|
||||
KeyMap.Add((API.VirtualKeys)(0x41 + i), Input.Key.A + i);
|
||||
}
|
||||
|
||||
KeyMap.Add(API.VirtualKeys.TAB, Input.Keys.Tab);
|
||||
KeyMap.Add(API.VirtualKeys.CAPITAL, Input.Keys.CapsLock);
|
||||
KeyMap.Add(API.VirtualKeys.LCONTROL, Input.Keys.LeftControl);
|
||||
KeyMap.Add(API.VirtualKeys.LSHIFT, Input.Keys.LeftShift);
|
||||
KeyMap.Add(API.VirtualKeys.LWIN, Input.Keys.LeftApp);
|
||||
KeyMap.Add(API.VirtualKeys.LMENU, Input.Keys.LeftAlt);
|
||||
KeyMap.Add(API.VirtualKeys.SPACE, Input.Keys.Space);
|
||||
KeyMap.Add(API.VirtualKeys.RMENU, Input.Keys.RightAlt);
|
||||
KeyMap.Add(API.VirtualKeys.RWIN, Input.Keys.RightApp);
|
||||
KeyMap.Add(API.VirtualKeys.APPS, Input.Keys.Menu);
|
||||
KeyMap.Add(API.VirtualKeys.RCONTROL, Input.Keys.RightControl);
|
||||
KeyMap.Add(API.VirtualKeys.RSHIFT, Input.Keys.RightShift);
|
||||
KeyMap.Add(API.VirtualKeys.RETURN, Input.Keys.Enter);
|
||||
KeyMap.Add(API.VirtualKeys.BACK, Input.Keys.Backspace);
|
||||
KeyMap.Add(API.VirtualKeys.TAB, Input.Key.Tab);
|
||||
KeyMap.Add(API.VirtualKeys.CAPITAL, Input.Key.CapsLock);
|
||||
KeyMap.Add(API.VirtualKeys.LCONTROL, Input.Key.ControlLeft);
|
||||
KeyMap.Add(API.VirtualKeys.LSHIFT, Input.Key.ShiftLeft);
|
||||
KeyMap.Add(API.VirtualKeys.LWIN, Input.Key.WinLeft);
|
||||
KeyMap.Add(API.VirtualKeys.LMENU, Input.Key.AltLeft);
|
||||
KeyMap.Add(API.VirtualKeys.SPACE, Input.Key.Space);
|
||||
KeyMap.Add(API.VirtualKeys.RMENU, Input.Key.AltRight);
|
||||
KeyMap.Add(API.VirtualKeys.RWIN, Input.Key.WinRight);
|
||||
KeyMap.Add(API.VirtualKeys.APPS, Input.Key.Menu);
|
||||
KeyMap.Add(API.VirtualKeys.RCONTROL, Input.Key.ControlRight);
|
||||
KeyMap.Add(API.VirtualKeys.RSHIFT, Input.Key.ShiftRight);
|
||||
KeyMap.Add(API.VirtualKeys.RETURN, Input.Key.Enter);
|
||||
KeyMap.Add(API.VirtualKeys.BACK, Input.Key.Backspace);
|
||||
|
||||
KeyMap.Add(API.VirtualKeys.OEM_1, Input.Keys.Semicolon); // Varies by keyboard, ;: on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_2, Input.Keys.Slash); // Varies by keyboard, /? on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_3, Input.Keys.Tilde); // Varies by keyboard, `~ on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_4, Input.Keys.LeftBracket); // Varies by keyboard, [{ on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_5, Input.Keys.BackSlash); // Varies by keyboard, \| on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_6, Input.Keys.RightBracket); // Varies by keyboard, ]} on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_7, Input.Keys.Quote); // Varies by keyboard, '" on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_PLUS, Input.Keys.Plus); // Invariant: +
|
||||
KeyMap.Add(API.VirtualKeys.OEM_COMMA, Input.Keys.Comma); // Invariant: ,
|
||||
KeyMap.Add(API.VirtualKeys.OEM_MINUS, Input.Keys.Minus); // Invariant: -
|
||||
KeyMap.Add(API.VirtualKeys.OEM_PERIOD, Input.Keys.Period); // Invariant: .
|
||||
KeyMap.Add(API.VirtualKeys.OEM_1, Input.Key.Semicolon); // Varies by keyboard, ;: on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_2, Input.Key.Slash); // Varies by keyboard, /? on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_3, Input.Key.Tilde); // Varies by keyboard, `~ on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_4, Input.Key.LeftBracket); // Varies by keyboard, [{ on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_5, Input.Key.BackSlash); // Varies by keyboard, \| on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_6, Input.Key.RightBracket); // Varies by keyboard, ]} on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_7, Input.Key.Quote); // Varies by keyboard, '" on Win2K/US
|
||||
KeyMap.Add(API.VirtualKeys.OEM_PLUS, Input.Key.Plus); // Invariant: +
|
||||
KeyMap.Add(API.VirtualKeys.OEM_COMMA, Input.Key.Comma); // Invariant: ,
|
||||
KeyMap.Add(API.VirtualKeys.OEM_MINUS, Input.Key.Minus); // Invariant: -
|
||||
KeyMap.Add(API.VirtualKeys.OEM_PERIOD, Input.Key.Period); // Invariant: .
|
||||
|
||||
KeyMap.Add(API.VirtualKeys.HOME, Input.Keys.Home);
|
||||
KeyMap.Add(API.VirtualKeys.END, Input.Keys.End);
|
||||
KeyMap.Add(API.VirtualKeys.DELETE, Input.Keys.Delete);
|
||||
KeyMap.Add(API.VirtualKeys.PRIOR, Input.Keys.PageUp);
|
||||
KeyMap.Add(API.VirtualKeys.NEXT, Input.Keys.PageDown);
|
||||
KeyMap.Add(API.VirtualKeys.PRINT, Input.Keys.PrintScreen);
|
||||
KeyMap.Add(API.VirtualKeys.PAUSE, Input.Keys.Pause);
|
||||
KeyMap.Add(API.VirtualKeys.NUMLOCK, Input.Keys.NumLock);
|
||||
KeyMap.Add(API.VirtualKeys.HOME, Input.Key.Home);
|
||||
KeyMap.Add(API.VirtualKeys.END, Input.Key.End);
|
||||
KeyMap.Add(API.VirtualKeys.DELETE, Input.Key.Delete);
|
||||
KeyMap.Add(API.VirtualKeys.PRIOR, Input.Key.PageUp);
|
||||
KeyMap.Add(API.VirtualKeys.NEXT, Input.Key.PageDown);
|
||||
KeyMap.Add(API.VirtualKeys.PRINT, Input.Key.PrintScreen);
|
||||
KeyMap.Add(API.VirtualKeys.PAUSE, Input.Key.Pause);
|
||||
KeyMap.Add(API.VirtualKeys.NUMLOCK, Input.Key.NumLock);
|
||||
|
||||
KeyMap.Add(API.VirtualKeys.SLEEP, Input.Keys.Sleep);
|
||||
KeyMap.Add(API.VirtualKeys.SLEEP, Input.Key.Sleep);
|
||||
|
||||
// Keypad
|
||||
for (int i = 0; i <= 9; i++)
|
||||
{
|
||||
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.NUMPAD0 + i), Input.Keys.Keypad0 + i);
|
||||
KeyMap.Add((API.VirtualKeys)((int)API.VirtualKeys.NUMPAD0 + i), Input.Key.Keypad0 + i);
|
||||
|
||||
}
|
||||
KeyMap.Add(API.VirtualKeys.DECIMAL, Input.Keys.KeypadDecimal);
|
||||
KeyMap.Add(API.VirtualKeys.ADD, Input.Keys.KeypadAdd);
|
||||
KeyMap.Add(API.VirtualKeys.SUBTRACT, Input.Keys.KeypadSubtract);
|
||||
KeyMap.Add(API.VirtualKeys.DIVIDE, Input.Keys.KeypadDivide);
|
||||
KeyMap.Add(API.VirtualKeys.MULTIPLY, Input.Keys.KeypadMultiply);
|
||||
KeyMap.Add(API.VirtualKeys.DECIMAL, Input.Key.KeypadDecimal);
|
||||
KeyMap.Add(API.VirtualKeys.ADD, Input.Key.KeypadAdd);
|
||||
KeyMap.Add(API.VirtualKeys.SUBTRACT, Input.Key.KeypadSubtract);
|
||||
KeyMap.Add(API.VirtualKeys.DIVIDE, Input.Key.KeypadDivide);
|
||||
KeyMap.Add(API.VirtualKeys.MULTIPLY, Input.Key.KeypadMultiply);
|
||||
|
||||
// Navigation
|
||||
KeyMap.Add(API.VirtualKeys.UP, Input.Keys.Up);
|
||||
KeyMap.Add(API.VirtualKeys.DOWN, Input.Keys.Down);
|
||||
KeyMap.Add(API.VirtualKeys.LEFT, Input.Keys.Left);
|
||||
KeyMap.Add(API.VirtualKeys.RIGHT, Input.Keys.Right);
|
||||
KeyMap.Add(API.VirtualKeys.UP, Input.Key.Up);
|
||||
KeyMap.Add(API.VirtualKeys.DOWN, Input.Key.Down);
|
||||
KeyMap.Add(API.VirtualKeys.LEFT, Input.Key.Left);
|
||||
KeyMap.Add(API.VirtualKeys.RIGHT, Input.Key.Right);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
|
@ -282,15 +282,15 @@ namespace OpenTK.Platform.Windows
|
|||
switch (rin.Data.Keyboard.VKey)
|
||||
{
|
||||
case API.VirtualKeys.SHIFT:
|
||||
keyboards[0][Input.Keys.LeftShift] = keyboards[0][Input.Keys.RightShift] = pressed;
|
||||
keyboards[0][Input.Key.ShiftLeft] = keyboards[0][Input.Key.ShiftRight] = pressed;
|
||||
return false;
|
||||
|
||||
case API.VirtualKeys.CONTROL:
|
||||
keyboards[0][Input.Keys.LeftControl] = keyboards[0][Input.Keys.RightControl] = pressed;
|
||||
keyboards[0][Input.Key.ControlLeft] = keyboards[0][Input.Key.ControlRight] = pressed;
|
||||
return false;
|
||||
|
||||
case API.VirtualKeys.MENU:
|
||||
keyboards[0][Input.Keys.LeftAlt] = keyboards[0][Input.Keys.RightAlt] = pressed;
|
||||
keyboards[0][Input.Key.AltLeft] = keyboards[0][Input.Key.AltRight] = pressed;
|
||||
return false;
|
||||
|
||||
default:
|
||||
|
|
|
@ -27,11 +27,8 @@ namespace OpenTK.Platform.X11
|
|||
using Atom = System.IntPtr;
|
||||
using VisualID = System.IntPtr;
|
||||
using Time = System.UInt32;
|
||||
using KeyCode = System.IntPtr; /* In order to use IME, the Macintosh needs
|
||||
* to pack 3 bytes into the keyCode field in
|
||||
* the XEvent. In the real X.h, a KeyCode is
|
||||
* defined as a short, which wouldn't be big
|
||||
* enough. */
|
||||
using KeyCode = System.Byte; // Or maybe ushort?
|
||||
|
||||
using Display = System.IntPtr;
|
||||
|
||||
#endregion
|
||||
|
@ -185,29 +182,56 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
#endregion
|
||||
|
||||
#region Pointer and Keyboard grabbing
|
||||
#region Pointer and Keyboard functions
|
||||
|
||||
[DllImport(_dll_name, EntryPoint = "XGrabPointer")]
|
||||
extern internal static ErrorCodes XGrabPointer(
|
||||
Display display,
|
||||
IntPtr grab_window,
|
||||
bool owner_events, int event_mask,
|
||||
GrabMode pointer_mode,
|
||||
GrabMode keyboard_mode,
|
||||
IntPtr confine_to,
|
||||
IntPtr cursor,
|
||||
int time
|
||||
);
|
||||
extern internal static ErrorCodes GrabPointer(Display display, IntPtr grab_window,
|
||||
bool owner_events, int event_mask, GrabMode pointer_mode, GrabMode keyboard_mode,
|
||||
IntPtr confine_to, IntPtr cursor, int time);
|
||||
|
||||
[DllImport(_dll_name, EntryPoint = "XUngrabPointer")]
|
||||
extern internal static ErrorCodes XUngrabPointer(Display display, int time);
|
||||
extern internal static ErrorCodes UngrabPointer(Display display, int time);
|
||||
|
||||
[DllImport(_dll_name, EntryPoint = "XGrabKeyboard")]
|
||||
extern internal static ErrorCodes XGrabKeyboard(Display display, IntPtr grab_window,
|
||||
extern internal static ErrorCodes GrabKeyboard(Display display, IntPtr grab_window,
|
||||
bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode, int time);
|
||||
|
||||
[DllImport(_dll_name, EntryPoint = "XUngrabKeyboard")]
|
||||
extern internal static void XUngrabKeyboard(Display display, int time);
|
||||
extern internal static void UngrabKeyboard(Display display, int time);
|
||||
|
||||
/// <summary>
|
||||
/// The XGetKeyboardMapping() function returns the symbols for the specified number of KeyCodes starting with first_keycode.
|
||||
/// </summary>
|
||||
/// <param name="display">Specifies the connection to the X server.</param>
|
||||
/// <param name="first_keycode">Specifies the first KeyCode that is to be returned.</param>
|
||||
/// <param name="keycode_count">Specifies the number of KeyCodes that are to be returned</param>
|
||||
/// <param name="keysyms_per_keycode_return">Returns the number of KeySyms per KeyCode.</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// <para>The value specified in first_keycode must be greater than or equal to min_keycode as returned by XDisplayKeycodes(), or a BadValue error results. In addition, the following expression must be less than or equal to max_keycode as returned by XDisplayKeycodes(): </para>
|
||||
/// <para>first_keycode + keycode_count - 1 </para>
|
||||
/// <para>If this is not the case, a BadValue error results. The number of elements in the KeySyms list is: </para>
|
||||
/// <para>keycode_count * keysyms_per_keycode_return </para>
|
||||
/// <para>KeySym number N, counting from zero, for KeyCode K has the following index in the list, counting from zero: </para>
|
||||
/// <para> (K - first_code) * keysyms_per_code_return + N </para>
|
||||
/// <para>The X server arbitrarily chooses the keysyms_per_keycode_return value to be large enough to report all requested symbols. A special KeySym value of NoSymbol is used to fill in unused elements for individual KeyCodes. To free the storage returned by XGetKeyboardMapping(), use XFree(). </para>
|
||||
/// <para>XGetKeyboardMapping() can generate a BadValue error.</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>
|
||||
/// </remarks>
|
||||
[DllImport(_dll_name, EntryPoint="XGetKeyboardMapping")]
|
||||
internal static extern KeySym GetKeyboardMapping(Display display, KeyCode first_keycode, int keycode_count,
|
||||
ref int keysyms_per_keycode_return);
|
||||
|
||||
/// <summary>
|
||||
/// The XDisplayKeycodes() function returns the min-keycodes and max-keycodes supported by the specified display.
|
||||
/// </summary>
|
||||
/// <param name="display">Specifies the connection to the X server.</param>
|
||||
/// <param name="min_keycodes_return">Returns the minimum number of KeyCodes</param>
|
||||
/// <param name="max_keycodes_return">Returns the maximum number of KeyCodes.</param>
|
||||
/// <remarks> The minimum number of KeyCodes returned is never less than 8, and the maximum number of KeyCodes returned is never greater than 255. Not all KeyCodes in this range are required to have corresponding keys.</remarks>
|
||||
[DllImport(_dll_name, EntryPoint = "XDisplayKeycodes")]
|
||||
internal static extern void DisplayKeycodes(Display display, ref int min_keycodes_return, ref int max_keycodes_return);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -927,7 +951,7 @@ XF86VidModeGetGammaRampSize(
|
|||
}
|
||||
|
||||
[Flags]
|
||||
internal enum CreateWindowMask : ulong
|
||||
internal enum CreateWindowMask : long//: ulong
|
||||
{
|
||||
CWBackPixmap = (1L<<0),
|
||||
CWBackPixel = (1L<<1),
|
||||
|
@ -945,15 +969,338 @@ XF86VidModeGetGammaRampSize(
|
|||
CWBackingPixel = (1L<<8),
|
||||
CWOverrideRedirect = (1L<<9),
|
||||
|
||||
/*
|
||||
CWY = (1<<1),
|
||||
CWWidth = (1<<2),
|
||||
CWHeight = (1<<3),
|
||||
CWBorderWidth = (1<<4),
|
||||
CWSibling = (1<<5),
|
||||
CWStackMode = (1<<6),
|
||||
*/
|
||||
//CWY = (1<<1),
|
||||
//CWWidth = (1<<2),
|
||||
//CWHeight = (1<<3),
|
||||
//CWBorderWidth = (1<<4),
|
||||
//CWSibling = (1<<5),
|
||||
//CWStackMode = (1<<6),
|
||||
}
|
||||
|
||||
#region XKey
|
||||
|
||||
/// <summary>
|
||||
/// Defines LATIN-1 and miscellaneous keys.
|
||||
/// </summary>
|
||||
internal enum XKey
|
||||
{
|
||||
/*
|
||||
* TTY function keys, cleverly chosen to map to ASCII, for convenience of
|
||||
* programming, but could have been arbitrary (at the cost of lookup
|
||||
* tables in client code).
|
||||
*/
|
||||
|
||||
BackSpace = 0xff08, /* Back space, back char */
|
||||
Tab = 0xff09,
|
||||
Linefeed = 0xff0a, /* Linefeed, LF */
|
||||
Clear = 0xff0b,
|
||||
Return = 0xff0d, /* Return, enter */
|
||||
Pause = 0xff13, /* Pause, hold */
|
||||
Scroll_Lock = 0xff14,
|
||||
Sys_Req = 0xff15,
|
||||
Escape = 0xff1b,
|
||||
Delete = 0xffff, /* Delete, rubout */
|
||||
|
||||
|
||||
|
||||
/* International & multi-key character composition */
|
||||
|
||||
Multi_key = 0xff20, /* Multi-key character compose */
|
||||
Codeinput = 0xff37,
|
||||
SingleCandidate = 0xff3c,
|
||||
MultipleCandidate = 0xff3d,
|
||||
PreviousCandidate = 0xff3e,
|
||||
|
||||
/* Japanese keyboard support */
|
||||
|
||||
Kanji = 0xff21, /* Kanji, Kanji convert */
|
||||
Muhenkan = 0xff22, /* Cancel Conversion */
|
||||
Henkan_Mode = 0xff23, /* Start/Stop Conversion */
|
||||
Henkan = 0xff23, /* Alias for Henkan_Mode */
|
||||
Romaji = 0xff24, /* to Romaji */
|
||||
Hiragana = 0xff25, /* to Hiragana */
|
||||
Katakana = 0xff26, /* to Katakana */
|
||||
Hiragana_Katakana = 0xff27, /* Hiragana/Katakana toggle */
|
||||
Zenkaku = 0xff28, /* to Zenkaku */
|
||||
Hankaku = 0xff29, /* to Hankaku */
|
||||
Zenkaku_Hankaku = 0xff2a, /* Zenkaku/Hankaku toggle */
|
||||
Touroku = 0xff2b, /* Add to Dictionary */
|
||||
Massyo = 0xff2c, /* Delete from Dictionary */
|
||||
Kana_Lock = 0xff2d, /* Kana Lock */
|
||||
Kana_Shift = 0xff2e, /* Kana Shift */
|
||||
Eisu_Shift = 0xff2f, /* Alphanumeric Shift */
|
||||
Eisu_toggle = 0xff30, /* Alphanumeric toggle */
|
||||
Kanji_Bangou = 0xff37, /* Codeinput */
|
||||
Zen_Koho = 0xff3d, /* Multiple/All Candidate(s) */
|
||||
Mae_Koho = 0xff3e, /* Previous Candidate */
|
||||
|
||||
/* 0xff31 thru 0xff3f are under XK_KOREAN */
|
||||
|
||||
/* Cursor control & motion */
|
||||
|
||||
Home = 0xff50,
|
||||
Left = 0xff51, /* Move left, left arrow */
|
||||
Up = 0xff52, /* Move up, up arrow */
|
||||
Right = 0xff53, /* Move right, right arrow */
|
||||
Down = 0xff54, /* Move down, down arrow */
|
||||
Prior = 0xff55, /* Prior, previous */
|
||||
Page_Up = 0xff55,
|
||||
Next = 0xff56, /* Next */
|
||||
Page_Down = 0xff56,
|
||||
End = 0xff57, /* EOL */
|
||||
Begin = 0xff58, /* BOL */
|
||||
|
||||
|
||||
/* Misc functions */
|
||||
|
||||
Select = 0xff60, /* Select, mark */
|
||||
Print = 0xff61,
|
||||
Execute = 0xff62, /* Execute, run, do */
|
||||
Insert = 0xff63, /* Insert, insert here */
|
||||
Undo = 0xff65,
|
||||
Redo = 0xff66, /* Redo, again */
|
||||
Menu = 0xff67,
|
||||
Find = 0xff68, /* Find, search */
|
||||
Cancel = 0xff69, /* Cancel, stop, abort, exit */
|
||||
Help = 0xff6a, /* Help */
|
||||
Break = 0xff6b,
|
||||
Mode_switch = 0xff7e, /* Character set switch */
|
||||
script_switch = 0xff7e, /* Alias for mode_switch */
|
||||
Num_Lock = 0xff7f,
|
||||
|
||||
/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */
|
||||
|
||||
KP_Space = 0xff80, /* Space */
|
||||
KP_Tab = 0xff89,
|
||||
KP_Enter = 0xff8d, /* Enter */
|
||||
KP_F1 = 0xff91, /* PF1, KP_A, ... */
|
||||
KP_F2 = 0xff92,
|
||||
KP_F3 = 0xff93,
|
||||
KP_F4 = 0xff94,
|
||||
KP_Home = 0xff95,
|
||||
KP_Left = 0xff96,
|
||||
KP_Up = 0xff97,
|
||||
KP_Right = 0xff98,
|
||||
KP_Down = 0xff99,
|
||||
KP_Prior = 0xff9a,
|
||||
KP_Page_Up = 0xff9a,
|
||||
KP_Next = 0xff9b,
|
||||
KP_Page_Down = 0xff9b,
|
||||
KP_End = 0xff9c,
|
||||
KP_Begin = 0xff9d,
|
||||
KP_Insert = 0xff9e,
|
||||
KP_Delete = 0xff9f,
|
||||
KP_Equal = 0xffbd, /* Equals */
|
||||
KP_Multiply = 0xffaa,
|
||||
KP_Add = 0xffab,
|
||||
KP_Separator = 0xffac, /* Separator, often comma */
|
||||
KP_Subtract = 0xffad,
|
||||
KP_Decimal = 0xffae,
|
||||
KP_Divide = 0xffaf,
|
||||
|
||||
KP_0 = 0xffb0,
|
||||
KP_1 = 0xffb1,
|
||||
KP_2 = 0xffb2,
|
||||
KP_3 = 0xffb3,
|
||||
KP_4 = 0xffb4,
|
||||
KP_5 = 0xffb5,
|
||||
KP_6 = 0xffb6,
|
||||
KP_7 = 0xffb7,
|
||||
KP_8 = 0xffb8,
|
||||
KP_9 = 0xffb9,
|
||||
|
||||
/*
|
||||
* Auxiliary functions; note the duplicate definitions for left and right
|
||||
* function keys; Sun keyboards and a few other manufacturers have such
|
||||
* function key groups on the left and/or right sides of the keyboard.
|
||||
* We've not found a keyboard with more than 35 function keys total.
|
||||
*/
|
||||
|
||||
F1 = 0xffbe,
|
||||
F2 = 0xffbf,
|
||||
F3 = 0xffc0,
|
||||
F4 = 0xffc1,
|
||||
F5 = 0xffc2,
|
||||
F6 = 0xffc3,
|
||||
F7 = 0xffc4,
|
||||
F8 = 0xffc5,
|
||||
F9 = 0xffc6,
|
||||
F10 = 0xffc7,
|
||||
F11 = 0xffc8,
|
||||
L1 = 0xffc8,
|
||||
F12 = 0xffc9,
|
||||
L2 = 0xffc9,
|
||||
F13 = 0xffca,
|
||||
L3 = 0xffca,
|
||||
F14 = 0xffcb,
|
||||
L4 = 0xffcb,
|
||||
F15 = 0xffcc,
|
||||
L5 = 0xffcc,
|
||||
F16 = 0xffcd,
|
||||
L6 = 0xffcd,
|
||||
F17 = 0xffce,
|
||||
L7 = 0xffce,
|
||||
F18 = 0xffcf,
|
||||
L8 = 0xffcf,
|
||||
F19 = 0xffd0,
|
||||
L9 = 0xffd0,
|
||||
F20 = 0xffd1,
|
||||
L10 = 0xffd1,
|
||||
F21 = 0xffd2,
|
||||
R1 = 0xffd2,
|
||||
F22 = 0xffd3,
|
||||
R2 = 0xffd3,
|
||||
F23 = 0xffd4,
|
||||
R3 = 0xffd4,
|
||||
F24 = 0xffd5,
|
||||
R4 = 0xffd5,
|
||||
F25 = 0xffd6,
|
||||
R5 = 0xffd6,
|
||||
F26 = 0xffd7,
|
||||
R6 = 0xffd7,
|
||||
F27 = 0xffd8,
|
||||
R7 = 0xffd8,
|
||||
F28 = 0xffd9,
|
||||
R8 = 0xffd9,
|
||||
F29 = 0xffda,
|
||||
R9 = 0xffda,
|
||||
F30 = 0xffdb,
|
||||
R10 = 0xffdb,
|
||||
F31 = 0xffdc,
|
||||
R11 = 0xffdc,
|
||||
F32 = 0xffdd,
|
||||
R12 = 0xffdd,
|
||||
F33 = 0xffde,
|
||||
R13 = 0xffde,
|
||||
F34 = 0xffdf,
|
||||
R14 = 0xffdf,
|
||||
F35 = 0xffe0,
|
||||
R15 = 0xffe0,
|
||||
|
||||
/* Modifiers */
|
||||
|
||||
Shift_L = 0xffe1, /* Left shift */
|
||||
Shift_R = 0xffe2, /* Right shift */
|
||||
Control_L = 0xffe3, /* Left control */
|
||||
Control_R = 0xffe4, /* Right control */
|
||||
Caps_Lock = 0xffe5, /* Caps lock */
|
||||
Shift_Lock = 0xffe6, /* Shift lock */
|
||||
|
||||
Meta_L = 0xffe7, /* Left meta */
|
||||
Meta_R = 0xffe8, /* Right meta */
|
||||
Alt_L = 0xffe9, /* Left alt */
|
||||
Alt_R = 0xffea, /* Right alt */
|
||||
Super_L = 0xffeb, /* Left super */
|
||||
Super_R = 0xffec, /* Right super */
|
||||
Hyper_L = 0xffed, /* Left hyper */
|
||||
Hyper_R = 0xffee, /* Right hyper */
|
||||
|
||||
/*
|
||||
* Latin 1
|
||||
* (ISO/IEC 8859-1 = Unicode U+0020..U+00FF)
|
||||
* Byte 3 = 0
|
||||
*/
|
||||
|
||||
space = 0x0020, /* U+0020 SPACE */
|
||||
exclam = 0x0021, /* U+0021 EXCLAMATION MARK */
|
||||
quotedbl = 0x0022, /* U+0022 QUOTATION MARK */
|
||||
numbersign = 0x0023, /* U+0023 NUMBER SIGN */
|
||||
dollar = 0x0024, /* U+0024 DOLLAR SIGN */
|
||||
percent = 0x0025, /* U+0025 PERCENT SIGN */
|
||||
ampersand = 0x0026, /* U+0026 AMPERSAND */
|
||||
apostrophe = 0x0027, /* U+0027 APOSTROPHE */
|
||||
quoteright = 0x0027, /* deprecated */
|
||||
parenleft = 0x0028, /* U+0028 LEFT PARENTHESIS */
|
||||
parenright = 0x0029, /* U+0029 RIGHT PARENTHESIS */
|
||||
asterisk = 0x002a, /* U+002A ASTERISK */
|
||||
plus = 0x002b, /* U+002B PLUS SIGN */
|
||||
comma = 0x002c, /* U+002C COMMA */
|
||||
minus = 0x002d, /* U+002D HYPHEN-MINUS */
|
||||
period = 0x002e, /* U+002E FULL STOP */
|
||||
slash = 0x002f, /* U+002F SOLIDUS */
|
||||
Number0 = 0x0030, /* U+0030 DIGIT ZERO */
|
||||
Number1 = 0x0031, /* U+0031 DIGIT ONE */
|
||||
Number2 = 0x0032, /* U+0032 DIGIT TWO */
|
||||
Number3 = 0x0033, /* U+0033 DIGIT THREE */
|
||||
Number4 = 0x0034, /* U+0034 DIGIT FOUR */
|
||||
Number5 = 0x0035, /* U+0035 DIGIT FIVE */
|
||||
Number6 = 0x0036, /* U+0036 DIGIT SIX */
|
||||
Number7 = 0x0037, /* U+0037 DIGIT SEVEN */
|
||||
Number8 = 0x0038, /* U+0038 DIGIT EIGHT */
|
||||
Number9 = 0x0039, /* U+0039 DIGIT NINE */
|
||||
colon = 0x003a, /* U+003A COLON */
|
||||
semicolon = 0x003b, /* U+003B SEMICOLON */
|
||||
less = 0x003c, /* U+003C LESS-THAN SIGN */
|
||||
equal = 0x003d, /* U+003D EQUALS SIGN */
|
||||
greater = 0x003e, /* U+003E GREATER-THAN SIGN */
|
||||
question = 0x003f, /* U+003F QUESTION MARK */
|
||||
at = 0x0040, /* U+0040 COMMERCIAL AT */
|
||||
A = 0x0041, /* U+0041 LATIN CAPITAL LETTER A */
|
||||
B = 0x0042, /* U+0042 LATIN CAPITAL LETTER B */
|
||||
C = 0x0043, /* U+0043 LATIN CAPITAL LETTER C */
|
||||
D = 0x0044, /* U+0044 LATIN CAPITAL LETTER D */
|
||||
E = 0x0045, /* U+0045 LATIN CAPITAL LETTER E */
|
||||
F = 0x0046, /* U+0046 LATIN CAPITAL LETTER F */
|
||||
G = 0x0047, /* U+0047 LATIN CAPITAL LETTER G */
|
||||
H = 0x0048, /* U+0048 LATIN CAPITAL LETTER H */
|
||||
I = 0x0049, /* U+0049 LATIN CAPITAL LETTER I */
|
||||
J = 0x004a, /* U+004A LATIN CAPITAL LETTER J */
|
||||
K = 0x004b, /* U+004B LATIN CAPITAL LETTER K */
|
||||
L = 0x004c, /* U+004C LATIN CAPITAL LETTER L */
|
||||
M = 0x004d, /* U+004D LATIN CAPITAL LETTER M */
|
||||
N = 0x004e, /* U+004E LATIN CAPITAL LETTER N */
|
||||
O = 0x004f, /* U+004F LATIN CAPITAL LETTER O */
|
||||
P = 0x0050, /* U+0050 LATIN CAPITAL LETTER P */
|
||||
Q = 0x0051, /* U+0051 LATIN CAPITAL LETTER Q */
|
||||
R = 0x0052, /* U+0052 LATIN CAPITAL LETTER R */
|
||||
S = 0x0053, /* U+0053 LATIN CAPITAL LETTER S */
|
||||
T = 0x0054, /* U+0054 LATIN CAPITAL LETTER T */
|
||||
U = 0x0055, /* U+0055 LATIN CAPITAL LETTER U */
|
||||
V = 0x0056, /* U+0056 LATIN CAPITAL LETTER V */
|
||||
W = 0x0057, /* U+0057 LATIN CAPITAL LETTER W */
|
||||
X = 0x0058, /* U+0058 LATIN CAPITAL LETTER X */
|
||||
Y = 0x0059, /* U+0059 LATIN CAPITAL LETTER Y */
|
||||
Z = 0x005a, /* U+005A LATIN CAPITAL LETTER Z */
|
||||
bracketleft = 0x005b, /* U+005B LEFT SQUARE BRACKET */
|
||||
backslash = 0x005c, /* U+005C REVERSE SOLIDUS */
|
||||
bracketright = 0x005d, /* U+005D RIGHT SQUARE BRACKET */
|
||||
asciicircum = 0x005e, /* U+005E CIRCUMFLEX ACCENT */
|
||||
underscore = 0x005f, /* U+005F LOW LINE */
|
||||
grave = 0x0060, /* U+0060 GRAVE ACCENT */
|
||||
quoteleft = 0x0060, /* deprecated */
|
||||
a = 0x0061, /* U+0061 LATIN SMALL LETTER A */
|
||||
b = 0x0062, /* U+0062 LATIN SMALL LETTER B */
|
||||
c = 0x0063, /* U+0063 LATIN SMALL LETTER C */
|
||||
d = 0x0064, /* U+0064 LATIN SMALL LETTER D */
|
||||
e = 0x0065, /* U+0065 LATIN SMALL LETTER E */
|
||||
f = 0x0066, /* U+0066 LATIN SMALL LETTER F */
|
||||
g = 0x0067, /* U+0067 LATIN SMALL LETTER G */
|
||||
h = 0x0068, /* U+0068 LATIN SMALL LETTER H */
|
||||
i = 0x0069, /* U+0069 LATIN SMALL LETTER I */
|
||||
j = 0x006a, /* U+006A LATIN SMALL LETTER J */
|
||||
k = 0x006b, /* U+006B LATIN SMALL LETTER K */
|
||||
l = 0x006c, /* U+006C LATIN SMALL LETTER L */
|
||||
m = 0x006d, /* U+006D LATIN SMALL LETTER M */
|
||||
n = 0x006e, /* U+006E LATIN SMALL LETTER N */
|
||||
o = 0x006f, /* U+006F LATIN SMALL LETTER O */
|
||||
p = 0x0070, /* U+0070 LATIN SMALL LETTER P */
|
||||
q = 0x0071, /* U+0071 LATIN SMALL LETTER Q */
|
||||
r = 0x0072, /* U+0072 LATIN SMALL LETTER R */
|
||||
s = 0x0073, /* U+0073 LATIN SMALL LETTER S */
|
||||
t = 0x0074, /* U+0074 LATIN SMALL LETTER T */
|
||||
u = 0x0075, /* U+0075 LATIN SMALL LETTER U */
|
||||
v = 0x0076, /* U+0076 LATIN SMALL LETTER V */
|
||||
w = 0x0077, /* U+0077 LATIN SMALL LETTER W */
|
||||
x = 0x0078, /* U+0078 LATIN SMALL LETTER X */
|
||||
y = 0x0079, /* U+0079 LATIN SMALL LETTER Y */
|
||||
z = 0x007a, /* U+007A LATIN SMALL LETTER Z */
|
||||
braceleft = 0x007b, /* U+007B LEFT CURLY BRACKET */
|
||||
bar = 0x007c, /* U+007C VERTICAL LINE */
|
||||
braceright = 0x007d, /* U+007D RIGHT CURLY BRACKET */
|
||||
asciitilde = 0x007e, /* U+007E TILDE */
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
|
||||
using OpenTK.Input;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenTK.Platform.X11
|
||||
{
|
||||
|
@ -12,15 +13,166 @@ namespace OpenTK.Platform.X11
|
|||
/// </summary>
|
||||
internal class X11Keyboard : IKeyboardDriver
|
||||
{
|
||||
internal X11Keyboard(WindowInfo windowHandle)
|
||||
/// <summary>
|
||||
/// The window receiving input events.
|
||||
/// </summary>
|
||||
WindowInfo window;
|
||||
|
||||
private bool[] keys = new bool[(int)OpenTK.Input.Key.MaxKeys];
|
||||
private List<Keyboard> keyboards;
|
||||
private static Dictionary<XKey, Key> keymap = new Dictionary<XKey, Key>((int)Key.MaxKeys);
|
||||
/// <summary>
|
||||
/// The smallest and largest KeyCode supported by the X server. Queried through API.DisplayKeycodes()
|
||||
/// </summary>
|
||||
int firstKeyCode, lastKeyCode;
|
||||
/// <summary>
|
||||
/// The number of KeySyms for each KeyCode.
|
||||
/// </summary>
|
||||
int keysyms_per_keycode;
|
||||
|
||||
IntPtr[] keysyms;
|
||||
|
||||
|
||||
|
||||
private static bool keymapExists;
|
||||
|
||||
#region private static void Initialize()
|
||||
|
||||
private static void Initialize()
|
||||
{
|
||||
if (!keymapExists)
|
||||
{
|
||||
keymap.Add(XKey.Shift_L, Key.ShiftLeft);
|
||||
keymap.Add(XKey.Shift_R, Key.ShiftRight);
|
||||
keymap.Add(XKey.Alt_L, Key.AltLeft);
|
||||
keymap.Add(XKey.Alt_R, Key.AltRight);
|
||||
keymap.Add(XKey.Control_L, Key.ControlLeft);
|
||||
keymap.Add(XKey.Control_R, Key.ControlRight);
|
||||
keymap.Add(XKey.Super_L, Key.WinLeft);
|
||||
keymap.Add(XKey.Super_R, Key.WinRight);
|
||||
keymap.Add(XKey.Meta_L, Key.WinLeft);
|
||||
keymap.Add(XKey.Meta_R, Key.WinRight);
|
||||
|
||||
keymap.Add(XKey.Menu, Key.Menu);
|
||||
keymap.Add(XKey.Print, Key.PrintScreen);
|
||||
keymap.Add(XKey.Tab, Key.Tab);
|
||||
keymap.Add(XKey.minus, Key.Minus);
|
||||
keymap.Add(XKey.plus, Key.Plus);
|
||||
//keymap.Add
|
||||
|
||||
//keymap.Add(XKey.Scroll_Lock, Key.Scr);
|
||||
keymap.Add(XKey.Caps_Lock, Key.CapsLock);
|
||||
keymap.Add(XKey.Num_Lock, Key.NumLock);
|
||||
|
||||
for (int i = (int)XKey.F1; i < (int)XKey.F35; i++)
|
||||
{
|
||||
keymap.Add((XKey)i, (Key)((int)Key.F1 + (i - (int)XKey.F1)));
|
||||
}
|
||||
|
||||
for (int i = (int)XKey.a; i < 26; i++)
|
||||
{
|
||||
keymap.Add((XKey)i, (Key)((int)Key.A + i));
|
||||
}
|
||||
|
||||
for (int i = (int)XKey.A; i < 26; i++)
|
||||
{
|
||||
keymap.Add((XKey)i, (Key)((int)Key.A + i));
|
||||
}
|
||||
|
||||
for (int i = (int)XKey.Number0; i <= 9; i++)
|
||||
{
|
||||
keymap.Add((XKey)i, (Key)((int)Key.Number0 + i));
|
||||
}
|
||||
|
||||
for (int i = (int)XKey.KP_0; i <= 9; i++)
|
||||
{
|
||||
keymap.Add((XKey)i, (Key)((int)Key.Keypad0 + i));
|
||||
}
|
||||
|
||||
keymap.Add(XKey.Pause, Key.Pause);
|
||||
keymap.Add(XKey.Break, Key.Pause);
|
||||
|
||||
keymapExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal X11Keyboard(WindowInfo window)
|
||||
{
|
||||
this.window = window;
|
||||
Initialize();
|
||||
|
||||
API.DisplayKeycodes(window.Display, ref firstKeyCode, ref lastKeyCode);
|
||||
IntPtr keysym_ptr = API.GetKeyboardMapping(window.Display, (byte)firstKeyCode,
|
||||
lastKeyCode - firstKeyCode + 1, ref keysyms_per_keycode);
|
||||
|
||||
Marshal.PtrToStructure(keysym_ptr, keysyms);
|
||||
API.Free(keysym_ptr);
|
||||
}
|
||||
|
||||
#region internal bool ProcessKeyboardEvent(API.RawInput rin)
|
||||
|
||||
/// <summary>
|
||||
/// Processes raw input events.
|
||||
/// </summary>
|
||||
/// <param name="rin"></param>
|
||||
/// <returns></returns>
|
||||
internal bool ProcessKeyboardEvent(X11.KeyEvent e)
|
||||
{
|
||||
return false;
|
||||
/*API.e.keycode
|
||||
switch (rin.Header.Type)
|
||||
{
|
||||
case API.RawInputDeviceType.KEYBOARD:
|
||||
bool pressed =
|
||||
rin.Data.Keyboard.Message == API.Constants.WM_KEYDOWN ||
|
||||
rin.Data.Keyboard.Message == API.Constants.WM_SYSKEYDOWN;
|
||||
|
||||
// Generic control, shift, alt keys may be sent instead of left/right.
|
||||
// It seems you have to explicitly register left/right events.
|
||||
switch (rin.Data.Keyboard.VKey)
|
||||
{
|
||||
case API.VirtualKeys.SHIFT:
|
||||
keyboards[0][Input.Key.ShiftLeft] = keyboards[0][Input.Key.ShiftRight] = pressed;
|
||||
return false;
|
||||
|
||||
case API.VirtualKeys.CONTROL:
|
||||
keyboards[0][Input.Key.ControlLeft] = keyboards[0][Input.Key.ControlRight] = pressed;
|
||||
return false;
|
||||
|
||||
case API.VirtualKeys.MENU:
|
||||
keyboards[0][Input.Key.AltLeft] = keyboards[0][Input.Key.AltRight] = pressed;
|
||||
return false;
|
||||
|
||||
default:
|
||||
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;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ApplicationException("Windows raw keyboard driver received invalid data.");
|
||||
}
|
||||
return false;*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- IKeyboardDriver Members ---
|
||||
|
||||
public IList<Keyboard> Keyboard
|
||||
{
|
||||
get { throw new Exception("The method or operation is not implemented."); }
|
||||
get { return keyboards; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue