Example #1
0
        private void SetDefaults(Capabilities capabilities)
        {
            if (capabilities != null)
            {
                if (capabilities.NumberOfAxis > 1)
                {
                    this.Config.LeftStick.X.AssignAxis(0, false);
                    this.Config.LeftStick.Y.AssignAxis(1, false);
                }
                if (capabilities.NumberOfPovHats > 0)
                {
                    this.Config.Dpad.AssignPovHat(0);
                }
                if (capabilities.NumberOfButtons > 0)
                {
                    for (int i = 0; i < capabilities.NumberOfButtons; i++)
                    {
                        Input input = this.Config[i];
                        if (input != null)
                        {
                            input.ID = i;
                            input.Negative = false;
                            input.Type = InputType.Button;
                        }
                    }
                }
            }

        }
Example #2
0
 public Joystick(int id)
 {
     // TODO: Complete member initialization
     this.id = id;
     this.device = Tao.Sdl.Sdl.SDL_JoystickOpen(id);
     this.Open = true;
     this.Name = Tao.Sdl.Sdl.SDL_JoystickName(id);
     this.Details = new Capabilities(this.device);
     this.Config = new PadConfig(this.Name, id);
     this.SetDefaults(this.Details);
 }
Example #3
0
        public Joystick(int id)
        {
            this.id = id;

            var cap = OpenTK.Input.Joystick.GetCapabilities(id);
            this.Open = true;

            this.Name = "";
            this.Details = new Capabilities(cap);
            this.Config = new PadConfig(this.Name, id);
            this.SetDefaults(this.Details);
        }
Example #4
0
 private void SetDefaults(Capabilities capabilities)
 {
   if (capabilities == null)
     return;
   if (capabilities.NumberOfAxis > 1)
   {
     this.Config.LeftStick.X.AssignAxis(0, false);
     this.Config.LeftStick.Y.AssignAxis(1, false);
   }
   if (capabilities.NumberOfPovHats > 0)
     this.Config.Dpad.AssignPovHat(0);
   if (capabilities.NumberOfButtons <= 0)
     return;
   for (int index = 0; index < capabilities.NumberOfButtons; ++index)
   {
     Input input = this.Config[index];
     if (input != null)
     {
       input.ID = index;
       input.Negative = false;
       input.Type = InputType.Button;
     }
   }
 }
Example #5
0
        public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
        {
            Controller controller = GamePad.GetController(playerIndex);

            if (!controller.IsConnected)
            {
                return(new GamePadCapabilities());
            }
            Capabilities        capabilities        = controller.GetCapabilities(DeviceQueryType.Any);
            GamePadCapabilities gamePadCapabilities = new GamePadCapabilities();

            switch (capabilities.SubType)
            {
            case DeviceSubType.Gamepad:
                gamePadCapabilities.GamePadType = GamePadType.GamePad;
                break;

            case DeviceSubType.Wheel:
                gamePadCapabilities.GamePadType = GamePadType.Wheel;
                break;

            case DeviceSubType.ArcadeStick:
                gamePadCapabilities.GamePadType = GamePadType.ArcadeStick;
                break;

            case DeviceSubType.DancePad:
                gamePadCapabilities.GamePadType = GamePadType.DancePad;
                break;

            case DeviceSubType.Guitar:
                gamePadCapabilities.GamePadType = GamePadType.Guitar;
                break;

            case DeviceSubType.DrumKit:
                gamePadCapabilities.GamePadType = GamePadType.DrumKit;
                break;

            default:
                gamePadCapabilities.GamePadType = GamePadType.Unknown;
                break;
            }
            Gamepad            gamepad            = capabilities.Gamepad;
            GamepadButtonFlags gamepadButtonFlags = gamepad.Buttons;

            gamePadCapabilities.HasAButton             = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.A);
            gamePadCapabilities.HasBackButton          = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.Back);
            gamePadCapabilities.HasBButton             = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.B);
            gamePadCapabilities.HasBigButton           = false;
            gamePadCapabilities.HasDPadDownButton      = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.DPadDown);
            gamePadCapabilities.HasDPadLeftButton      = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.DPadLeft);
            gamePadCapabilities.HasDPadRightButton     = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.DPadLeft);
            gamePadCapabilities.HasDPadUpButton        = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.DPadUp);
            gamePadCapabilities.HasLeftShoulderButton  = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.LeftShoulder);
            gamePadCapabilities.HasLeftStickButton     = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.LeftThumb);
            gamePadCapabilities.HasRightShoulderButton = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.RightShoulder);
            gamePadCapabilities.HasRightStickButton    = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.RightThumb);
            gamePadCapabilities.HasStartButton         = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.Start);
            gamePadCapabilities.HasXButton             = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.X);
            gamePadCapabilities.HasYButton             = gamepadButtonFlags.HasFlag((Enum)GamepadButtonFlags.Y);
            gamePadCapabilities.HasRightTrigger        = (int)gamepad.LeftTrigger > 0;
            gamePadCapabilities.HasRightXThumbStick    = (int)gamepad.RightThumbX != 0;
            gamePadCapabilities.HasRightYThumbStick    = (int)gamepad.RightThumbY != 0;
            gamePadCapabilities.HasLeftTrigger         = (int)gamepad.LeftTrigger > 0;
            gamePadCapabilities.HasLeftXThumbStick     = (int)gamepad.LeftThumbX != 0;
            gamePadCapabilities.HasLeftYThumbStick     = (int)gamepad.LeftThumbY != 0;
            gamePadCapabilities.HasLeftVibrationMotor  = (int)capabilities.Vibration.LeftMotorSpeed > 0;
            gamePadCapabilities.HasRightVibrationMotor = (int)capabilities.Vibration.RightMotorSpeed > 0;
            gamePadCapabilities.IsConnected            = controller.IsConnected;
            gamePadCapabilities.HasVoiceSupport        = capabilities.Flags.HasFlag((Enum)CapabilityFlags.VoiceSupported);
            return(gamePadCapabilities);
        }