public MyGuiLocalizedKeyboardState()
        {
            m_actualKeyboardState = MyWindowsKeyboard.GetCurrentState();

            if (m_localKeys == null)
            {
                m_localKeys = new HashSet <byte>();

                AddLocalKey(MyKeys.LeftControl);
                AddLocalKey(MyKeys.LeftAlt);
                AddLocalKey(MyKeys.LeftShift);
                AddLocalKey(MyKeys.RightAlt);
                AddLocalKey(MyKeys.RightControl);
                AddLocalKey(MyKeys.RightShift);
                AddLocalKey(MyKeys.Delete);
                AddLocalKey(MyKeys.NumPad0);
                AddLocalKey(MyKeys.NumPad1);
                AddLocalKey(MyKeys.NumPad2);
                AddLocalKey(MyKeys.NumPad3);
                AddLocalKey(MyKeys.NumPad4);
                AddLocalKey(MyKeys.NumPad5);
                AddLocalKey(MyKeys.NumPad6);
                AddLocalKey(MyKeys.NumPad7);
                AddLocalKey(MyKeys.NumPad8);
                AddLocalKey(MyKeys.NumPad9);
                AddLocalKey(MyKeys.Decimal);
                AddLocalKey(MyKeys.LeftWindows);
                AddLocalKey(MyKeys.RightWindows);
                AddLocalKey(MyKeys.Apps);
                AddLocalKey(MyKeys.Pause);
                AddLocalKey(MyKeys.Divide);
            }
        }
        public MyGuiLocalizedKeyboardState()
        {
            m_actualKeyboardState = MyWindowsKeyboard.GetCurrentState();

            if (m_localKeys == null)
            {
                m_localKeys = new HashSet<byte>();

                AddLocalKey(MyKeys.LeftControl);
                AddLocalKey(MyKeys.LeftAlt);
                AddLocalKey(MyKeys.LeftShift);
                AddLocalKey(MyKeys.RightAlt);
                AddLocalKey(MyKeys.RightControl);
                AddLocalKey(MyKeys.RightShift);
                AddLocalKey(MyKeys.Delete);
                AddLocalKey(MyKeys.NumPad0);
                AddLocalKey(MyKeys.NumPad1);
                AddLocalKey(MyKeys.NumPad2);
                AddLocalKey(MyKeys.NumPad3);
                AddLocalKey(MyKeys.NumPad4);
                AddLocalKey(MyKeys.NumPad5);
                AddLocalKey(MyKeys.NumPad6);
                AddLocalKey(MyKeys.NumPad7);
                AddLocalKey(MyKeys.NumPad8);
                AddLocalKey(MyKeys.NumPad9);
                AddLocalKey(MyKeys.Decimal);
                AddLocalKey(MyKeys.LeftWindows);
                AddLocalKey(MyKeys.RightWindows);
                AddLocalKey(MyKeys.Apps);
                AddLocalKey(MyKeys.Pause);
                AddLocalKey(MyKeys.Divide);
            }
        }
Пример #3
0
        public static MyKeyboardState GetCurrentState()
        {
            MyKeyboardBuffer buffer = new MyKeyboardBuffer();

            // Because GetKeyboardState cannot read from different than main thread

            /*
             * unsafe
             * {
             * byte* keyData = stackalloc byte[256];
             *
             * if (!GetKeyboardState(keyData))
             * {
             *  throw new InvalidOperationException("Could not read keyboard");
             * }
             *
             *
             * CopyBuffer(keyData, ref buffer);
             * }     */

            for (int i = 0; i < 256; i++)
            {
                if ((((ushort)GetAsyncKeyState(i)) >> 15) != 0)
                {
                    buffer.SetBit((byte)i, true);
                }
            }

            return(MyKeyboardState.FromBuffer(buffer));
        }
 public void ClearStates()
 {
     m_previousKeyboardState = m_actualKeyboardState;
     m_actualKeyboardState   = new MyKeyboardState();
 }
 public void UpdateStatesFromSnapshot(MyKeyboardState currentState, MyKeyboardState previousState)
 {
     m_previousKeyboardState = previousState;
     m_actualKeyboardState   = currentState;
 }
 // Used to simulate input for recordings
 public void UpdateStatesFromSnapshot(MyKeyboardState state)
 {
     m_previousKeyboardState = m_actualKeyboardState;
     m_actualKeyboardState   = state;
 }
 public void UpdateStates()
 {
     m_previousKeyboardState = m_actualKeyboardState;
     m_actualKeyboardState   = MyWindowsKeyboard.GetCurrentState();
 }
 public void ClearStates()
 {
     m_previousKeyboardState = new MyKeyboardState();
     m_actualKeyboardState = new MyKeyboardState();                        
 }
 // Used to simulate input for recordings
 public void UpdateStatesFromSnapshot(MyKeyboardState state)
 {
     m_previousKeyboardState = m_actualKeyboardState;
     m_actualKeyboardState = state;
 }
 public void UpdateStates()
 {
     m_previousKeyboardState = m_actualKeyboardState;
     m_actualKeyboardState = MyWindowsKeyboard.GetCurrentState();
 }
 public void UpdateStatesFromPlayback(MyKeyboardState currentKeyboard, MyKeyboardState previousKeyboard, MyMouseState currentMouse, MyMouseState previousMouse, JoystickState currentJoystick, JoystickState previousJoystick, int x, int y)
 {
     m_keyboardState.UpdateStatesFromSnapshot(currentKeyboard,previousKeyboard);
     m_previousMouseState = previousMouse;
     m_actualMouseState = currentMouse;
     m_actualJoystickState = currentJoystick;
     m_previousJoystickState = previousJoystick;
     m_absoluteMousePosition = new Vector2(x, y);
     if (m_gameWasFocused)
     {
         MyWindowsMouse.SetPosition(x, y);
     }
 }