Example #1
0
		/// <summary>
		/// Returns an array of values holding keys that are currently being pressed.
		/// </summary>
		/// <returns>The keys that are currently being pressed.</returns>
		public CCKeys[] GetPressedKeys()
		{
			var pressedKeys = KeyboardState.GetPressedKeys ();
            var pressed = new CCKeys[pressedKeys.Length];
            for (int k = 0; k < pressedKeys.Length; k++)
                pressed[k] = (CCKeys)pressedKeys[k];

			return pressed;
		}
        /// <summary>
        /// Returns an array of values holding keys that are currently being pressed.
        /// </summary>
        /// <returns>The keys that are currently being pressed.</returns>
        public                 CCKeys[] GetPressedKeys()
        {
            var pressedKeys = KeyboardState.GetPressedKeys();
            var pressed     = new CCKeys[pressedKeys.Length];

            for (int k = 0; k < pressedKeys.Length; k++)
            {
                pressed[k] = (CCKeys)pressedKeys[k];
            }

            return(pressed);
        }
        void OnKeyReleased(CCEventKeyboard eventKeyboard)
        {
            //CCLog.Log("On Released " + eventKeyboard.Keys);
            if (eventKeyboard.Keys == CCKeys.Back)
            {
                OnDeleteBackward();
            }
            else
            {
                keyState = eventKeyboard.KeyboardState;
                var charKey = ConvertKey(eventKeyboard.Keys, ShiftDown, false, false);
                if (charKey != (int)CCKeys.None)
                {
                    OnInsertText(new CCIMEKeybardEventArgs(charKey.ToString(), 1));
                }
            }

            lastPressedKey = CCKeys.None;
            if (AutoRepeat)
            {
                StopAutorepeat();
            }
        }
        void OnKeyPressed(CCEventKeyboard eventKeyboard)
        {
            lastPressedKey = CCKeys.None;

            if (eventKeyboard.Keys == CCKeys.Back)
            {
                lastPressedKey = eventKeyboard.Keys;
            }
            else
            {
                keyState = eventKeyboard.KeyboardState;
                var charKey = ConvertKey(eventKeyboard.Keys, ShiftDown, false, false);
                if (charKey != (int)CCKeys.None)
                {
                    lastPressedKey = eventKeyboard.Keys;
                }
            }

            //CCLog.Log("On Pressed " + lastPressedKey);
            if (AutoRepeat && lastPressedKey != CCKeys.None)
            {
                StartAutorepeat();
            }
        }
        public static char ConvertKey(CCKeys key, bool shift, bool capsLock, bool numLock)
        {

            switch (key)
            {

                case CCKeys.A: return ConvertToChar('a', shift, capsLock);
                case CCKeys.B: return ConvertToChar('b', shift, capsLock);
                case CCKeys.C: return ConvertToChar('c', shift, capsLock);
                case CCKeys.D: return ConvertToChar('d', shift, capsLock);
                case CCKeys.E: return ConvertToChar('e', shift, capsLock);
                case CCKeys.F: return ConvertToChar('f', shift, capsLock);
                case CCKeys.G: return ConvertToChar('g', shift, capsLock);
                case CCKeys.H: return ConvertToChar('h', shift, capsLock);
                case CCKeys.I: return ConvertToChar('i', shift, capsLock);
                case CCKeys.J: return ConvertToChar('j', shift, capsLock);
                case CCKeys.K: return ConvertToChar('k', shift, capsLock);
                case CCKeys.L: return ConvertToChar('l', shift, capsLock);
                case CCKeys.M: return ConvertToChar('m', shift, capsLock);
                case CCKeys.N: return ConvertToChar('n', shift, capsLock);
                case CCKeys.O: return ConvertToChar('o', shift, capsLock);
                case CCKeys.P: return ConvertToChar('p', shift, capsLock);
                case CCKeys.Q: return ConvertToChar('q', shift, capsLock);
                case CCKeys.R: return ConvertToChar('r', shift, capsLock);
                case CCKeys.S: return ConvertToChar('s', shift, capsLock);
                case CCKeys.T: return ConvertToChar('t', shift, capsLock);
                case CCKeys.U: return ConvertToChar('u', shift, capsLock);
                case CCKeys.V: return ConvertToChar('v', shift, capsLock);
                case CCKeys.W: return ConvertToChar('w', shift, capsLock);
                case CCKeys.X: return ConvertToChar('x', shift, capsLock);
                case CCKeys.Y: return ConvertToChar('y', shift, capsLock);
                case CCKeys.Z: return ConvertToChar('z', shift, capsLock);

                case CCKeys.D0: return (shift) ? ')' : '0';
                case CCKeys.D1: return (shift) ? '!' : '1';
                case CCKeys.D2: return (shift) ? '@' : '2';
                case CCKeys.D3: return (shift) ? '#' : '3';
                case CCKeys.D4: return (shift) ? '$' : '4';
                case CCKeys.D5: return (shift) ? '%' : '5';
                case CCKeys.D6: return (shift) ? '^' : '6';
                case CCKeys.D7: return (shift) ? '&' : '7';
                case CCKeys.D8: return (shift) ? '*' : '8';
                case CCKeys.D9: return (shift) ? '(' : '9';

                case CCKeys.Add: return '+';
                case CCKeys.Divide: return '/';
                case CCKeys.Multiply: return '*';
                case CCKeys.Subtract: return '-';

                case CCKeys.Space: return ' ';
                case CCKeys.Enter: return '\n';

                case CCKeys.Decimal: if (numLock && !shift) return '.'; break;
                case CCKeys.NumPad0: if (numLock && !shift) return '0'; break;
                case CCKeys.NumPad1: if (numLock && !shift) return '1'; break;
                case CCKeys.NumPad2: if (numLock && !shift) return '2'; break;
                case CCKeys.NumPad3: if (numLock && !shift) return '3'; break;
                case CCKeys.NumPad4: if (numLock && !shift) return '4'; break;
                case CCKeys.NumPad5: if (numLock && !shift) return '5'; break;
                case CCKeys.NumPad6: if (numLock && !shift) return '6'; break;
                case CCKeys.NumPad7: if (numLock && !shift) return '7'; break;
                case CCKeys.NumPad8: if (numLock && !shift) return '8'; break;
                case CCKeys.NumPad9: if (numLock && !shift) return '9'; break;

                case CCKeys.OemBackslash: return shift ? '|' : '\\';
                case CCKeys.OemCloseBrackets: return shift ? '}' : ']';
                case CCKeys.OemComma: return shift ? '<' : ',';
                case CCKeys.OemMinus: return shift ? '_' : '-';
                case CCKeys.OemOpenBrackets: return shift ? '{' : '[';
                case CCKeys.OemPeriod: return shift ? '>' : '.';
                case CCKeys.OemPipe: return shift ? '|' : '\\';
                case CCKeys.OemPlus: return shift ? '+' : '=';
                case CCKeys.OemQuestion: return shift ? '?' : '/';
                case CCKeys.OemQuotes: return shift ? '"' : '\'';
                case CCKeys.OemSemicolon: return shift ? ':' : ';';
                case CCKeys.OemTilde: return shift ? '~' : '`';
            }
            return (char)0;
        }
