示例#1
0
 public void ReadState(KeyboardState outState)
 {
     outState.CopyFrom(dummyState);
 }
示例#2
0
        internal void Update()
        {
                        #if ANDROID
            ProcessAndroidKeys();
                        #endif



#if FRB_MDX
            mBufferedData = null;

            if (mKeyboardDevice.Properties.BufferSize != 0)
            {
                do
                {// Try to get the current state
                    try
                    {
                        mKeyboardState = mKeyboardDevice.GetCurrentKeyboardState();
                        mBufferedData  = mKeyboardDevice.GetBufferedData();
                        break; // everything's ok, so we get out
                    }
                    catch (InputException)
                    {   // let the application handle Windows messages
                        try
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                        catch (Microsoft.DirectX.Direct3D.DeviceLostException)
                        {
                            break;
                            //					continue;
                        }
                        // Try to get reacquire the keyboard and don't care about exceptions
                        try { mKeyboardDevice.Acquire(); }
                        catch (InputLostException) { continue; }
                        catch (OtherApplicationHasPriorityException)
                        {
                            // this was continue, but we don't want to be stuck in this loop, so get out
                            //	continue;
                            break;
                        }
                    }
                }while (true); // Do this until it's successful
                //			Microsoft.DirectX.DirectInput.BufferedDataCollection tempCollection = keyboard.GetBufferedData();
            }

            for (int i = 0; i < Keyboard.NumberOfKeys; i++)
            {
                mKeysTyped[i] = false;
            }

            if (mBufferedData != null)
            {
                foreach (BufferedData d in mBufferedData)
                { // loop through all Data
                    if ((d.Data & 0x80) == 0)
                    {
                        continue;
                    }

                    // d.Offset corresponds with the Key values

                    // mark when the button was pushed so that repetitive input can be used
                    mLastTimeKeyTyped[d.Offset]  = TimeManager.CurrentTime;
                    mLastTypedFromPush[d.Offset] = true;
                    mKeysTyped[d.Offset]         = true;
                }
            }
#else
#if SILVERLIGHT
            mLastFrameKeyboardState.CopyFrom(mTemporaryKeyboardState);
            mTemporaryKeyboardState.CopyFrom(mKeyboardState);

            // This is automatic:
            mKeyboardState = Microsoft.Xna.Framework.Input.Keyboard.GetState();
#else
            mLastFrameKeyboardState = mKeyboardState;
            mKeyboardState          = Microsoft.Xna.Framework.Input.Keyboard.GetState();
#endif
            for (int i = 0; i < NumberOfKeys; i++)
            {
                mKeysIgnoredForThisFrame[i] = false;
                mKeysTyped[i] = false;

                if (KeyPushed((Keys)(i)))
                {
                    mKeysTyped[i]         = true;
                    mLastTimeKeyTyped[i]  = TimeManager.CurrentTime;
                    mLastTypedFromPush[i] = true;
                }
            }
#endif
            const double timeAfterInitialPushForRepeat = .5;
            const double timeBetweenRepeats            = .07;

            for (int i = 0; i < NumberOfKeys; i++)
            {
                if (KeyDown((Keys)(i)))
                {
                    if ((mLastTypedFromPush[i] && TimeManager.CurrentTime - mLastTimeKeyTyped[i] > timeAfterInitialPushForRepeat) ||
                        (mLastTypedFromPush[i] == false && TimeManager.CurrentTime - mLastTimeKeyTyped[i] > timeBetweenRepeats)
                        )
                    {
                        mLastTypedFromPush[i] = false;
                        mLastTimeKeyTyped[i]  = TimeManager.CurrentTime;
                        mKeysTyped[i]         = true;
                    }
                }
            }

#if !XBOX360
            // Need to call the ReceiveInput method after testing out typed keys
            if (InputManager.mReceivingInput != null)
            {
                InputManager.InputReceiver.OnFocusUpdate();
                InputManager.mReceivingInput.ReceiveInput();

                //				((IInputReceiver)receivingInput).ReceiveInput(this);
                InputManager.CurrentFrameKeyboardInputSuspended = true;
            }
#endif
        }