Beispiel #1
0
 private void MainFrame_Activated(object sender, EventArgs e)
 {
     try
     {
         if (DInputDevice != null)
         {
             DInputDevice.Acquire();
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #2
0
        protected override bool OnPostInitializeDInput()
        {
            try
            {
                CooperativeLevelFlags CoopFlags;

                CoopFlags  = CooperativeLevelFlags.Exclusive;
                CoopFlags |= CooperativeLevelFlags.Foreground;

                DInputDevice.SetCooperativeLevel(this, CoopFlags);
            }
            catch (InputException)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        private bool ReadKeyboard()
        {
            try
            {
                KeyboardState State = null;

                if (DInputDevice == null)
                {
                    return(true);
                }

                // Get the input's device state, and store it.
                InputException Ie = null;

                try
                {
                    State = DInputDevice.GetCurrentKeyboardState();
                }
                catch (DirectXException)
                {
                    bool Loop = true;

                    do
                    {
                        try
                        {
                            DInputDevice.Acquire();
                        }
                        catch (InputLostException)
                        {
                            Loop = true;
                        }
                        catch (InputException theInputException)
                        {
                            Ie   = theInputException;
                            Loop = false;
                        }
                    } while (Loop);

                    return(true);
                }

                p_Beast.BeastWait();

                if (State[Key.Left] == true)
                {
                    p_Beast.BeastRunLeft();
                    p_Landscape.GoLeft();
                }

                if (State[Key.Right] == true)
                {
                    p_Beast.BeastRunRight();
                    p_Landscape.GoRight();
                }

                if (State[Key.Escape] == true)
                {
                    this.Close();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }