Example #1
0
        public KeyEvent ConvertScanCode(byte scan2, bool ctrl, bool shift, bool alt, bool num, bool caps, bool scroll)
        {
            var keyev = new KeyEvent();
            var found = false;
            if (scan2 == 0)
            {
                found = true;
                return keyev;
            }
            var scan = scan2;
            if (alt) keyev.Modifiers |= ConsoleModifiers.Alt;
            if (ctrl) keyev.Modifiers |= ConsoleModifiers.Control;
            if (shift) keyev.Modifiers |= ConsoleModifiers.Shift;

            keyev.Type = (scan & 0x80) != 0 ? KeyEvent.KeyEventType.Break : KeyEvent.KeyEventType.Make;
            if ((scan & 0x80) != 0) scan = (byte)(scan ^ 0x80);
            Debugger.DoSend("Number of keys: ");
            Debugger.DoSendNumber((uint) _keys.Count);
            for (var index = 0; index < _keys.Count; index++)
            {
                var t = _keys[index];
                if (t == null)
                {
                    Debugger.DoSend("Key received but item is NULL");
                    continue;
                }
                if (t.Scancode == scan)
                {
                    found = true;
                    var map = t;
                    var key = '\0';

                    if (shift)
                    {
                        if (caps) key = map.ShiftCaps;
                        else if (num) key = map.ShiftNum;
                        else key = map.Shift;
                    }
                    else if (caps)
                    {
                        key = map.Caps;
                    }
                    else if (num)
                    {
                        key = map.Num;
                    }
                    else
                    {
                        key = map.Value;
                    }

                    keyev.KeyChar = key;
                    keyev.Key = num ? t.NumLockKey : t.Key;
                    break;
                }
            }
            return found ? keyev : null;
        }
Example #2
0
 public bool TryReadKey(out KeyEvent oKey)
 {
     if (mQueuedKeys.Count > 0)
     {
         oKey = mQueuedKeys.Dequeue();
         return true;
     }
     oKey = default(KeyEvent);
     return false;
 }
Example #3
0
 public bool GetKey(byte aScancode, bool released, out KeyEvent keyInfo)
 {
     keyInfo = KeyLayout.ConvertScanCode(aScancode, ControlPressed, ShiftPressed, AltPressed, Global.NumLock, Global.CapsLock, Global.ScrollLock);
     return keyInfo != null;
 }
Example #4
0
 protected void Enqueue(KeyEvent aKey)
 {
     mQueuedKeys.Enqueue(aKey);
 }
Example #5
0
 public bool GetKey(byte aScancode, bool released, out KeyEvent keyInfo)
 {
     if (KeyLayout == null)
     {
         Debugger.DoSend("No KeyLayout");
     }
     keyInfo = KeyLayout.ConvertScanCode(aScancode, ControlPressed, ShiftPressed, AltPressed, Global.NumLock, Global.CapsLock, Global.ScrollLock);
     return keyInfo != null;
 }
Example #6
0
 protected void Enqueue(KeyEvent aKey)
 {
     mQueuedKeys.Enqueue(aKey);
 }
Example #7
0
        public KeyEvent ConvertScanCode(byte scan2, bool ctrl, bool shift, bool alt, bool num, bool caps, bool scroll)
        {
            var keyev = new KeyEvent();
            var found = false;

            if (scan2 == 0)
            {
                found = true;
                return(keyev);
            }
            var scan = scan2;

            if (alt)
            {
                keyev.Modifiers |= ConsoleModifiers.Alt;
            }
            if (ctrl)
            {
                keyev.Modifiers |= ConsoleModifiers.Control;
            }
            if (shift)
            {
                keyev.Modifiers |= ConsoleModifiers.Shift;
            }

            keyev.Type = (scan & 0x80) != 0 ? KeyEvent.KeyEventType.Break : KeyEvent.KeyEventType.Make;
            if ((scan & 0x80) != 0)
            {
                scan = (byte)(scan ^ 0x80);
            }

            for (var index = 0; index < _keys.Count; index++)
            {
                var t = _keys[index];
                if (t.Scancode == scan)
                {
                    found = true;
                    var map = t;
                    var key = '\0';

                    if (shift)
                    {
                        if (caps)
                        {
                            key = map.ShiftCaps;
                        }
                        else if (num)
                        {
                            key = map.ShiftNum;
                        }
                        else
                        {
                            key = map.Shift;
                        }
                    }
                    else if (caps)
                    {
                        key = map.Caps;
                    }
                    else if (num)
                    {
                        key = map.Num;
                    }
                    else
                    {
                        key = map.Value;
                    }

                    keyev.KeyChar = key;
                    keyev.Key     = num ? t.NumLockKey : t.Key;
                    break;
                }
            }
            return(found ? keyev : null);
        }