示例#1
0
 /// <summary>
 /// Translates alphanumeric OpenTK key code to character value.
 /// </summary>
 /// <param name="key">OpenTK key code.</param>
 /// <returns>Translated character.</returns>
 private static char TranslateChar(OpenTKKey key)
 {
     if (key >= OpenTKKey.A && key <= OpenTKKey.Z)
     {
         return((char)('a' + ((int)key - (int)OpenTKKey.A)));
     }
     return(' ');
 }
示例#2
0
        //public bool ProcessKeyUp(EventArgs args)
        public bool ProcessKeyUp(OpenTKKey key)
        {
            char ch = TranslateChar(key);

            Key iKey = TranslateKeyCode(key);

            return(m_Canvas.Input_Key(iKey, false));
        }
示例#3
0
 private static void HandleKeyUp(Key key)
 {
     if (CurrentKeys.Contains(key)) 
     {
         CurrentKeys.Remove(key);
     }
     if (!ReleasedKeys.Contains(key))
         ReleasedKeys.Add(key);
 }
示例#4
0
 private static void HandleKeyUp(Key key)
 {
     if (CurrentKeys.Contains(key))
     {
         CurrentKeys.Remove(key);
     }
     if (!ReleasedKeys.Contains(key))
     {
         ReleasedKeys.Add(key);
     }
 }
示例#5
0
 private static void HandleKeyDown(Key key)
 {
     if (!NewKeys.Contains(key) && !CurrentKeys.Contains(key))
     {
         NewKeys.Add(key);
     }
     if (!CurrentKeys.Contains(key))
     {
         CurrentKeys.Add(key);
     }
 }
示例#6
0
 private static void HandleKeyDown(Key key)
 {
     if (!NewKeys.Contains(key) && !CurrentKeys.Contains(key))
     {
         NewKeys.Add(key);
     }
     if (!CurrentKeys.Contains(key)) 
     {
         CurrentKeys.Add(key);
     }
 }
示例#7
0
 private void EntryField_OnTKKeyPress(TKKey key)
 {
     if (this.IsKeyboardEntry && this.IsKeyboardFocusWithin)
     {
         this.Dispatcher.Invoke(() =>
         {
             this.DisplayText = key.ToString();
             this.EntryText   = key.ToSHKeyCode().ToString();
             FieldSet         = true;
         });
     }
 }
示例#8
0
        /// <summary>
        /// Translates control key's OpenTK key code to GWEN's code.
        /// </summary>
        /// <param name="key">OpenTK key code.</param>
        /// <returns>GWEN key code.</returns>
        private Key TranslateKeyCode(OpenTKKey key)
        {
            switch (key)
            {
            case OpenTKKey.BackSpace: return(Key.Backspace);

            case OpenTKKey.Enter: return(Key.Return);

            case OpenTKKey.Escape: return(Key.Escape);

            case OpenTKKey.Tab: return(Key.Tab);

            case OpenTKKey.Space: return(Key.Space);

            case OpenTKKey.Up: return(Key.Up);

            case OpenTKKey.Down: return(Key.Down);

            case OpenTKKey.Left: return(Key.Left);

            case OpenTKKey.Right: return(Key.Right);

            case OpenTKKey.Home: return(Key.Home);

            case OpenTKKey.End: return(Key.End);

            case OpenTKKey.Delete: return(Key.Delete);

            case OpenTKKey.LControl:
                this.m_AltGr = true;
                return(Key.Control);

            case OpenTKKey.LAlt: return(Key.Alt);

            case OpenTKKey.LShift: return(Key.Shift);

            case OpenTKKey.RControl: return(Key.Control);

            case OpenTKKey.RAlt:
                if (this.m_AltGr)
                {
                    this.m_Canvas.Input_Key(Key.Control, false);
                }
                return(Key.Alt);

            case OpenTKKey.RShift: return(Key.Shift);
            }
            return(Key.Invalid);
        }
示例#9
0
        private int MapKey(OpenTK.Input.Key srcKey)
        {
            int key = (int)srcKey;

            key &= 255;

            if (key >= _KeyTable.Length)
            {
                return(0);
            }

            if (_KeyTable[key] == 0)
            {
                Con.DPrint("key 0x{0:X} has no translation\n", key);
            }

            return(_KeyTable[key]);
        }
示例#10
0
        public bool ProcessKeyDown(OpenTKKey key)
        {
            char ch = TranslateChar(key);

            if (InputHandler.DoSpecialKeys(m_Canvas, ch))
            {
                return(false);
            }

            /*
             * if (ch != ' ')
             * {
             *  m_Canvas.Input_Character(ch);
             * }
             */
            Key iKey = TranslateKeyCode(key);

            return(m_Canvas.Input_Key(iKey, true));
        }