Example #6
0
 public void OnKeyRelease(CCKeys key)
 {
     m_inputs.Remove(key);
 }
        void OnKeyPressed(CCEventKeyboard eventKeyboard)
        {

            lastPressedKey = CCKeys.None;

            if (eventKeyboard.Keys == CCKeys.Back)
            {
                lastPressedKey = eventKeyboard.Keys;
            }
            else
            {
                keyState = eventKeyboard.KeyboardState;
                var charKey = ConvertKey(eventKeyboard.Keys, ShiftDown, false, false);
                if (charKey != (int)CCKeys.None)
                {
                    lastPressedKey = eventKeyboard.Keys;
                }
            }

            CCLog.Log("On Pressed " + lastPressedKey);
            if (AutoRepeat && lastPressedKey != CCKeys.None)
            {
                StartAutorepeat();
            }
        }
        void OnKeyReleased(CCEventKeyboard eventKeyboard)
        {
            CCLog.Log("On Released " + eventKeyboard.Keys);
            if (eventKeyboard.Keys == CCKeys.Back)
                OnDeleteBackward();
            else
            {
                keyState = eventKeyboard.KeyboardState;
                var charKey = ConvertKey(eventKeyboard.Keys, ShiftDown, false, false);
                if (charKey != (int)CCKeys.None)
                    OnInsertText(new CCIMEKeybardEventArgs(charKey.ToString(), 1));
            }

            lastPressedKey = CCKeys.None;
            if (AutoRepeat)
                StopAutorepeat();
        }
 /// <summary>
 /// Returns the state of a specified key.
 /// </summary>
 /// <param name="key">The key to query.</param>
 /// <returns>The state of the key.</returns>
 public                 CCKeyState this[CCKeys key]
 {
     get { return((CCKeyState)KeyboardState[(Microsoft.Xna.Framework.Input.Keys)key]); }
 }
 /// <summary>
 /// Gets whether given key is currently being pressed.
 /// </summary>
 /// <param name="key">The key to query.</param>
 /// <returns>true if the key is pressed; false otherwise.</returns>
 public bool IsKeyDown(CCKeys key)
 {
     return(KeyboardState.IsKeyDown((Keys)key));
 }
 /// <summary>
 /// Gets whether given key is currently being not pressed.
 /// </summary>
 /// <param name="key">The key to query.</param>
 /// <returns>true if the key is not pressed; false otherwise.</returns>
 public bool IsKeyUp(CCKeys key)
 {
     return(KeyboardState.IsKeyUp((Keys)key));;
 }
