Beispiel #1
0
        internal void Clear()
        {
            for (var Index = 0; Index < KeyCurState.Length; ++Index)
            {
                KeyCurState[Index]    = false;
                KeyPreState[Index]    = false;
                KeyPressedTime[Index] = 0;
            }

            KeyCode = LGuiKeys.None;

            for (var Index = 0; Index < MouseCurState.Length; ++Index)
            {
                MouseCurState[Index]    = false;
                MousePreState[Index]    = false;
                MousePressedTime[Index] = 0;
                MouseClickPos[Index]    = LGuiVec2.Zero;
            }

            MouseCurDeltaPos = LGuiVec2.Zero;
            MousePreDeltaPos = LGuiVec2.Zero;
            MouseButton      = LGuiMouseButtons.None;
            MousePos         = LGuiVec2.Zero;
            MouseWheel       = 0;
        }
Beispiel #2
0
        public void SetKeyState(LGuiKeys Key, bool IsKeyDown)
        {
            var Index = (int)Key;

            KeyPreState[Index] = KeyCurState[Index];
            KeyCurState[Index] = IsKeyDown;
            KeyCode            = IsKeyDown ? Key : LGuiKeys.None;
        }
Beispiel #3
0
        public bool IsKeyPressed(LGuiKeys Key)
        {
            var Index = (int)Key;

            return(IsKeyClick(Key) || (IsKeyDown(Key) && KeyPressedTime[Index] >= 0.5f));
        }
Beispiel #4
0
        public bool IsKeyClick(LGuiKeys Key)
        {
            var Index = (int)Key;

            return(!KeyPreState[Index] && KeyCurState[Index]);
        }
Beispiel #5
0
 public bool IsKeyUp(LGuiKeys Key)
 {
     return(!KeyCurState[(int)Key]);
 }
Beispiel #6
0
 public bool IsKeyDown(LGuiKeys Key)
 {
     return(KeyCurState[(int)Key]);
 }
        private static char ParseKeyCharacter(LGuiKeys KeyCode, bool Shift, bool CapsLock)
        {
            switch (KeyCode)
            {
            case LGuiKeys.A:
                return(Shift || CapsLock ? 'A' : 'a');

            case LGuiKeys.B:
                return(Shift || CapsLock ? 'B' : 'b');

            case LGuiKeys.C:
                return(Shift || CapsLock ? 'C' : 'c');

            case LGuiKeys.D:
                return(Shift || CapsLock ? 'D' : 'd');

            case LGuiKeys.E:
                return(Shift || CapsLock ? 'E' : 'e');

            case LGuiKeys.F:
                return(Shift || CapsLock ? 'F' : 'f');

            case LGuiKeys.G:
                return(Shift || CapsLock ? 'G' : 'g');

            case LGuiKeys.H:
                return(Shift || CapsLock ? 'H' : 'h');

            case LGuiKeys.I:
                return(Shift || CapsLock ? 'I' : 'i');

            case LGuiKeys.J:
                return(Shift || CapsLock ? 'J' : 'j');

            case LGuiKeys.K:
                return(Shift || CapsLock ? 'K' : 'k');

            case LGuiKeys.L:
                return(Shift || CapsLock ? 'L' : 'l');

            case LGuiKeys.M:
                return(Shift || CapsLock ? 'M' : 'm');

            case LGuiKeys.N:
                return(Shift || CapsLock ? 'N' : 'n');

            case LGuiKeys.O:
                return(Shift || CapsLock ? 'O' : 'o');

            case LGuiKeys.P:
                return(Shift || CapsLock ? 'P' : 'p');

            case LGuiKeys.Q:
                return(Shift || CapsLock ? 'Q' : 'q');

            case LGuiKeys.R:
                return(Shift || CapsLock ? 'R' : 'r');

            case LGuiKeys.S:
                return(Shift || CapsLock ? 'S' : 's');

            case LGuiKeys.T:
                return(Shift || CapsLock ? 'T' : 't');

            case LGuiKeys.U:
                return(Shift || CapsLock ? 'U' : 'u');

            case LGuiKeys.V:
                return(Shift || CapsLock ? 'V' : 'v');

            case LGuiKeys.W:
                return(Shift || CapsLock ? 'W' : 'w');

            case LGuiKeys.X:
                return(Shift || CapsLock ? 'X' : 'x');

            case LGuiKeys.Y:
                return(Shift || CapsLock ? 'Y' : 'y');

            case LGuiKeys.Z:
                return(Shift || CapsLock ? 'Z' : 'z');

            case LGuiKeys.D1:
                return(Shift ? '!' : '1');

            case LGuiKeys.D2:
                return(Shift ? '@' : '2');

            case LGuiKeys.D3:
                return(Shift ? '#' : '3');

            case LGuiKeys.D4:
                return(Shift ? '$' : '4');

            case LGuiKeys.D5:
                return(Shift ? '%' : '5');

            case LGuiKeys.D6:
                return(Shift ? '^' : '6');

            case LGuiKeys.D7:
                return(Shift ? '&' : '7');

            case LGuiKeys.D8:
                return(Shift ? '*' : '8');

            case LGuiKeys.D9:
                return(Shift ? '(' : '9');

            case LGuiKeys.D0:
                return(Shift ? ')' : '0');

            case LGuiKeys.DTilde:
                return(Shift ? '~' : '`');

            case LGuiKeys.DMinus:
                return(Shift ? '_' : '-');

            case LGuiKeys.DPlus:
                return(Shift ? '+' : '=');

            case LGuiKeys.DPipe:
                return(Shift ? '|' : '\\');

            case LGuiKeys.DOpenBrackets:
                return(Shift ? '{' : '[');

            case LGuiKeys.DCloseBrackets:
                return(Shift ? '}' : ']');

            case LGuiKeys.DSemicolon:
                return(Shift ? ':' : ';');

            case LGuiKeys.DQuotes:
                return(Shift ? '"' : '\'');

            case LGuiKeys.DComma:
                return(Shift ? '<' : ',');

            case LGuiKeys.DPeriod:
                return(Shift ? '>' : '.');

            case LGuiKeys.DQuestion:
                return(Shift ? '?' : '/');

            case LGuiKeys.Enter:
                return('\n');

            case LGuiKeys.Space:
                return(' ');

            case LGuiKeys.NumPad0:
                return('0');

            case LGuiKeys.NumPad1:
                return('1');

            case LGuiKeys.NumPad2:
                return('2');

            case LGuiKeys.NumPad3:
                return('3');

            case LGuiKeys.NumPad4:
                return('4');

            case LGuiKeys.NumPad5:
                return('5');

            case LGuiKeys.NumPad6:
                return('6');

            case LGuiKeys.NumPad7:
                return('7');

            case LGuiKeys.NumPad8:
                return('8');

            case LGuiKeys.NumPad9:
                return('9');
            }

            return((char)0);
        }