示例#1
0
        protected override void OnUpdateState()
        {
            //button1
            {
                bool pressed = EngineApp.Instance.IsKeyPressed(EKeys.H);
                if (lastButton1Pressed != pressed)
                {
                    if (pressed)
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonDownEvent(this, Buttons[0]));
                    }
                    else
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonUpEvent(this, Buttons[0]));
                    }
                    lastButton1Pressed = pressed;
                }
            }

            //button2
            {
                bool pressed = EngineApp.Instance.IsKeyPressed(EKeys.J);
                if (lastButton2Pressed != pressed)
                {
                    if (pressed)
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonDownEvent(this, Buttons[1]));
                    }
                    else
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonUpEvent(this, Buttons[1]));
                    }
                    lastButton2Pressed = pressed;
                }
            }

            //axis X
            {
                float value = MathFunctions.Sin(EngineApp.Instance.Time * 2.0f);

                Axes[0].Value = value;

                InputDeviceManager.Instance.SendEvent(
                    new JoystickAxisChangedEvent(this, Axes[0]));
            }

            //custom event example
            {
                //this event will be caused in the EngineApp.OnCustomInputDeviceEvent()
                //and in the all gui controls EControl.OnCustomInputDeviceEvent().
                ExampleCustomInputDeviceSpecialEvent customEvent =
                    new ExampleCustomInputDeviceSpecialEvent(this);
                InputDeviceManager.Instance.SendEvent(customEvent);
            }
        }
        protected override void OnUpdateState()
        {
            //button1
            {
                bool pressed = EngineApp.Instance.IsKeyPressed( EKeys.H );
                if( lastButton1Pressed != pressed )
                {
                    if( pressed )
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonDownEvent( this, Buttons[ 0 ] ) );
                    }
                    else
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonUpEvent( this, Buttons[ 0 ] ) );
                    }
                    lastButton1Pressed = pressed;
                }
            }

            //button2
            {
                bool pressed = EngineApp.Instance.IsKeyPressed( EKeys.J );
                if( lastButton2Pressed != pressed )
                {
                    if( pressed )
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonDownEvent( this, Buttons[ 1 ] ) );
                    }
                    else
                    {
                        InputDeviceManager.Instance.SendEvent(
                            new JoystickButtonUpEvent( this, Buttons[ 1 ] ) );
                    }
                    lastButton2Pressed = pressed;
                }
            }

            //axis X
            {
                float value = MathFunctions.Sin( EngineApp.Instance.Time * 2.0f );

                Axes[ 0 ].Value = value;

                InputDeviceManager.Instance.SendEvent(
                    new JoystickAxisChangedEvent( this, Axes[ 0 ] ) );
            }

            //custom event example
            {
                //this event will be caused in the EngineApp.OnCustomInputDeviceEvent()
                //and in the all gui controls EControl.OnCustomInputDeviceEvent().
                ExampleCustomInputDeviceSpecialEvent customEvent =
                    new ExampleCustomInputDeviceSpecialEvent( this );
                InputDeviceManager.Instance.SendEvent( customEvent );
            }
        }