示例#11
0
 public MenuButton(string text, Color4 textColour, Action <MenuButton> onActivate = null, RefVar boundVar = null, string description = null, Inp.Key hotkey = Inp.Key.Unknown, float width = -1f, Func <MenuButton, string> variableText = null, bool saveSettingsOnHotkey = false)
 {
     Text                 = text;
     OnActivate           = onActivate;
     Width                = width;
     LimitTextDrawWidth   = width >= 0f;
     TextColour           = textColour;
     BoundVar             = boundVar;
     VariableText         = variableText;
     Hotkey               = hotkey;
     SaveSettingsOnHotkey = saveSettingsOnHotkey;
     if (hotkey != Inp.Key.Unknown)
     {
         description = "Ctrl + " + hotkey + (description == null ? "" : "\n" + description);
     }
     if (description != null)
     {
         Description = Main.AddTextWrappingSeparators(DESCRIPTION_HEIGHT, DESCRIPTION_WRAP_WIDTH, description);
     }
 }
示例#12
0
 /********************
  *      MENU SYSTEM METHODS
  *********************/
 //
 // INITIALIZE THE MENU SYSTEM
 //
 private void Init()
 {
     Reset();
     // choose the text font size according to screen height
     // the boundaries follow approximately the progression
     // of font sizes defined in Graphics/Fonts.cs
     if (Screen.Height <= 512)
     {
         menuFont = Fonts.SmallFont;
     }
     else if (Screen.Height <= 680)
     {
         menuFont = Fonts.NormalFont;
     }
     else if (Screen.Height <= 890)
     {
         menuFont = Fonts.LargeFont;
     }
     else if (Screen.Height <= 1150)
     {
         menuFont = Fonts.VeryLargeFont;
     }
     else
     {
         menuFont = Fonts.EvenLargerFont;
     }
     em         = (int)menuFont.FontSize;
     lineHeight = (int)(em * LineSpacing);
     for (int i = 0; i < Interface.CurrentControls.Length; i++)
     {
         //Find the current menu back key- It's unlikely that we want to set a new key to this
         if (Interface.CurrentControls[i].Command == Interface.Command.MenuBack)
         {
             MenuBackKey = Interface.CurrentControls[i].Key;
             break;
         }
     }
     isInitialized = true;
 }
示例#13
0
 static void Map(VirtualKeyCode a, OpenTK.Input.Key b)
 {
     reverse.Add(a, b);
     lookup.Add(b, a);
 }
示例#14
0
 void Keyboard_KeyDown(OpenTK.Input.KeyboardDevice sender, OpenTK.Input.Key key)
 {
     ActualizarEstadoInput(key, true);
 }
示例#15
0
 void Keyboard_KeyUp(OpenTK.Input.KeyboardDevice sender, OpenTK.Input.Key key)
 {
     ActualizarEstadoInput(key, false);
 }
