OpenTK.Platform.X11.X11Joystick.Poll C# (CSharp) Method

Poll() public method

public Poll ( ) : void
return void
        public void Poll()
        {
            JoystickEvent e;

            foreach (JoystickDevice js in sticks)
            {
                unsafe
                {
                    while ((long)UnsafeNativeMethods.read(js.Id, (void*)&e, (UIntPtr)sizeof(JoystickEvent)) > 0)
                    {
                        e.Type &= ~JoystickEventType.Init;

                        switch (e.Type)
                        {
                            case JoystickEventType.Axis:
                                // Flip vertical axes so that +1 point up.
                                if (e.Number % 2 == 0)
                                    js.SetAxis((JoystickAxis)e.Number, e.Value / 32767.0f);
                                else
                                    js.SetAxis((JoystickAxis)e.Number, -e.Value / 32767.0f);
                                break;

                            case JoystickEventType.Button:
                                js.SetButton((JoystickButton)e.Number, e.Value != 0);
                                break;
                        }
                    }
                }
            }
        }

Usage Example

Beispiel #1
0
 /// <summary>
 /// Polls and updates state of all keyboard, mouse and joystick devices.
 /// </summary>
 public void Poll()
 {
     joystick_driver.Poll();
 }