Example #12
0
		/// <summary>
		/// Gets whether given key is currently being pressed.
		/// </summary>
		/// <param name="key">The key to query.</param>
		/// <returns>true if the key is pressed; false otherwise.</returns>
		public bool IsKeyDown(CCKeys key)
		{
			return KeyboardState.IsKeyDown((Keys)key);
		}
Example #13
0
		/// <summary>
		/// Gets whether given key is currently being not pressed.
		/// </summary>
		/// <param name="key">The key to query.</param>
		/// <returns>true if the key is not pressed; false otherwise.</returns>
		public bool IsKeyUp(CCKeys key)
		{
			return KeyboardState.IsKeyUp((Keys)key);;
		}
Example #14
0
		/// <summary>
		/// Returns the state of a specified key.
		/// </summary>
		/// <param name="key">The key to query.</param>
		/// <returns>The state of the key.</returns>
		public CCKeyState this[CCKeys key]
		{
			get { return (CCKeyState)KeyboardState[(Microsoft.Xna.Framework.Input.Keys)key]; }
		}
Example #15
0
 public void OnKeyPress(CCKeys key)
 {
     m_inputs.Add(key);
 }
Example #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="keys"></param>
 /// <returns></returns>
 public bool IsKeyDown(CCKeys keys) => InputHelper.Instance.IsKeyIn(keys);
Example #17
0
 public static void OnKeyPress(CCKeys key) {
     Inputs.Add(key);
 }
Example #18
0
 public static bool IsKeyIn(CCKeys key) {
     return Inputs.Contains(key);
 }