示例#16
0
        private void KeyEvent(OpenTK.Input.Key key, bool down)
        {
            int keyCode = (int)key;
            int cc;

            if (keyCode >= KEY_CODE_A && keyCode <= KEY_CODE_Z)
            {
                cc = keyCode - KEY_CODE_A + 65;
            }
            else if (keyCode >= KEY_CODE_F1 && keyCode <= KEY_CODE_F12)
            {
                if (this.altPressed && keyCode == KEY_CODE_F1 + 3)
                {
                    events.Enqueue(EXIT);
                    events.Enqueue(EXIT_ALT_F4);
                }
                cc = keyCode - KEY_CODE_F1 + 112;
            }
            else if (keyCode >= KEY_CODE_0 && keyCode <= KEY_CODE_9)
            {
                cc = keyCode - KEY_CODE_0 + 48;
            }
            else
            {
                switch (key)
                {
                case OpenTK.Input.Key.Space: cc = 32; break;

                case OpenTK.Input.Key.Enter:
                case OpenTK.Input.Key.KeypadEnter: cc = 13; break;

                case OpenTK.Input.Key.Tab: cc = 9; break;

                case OpenTK.Input.Key.Escape: cc = 27; break;

                case OpenTK.Input.Key.Left: cc = 37; break;

                case OpenTK.Input.Key.Right: cc = 39; break;

                case OpenTK.Input.Key.Up: cc = 38; break;

                case OpenTK.Input.Key.Down: cc = 40; break;

                case OpenTK.Input.Key.Comma: cc = 188; break;

                case OpenTK.Input.Key.Period: cc = 190; break;

                case OpenTK.Input.Key.Semicolon: cc = 186; break;

                case OpenTK.Input.Key.Quote: cc = 222; break;

                case OpenTK.Input.Key.Slash: cc = 191; break;

                case OpenTK.Input.Key.BackSlash: cc = 220; break;

                case OpenTK.Input.Key.BracketLeft: cc = 219; break;

                case OpenTK.Input.Key.BracketRight: cc = 221; break;

                case OpenTK.Input.Key.Minus: cc = 189; break;

                case OpenTK.Input.Key.Plus: cc = 187; break;

                case OpenTK.Input.Key.Tilde: cc = 192; break;

                case OpenTK.Input.Key.ControlLeft:
                case OpenTK.Input.Key.ControlRight: cc = 17; break;

                case OpenTK.Input.Key.ShiftLeft:
                case OpenTK.Input.Key.ShiftRight: cc = 16; break;

                case OpenTK.Input.Key.AltLeft:
                case OpenTK.Input.Key.AltRight: cc = 18; this.altPressed = down; break;

                case OpenTK.Input.Key.PageUp: cc = 33; break;

                case OpenTK.Input.Key.PageDown: cc = 34; break;

                case OpenTK.Input.Key.Home: cc = 36; break;

                case OpenTK.Input.Key.End: cc = 35; break;

                case OpenTK.Input.Key.Delete: cc = 46; break;

                case OpenTK.Input.Key.Insert: cc = 45; break;

                case OpenTK.Input.Key.BackSpace: cc = 8; break;

                case OpenTK.Input.Key.PrintScreen: cc = 44; break;

                case OpenTK.Input.Key.Pause: cc = 19; break;

                case OpenTK.Input.Key.WinLeft:
                case OpenTK.Input.Key.WinRight: cc = 91; break;

                case OpenTK.Input.Key.Menu: cc = 93; break;

                case OpenTK.Input.Key.CapsLock: cc = 20; break;

                case OpenTK.Input.Key.ScrollLock: cc = 145; break;

                case OpenTK.Input.Key.NumLock: cc = 144; break;

                default: return;
                }
            }
            events.Enqueue(KEY_EVENT);
            events.Enqueue(down ? 1 : 0);
            events.Enqueue(cc);
        }
示例#17
0
 public bool KeyUp(OpenTK.Input.Key key)
 {
     return(!curKeysDown[(int)key]);
 }
示例#18
0
 public static IGuiMenuItem SetHotKey(this IGuiMenuItem item, OpenTK.Input.Key hotKey)
 {
     item.ModifierKey = 0;
     item.HotKey      = hotKey;
     return(item);
 }
示例#19
0
 private static Key RemapKey(Key oldKey)
     => KeyRemappings.ContainsKey(oldKey) ? RemapKey(KeyRemappings[oldKey]) : oldKey;
示例#20
0
 public static bool IsKeyDown(Key k)
 {
     return CurrentKeys.Contains(k);
 }
示例#21
0
 public virtual void InputText(OpenTK.Input.Key key)
 {
 }
示例#22
0
 public static bool IsKeyDown(Key k)
 {
     return(CurrentKeys.Contains(k));
 }
示例#23
0
 private static Key RemapKey(Key oldKey)
 => KeyRemappings.ContainsKey(oldKey) ? RemapKey(KeyRemappings[oldKey]) : oldKey;
示例#24
0
 public bool KeyPressed(OpenTK.Input.Key key)
 {
     return((!prevKeysDown[(int)key]) && curKeysDown[(int)key]);
 }
示例#25
0
文件: Menu.cs 项目: leezer3/OpenBVE
		/********************
			MENU SYSTEM METHODS
		*********************/
		//
		// INITIALIZE THE MENU SYSTEM
		//
		private void Init()
		{
			Reset();
			// choose the text font size according to screen height
			// the boundaries follow approximately the progression
			// of font sizes defined in Graphics/Fonts.cs
			if (Screen.Height <= 512)		menuFont	= Fonts.SmallFont;
			else if (Screen.Height <= 680)	menuFont	= Fonts.NormalFont;
			else if (Screen.Height <= 890)	menuFont	= Fonts.LargeFont;
			else if (Screen.Height <= 1150)	menuFont	= Fonts.VeryLargeFont;
			else 							menuFont	= Fonts.EvenLargerFont;
			em				= (int)menuFont.FontSize;
			lineHeight		= (int)(em * LineSpacing);
			for(int i= 0; i < Interface.CurrentControls.Length; i++)
			{
				//Find the current menu back key- It's unlikely that we want to set a new key to this
				if(Interface.CurrentControls[i].Command == Interface.Command.MenuBack)
				{
					MenuBackKey = Interface.CurrentControls[i].Key;
					break;
				}
			}
			isInitialized	= true;
		}
示例#26
0
 public bool KeyReleased(OpenTK.Input.Key key)
 {
     return(prevKeysDown[(int)key] && (!curKeysDown[(int)key]));
 }