Example #19
0
 public static void OnKeyRelease(CCKeys key) {
     Inputs.Remove(key);
 }
        public static char ConvertKey(CCKeys key, bool shift, bool capsLock, bool numLock)
        {
            switch (key)
            {
            case CCKeys.A: return(ConvertToChar('a', shift, capsLock));

            case CCKeys.B: return(ConvertToChar('b', shift, capsLock));

            case CCKeys.C: return(ConvertToChar('c', shift, capsLock));

            case CCKeys.D: return(ConvertToChar('d', shift, capsLock));

            case CCKeys.E: return(ConvertToChar('e', shift, capsLock));

            case CCKeys.F: return(ConvertToChar('f', shift, capsLock));

            case CCKeys.G: return(ConvertToChar('g', shift, capsLock));

            case CCKeys.H: return(ConvertToChar('h', shift, capsLock));

            case CCKeys.I: return(ConvertToChar('i', shift, capsLock));

            case CCKeys.J: return(ConvertToChar('j', shift, capsLock));

            case CCKeys.K: return(ConvertToChar('k', shift, capsLock));

            case CCKeys.L: return(ConvertToChar('l', shift, capsLock));

            case CCKeys.M: return(ConvertToChar('m', shift, capsLock));

            case CCKeys.N: return(ConvertToChar('n', shift, capsLock));

            case CCKeys.O: return(ConvertToChar('o', shift, capsLock));

            case CCKeys.P: return(ConvertToChar('p', shift, capsLock));

            case CCKeys.Q: return(ConvertToChar('q', shift, capsLock));

            case CCKeys.R: return(ConvertToChar('r', shift, capsLock));

            case CCKeys.S: return(ConvertToChar('s', shift, capsLock));

            case CCKeys.T: return(ConvertToChar('t', shift, capsLock));

            case CCKeys.U: return(ConvertToChar('u', shift, capsLock));

            case CCKeys.V: return(ConvertToChar('v', shift, capsLock));

            case CCKeys.W: return(ConvertToChar('w', shift, capsLock));

            case CCKeys.X: return(ConvertToChar('x', shift, capsLock));

            case CCKeys.Y: return(ConvertToChar('y', shift, capsLock));

            case CCKeys.Z: return(ConvertToChar('z', shift, capsLock));

            case CCKeys.D0: return((shift) ? ')' : '0');

            case CCKeys.D1: return((shift) ? '!' : '1');

            case CCKeys.D2: return((shift) ? '@' : '2');

            case CCKeys.D3: return((shift) ? '#' : '3');

            case CCKeys.D4: return((shift) ? '$' : '4');

            case CCKeys.D5: return((shift) ? '%' : '5');

            case CCKeys.D6: return((shift) ? '^' : '6');

            case CCKeys.D7: return((shift) ? '&' : '7');

            case CCKeys.D8: return((shift) ? '*' : '8');

            case CCKeys.D9: return((shift) ? '(' : '9');

            case CCKeys.Add: return('+');

            case CCKeys.Divide: return('/');

            case CCKeys.Multiply: return('*');

            case CCKeys.Subtract: return('-');

            case CCKeys.Space: return(' ');

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

            case CCKeys.Decimal: if (numLock && !shift)
                {
                    return('.');
                }
                break;

            case CCKeys.NumPad0: if (numLock && !shift)
                {
                    return('0');
                }
                break;

            case CCKeys.NumPad1: if (numLock && !shift)
                {
                    return('1');
                }
                break;

            case CCKeys.NumPad2: if (numLock && !shift)
                {
                    return('2');
                }
                break;

            case CCKeys.NumPad3: if (numLock && !shift)
                {
                    return('3');
                }
                break;

            case CCKeys.NumPad4: if (numLock && !shift)
                {
                    return('4');
                }
                break;

            case CCKeys.NumPad5: if (numLock && !shift)
                {
                    return('5');
                }
                break;

            case CCKeys.NumPad6: if (numLock && !shift)
                {
                    return('6');
                }
                break;

            case CCKeys.NumPad7: if (numLock && !shift)
                {
                    return('7');
                }
                break;

            case CCKeys.NumPad8: if (numLock && !shift)
                {
                    return('8');
                }
                break;

            case CCKeys.NumPad9: if (numLock && !shift)
                {
                    return('9');
                }
                break;

            case CCKeys.OemBackslash: return(shift ? '|' : '\\');

            case CCKeys.OemCloseBrackets: return(shift ? '}' : ']');

            case CCKeys.OemComma: return(shift ? '<' : ',');

            case CCKeys.OemMinus: return(shift ? '_' : '-');

            case CCKeys.OemOpenBrackets: return(shift ? '{' : '[');

            case CCKeys.OemPeriod: return(shift ? '>' : '.');

            case CCKeys.OemPipe: return(shift ? '|' : '\\');

            case CCKeys.OemPlus: return(shift ? '+' : '=');

            case CCKeys.OemQuestion: return(shift ? '?' : '/');

            case CCKeys.OemQuotes: return(shift ? '"' : '\'');

            case CCKeys.OemSemicolon: return(shift ? ':' : ';');

            case CCKeys.OemTilde: return(shift ? '~' : '`');
            }
            return((char)0);
        }
Example #21
0
 public bool IsKeyIn(CCKeys key)
 {
     return(m_inputs.Contains(key));
 }