protected GamePad(InputDevice device) { _device = device; _deviceId = device.Id; _capabilities = CapabilitiesOfDevice(device); }
public GamePadCapabilitiesEx(GamePadCapabilities copy) : this() { this.IsConnected = copy.IsConnected; this.HasAButton = copy.HasAButton; this.HasBackButton = copy.HasBackButton; this.HasBButton = copy.HasBButton; this.HasDPadDownButton = copy.HasDPadDownButton; this.HasDPadLeftButton = copy.HasDPadLeftButton; this.HasDPadRightButton = copy.HasDPadRightButton; this.HasDPadUpButton = copy.HasDPadUpButton; this.HasLeftShoulderButton = copy.HasLeftShoulderButton; this.HasLeftStickButton = copy.HasLeftStickButton; this.HasRightShoulderButton = copy.HasRightShoulderButton; this.HasRightStickButton = copy.HasRightStickButton; this.HasStartButton = copy.HasStartButton; this.HasXButton = copy.HasXButton; this.HasYButton = copy.HasYButton; this.HasBigButton = copy.HasBigButton; this.HasLeftXThumbStick = copy.HasLeftXThumbStick; this.HasLeftYThumbStick = copy.HasLeftYThumbStick; this.HasRightXThumbStick = copy.HasRightXThumbStick; this.HasRightYThumbStick = copy.HasRightYThumbStick; this.HasLeftTrigger = copy.HasLeftTrigger; this.HasRightTrigger = copy.HasRightTrigger; this.HasLeftVibrationMotor = copy.HasLeftVibrationMotor; this.HasRightVibrationMotor = copy.HasRightVibrationMotor; this.HasVoiceSupport = copy.HasVoiceSupport; this.GamePadType = copy.GamePadType; }
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; }
private static GamePadCapabilities PlatformGetCapabilities(int index) { GamePadCapabilities capabilities = new GamePadCapabilities(); capabilities.IsConnected = (index == 0); capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasBackButton = true; capabilities.HasStartButton = true; capabilities.HasDPadUpButton = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; return capabilities; }
public static void Boot() { //SDL2 doesn't support changing this after SDL_SYS_JoystickInit has been called. //We're handling the accelerometer controller on our own. SDL2.SDL.SDL_SetHint("SDL_HINT_ACCELEROMETER_AS_JOYSTICK", "0"); //The FNAPlatform hooking reflection part.. oh, so shiny! Assembly asm = Assembly.GetAssembly(typeof(Game)); Type t; FieldInfo f; t = asm.GetType("Microsoft.Xna.Framework.Input.GamePad"); f = t.GetField("GAMEPAD_COUNT", BindingFlags.Static | BindingFlags.NonPublic); _GamePad_GAMEPAD_COUNT = (int) f.GetValue(null); PhoneGamePadCapabilities = new GamePadCapabilities(); t = PhoneGamePadCapabilities.GetType(); t.GetProperty("IsConnected", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { true }); t.GetProperty("HasBackButton", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { true }); t.GetProperty("HasLeftXThumbStick", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { true }); t.GetProperty("HasLeftYThumbStick", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { true }); t.GetProperty("HasLeftVibrationMotor", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { true }); t.GetProperty("HasRightVibrationMotor", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { true }); t.GetProperty("GamePadType", BindingFlags.Instance | BindingFlags.Public) .GetSetMethod(true).Invoke(PhoneGamePadCapabilities, new object[] { GamePadType.Unknown }); t = asm.GetType("Microsoft.Xna.Framework.FNAPlatform"); f = t.GetField("Log"); f.SetValue(null, (Action<string>) Log); Hook("GetMaximumTouchCount"); Hook("SetGamePadVibration"); Hook("GetGamePadCapabilities"); Hook("GetGamePadState"); }
public static Microsoft.Xna.Framework.Input.GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) { GamePadCapabilities capabilities = new GamePadCapabilities(); capabilities.IsConnected = (playerIndex == PlayerIndex.One); capabilities.HasBackButton = true; return capabilities; }
public OuyaGamePad(InputDevice device) { _device = device; _deviceId = device.Id; _descriptor = device.Descriptor; _isConnected = true; _capabilities = CapabilitiesOfDevice(device); }
public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) { var gamePad = GamePads[(int) playerIndex]; if (gamePad != null) return gamePad._capabilities; GamePadCapabilities capabilities = new GamePadCapabilities(); capabilities.IsConnected = false; capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasBackButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; return capabilities; }
public virtual IEnumerator <ITask> QueryControllersHandler(QueryControllers queryControllers) { QueryControllersResponse response = new QueryControllersResponse(); for (PlayerIndex player = PlayerIndex.One; player <= PlayerIndex.Four; player++) { xinput.GamePadCapabilities caps = xinput.GamePad.GetCapabilities((xna.PlayerIndex)player); if (caps.IsConnected) { ControllerCaps controller = new ControllerCaps(); controller.PlayerIndex = player; controller.IsConnected = true; controller.ControllerType = (ControllerType)caps.GamePadType; response.Controllers.Add(controller); } } queryControllers.ResponsePort.Post(response); yield break; }
private static void INTERNAL_AddInstance(int dev) { int which = -1; for (int i = 0; i < INTERNAL_devices.Length; i += 1) { if (INTERNAL_devices[i] == IntPtr.Zero) { which = i; break; } } if (which == -1) { return; // Ignoring more than 4 controllers. } // Clear the error buffer. We're about to do a LOT of dangerous stuff. SDL.SDL_ClearError(); // Open the device! INTERNAL_devices[which] = SDL.SDL_GameControllerOpen(dev); // We use this when dealing with Haptic/GUID initialization. IntPtr thisJoystick = SDL.SDL_GameControllerGetJoystick(INTERNAL_devices[which]); // Pair up the instance ID to the player index. // FIXME: Remove check after 2.0.4? -flibit int thisInstance = SDL.SDL_JoystickInstanceID(thisJoystick); if (INTERNAL_instanceList.ContainsKey(thisInstance)) { // Duplicate? Usually this is OSX being dumb, but...? INTERNAL_devices[which] = IntPtr.Zero; return; } INTERNAL_instanceList.Add(thisInstance, which); // Start with a fresh state. INTERNAL_states[which] = new GamePadState(); INTERNAL_states[which].IsConnected = true; // Initialize the haptics for the joystick, if applicable. if (SDL.SDL_JoystickIsHaptic(thisJoystick) == 1) { INTERNAL_haptics[which] = SDL.SDL_HapticOpenFromJoystick(thisJoystick); if (INTERNAL_haptics[which] == IntPtr.Zero) { Log("HAPTIC OPEN ERROR: " + SDL.SDL_GetError()); } } if (INTERNAL_haptics[which] != IntPtr.Zero) { if ( OSVersion.Equals("Mac OS X") && SDL.SDL_HapticEffectSupported(INTERNAL_haptics[which], ref INTERNAL_leftRightMacHackEffect) == 1 ) { INTERNAL_hapticTypes[which] = HapticType.LeftRightMacHack; SDL.SDL_HapticNewEffect(INTERNAL_haptics[which], ref INTERNAL_leftRightMacHackEffect); } else if ( !OSVersion.Equals("Mac OS X") && SDL.SDL_HapticEffectSupported(INTERNAL_haptics[which], ref INTERNAL_leftRightEffect) == 1 ) { INTERNAL_hapticTypes[which] = HapticType.LeftRight; SDL.SDL_HapticNewEffect(INTERNAL_haptics[which], ref INTERNAL_leftRightEffect); } else if (SDL.SDL_HapticRumbleSupported(INTERNAL_haptics[which]) == 1) { INTERNAL_hapticTypes[which] = HapticType.Simple; SDL.SDL_HapticRumbleInit(INTERNAL_haptics[which]); } else { // We can't even play simple rumble, this haptic device is useless to us. SDL.SDL_HapticClose(INTERNAL_haptics[which]); INTERNAL_haptics[which] = IntPtr.Zero; } } // An SDL_GameController _should_ always be complete... INTERNAL_capabilities[which] = new GamePadCapabilities() { IsConnected = true, HasAButton = true, HasBButton = true, HasXButton = true, HasYButton = true, HasBackButton = true, HasStartButton = true, HasDPadDownButton = true, HasDPadLeftButton = true, HasDPadRightButton = true, HasDPadUpButton = true, HasLeftShoulderButton = true, HasRightShoulderButton = true, HasLeftStickButton = true, HasRightStickButton = true, HasLeftTrigger = true, HasRightTrigger = true, HasLeftXThumbStick = true, HasLeftYThumbStick = true, HasRightXThumbStick = true, HasRightYThumbStick = true, HasBigButton = true, HasLeftVibrationMotor = INTERNAL_haptics[which] != IntPtr.Zero, HasRightVibrationMotor = INTERNAL_haptics[which] != IntPtr.Zero, HasVoiceSupport = false }; // Store the GUID string for this device StringBuilder result = new StringBuilder(); byte[] resChar = new byte[33]; // FIXME: Sort of arbitrary. SDL.SDL_JoystickGetGUIDString( SDL.SDL_JoystickGetGUID(thisJoystick), resChar, resChar.Length ); if (OSVersion.Equals("Linux")) { result.Append((char) resChar[8]); result.Append((char) resChar[9]); result.Append((char) resChar[10]); result.Append((char) resChar[11]); result.Append((char) resChar[16]); result.Append((char) resChar[17]); result.Append((char) resChar[18]); result.Append((char) resChar[19]); } else if (OSVersion.Equals("Mac OS X")) { result.Append((char) resChar[0]); result.Append((char) resChar[1]); result.Append((char) resChar[2]); result.Append((char) resChar[3]); result.Append((char) resChar[16]); result.Append((char) resChar[17]); result.Append((char) resChar[18]); result.Append((char) resChar[19]); } else if (OSVersion.Equals("Windows")) { bool isXInput = true; foreach (byte b in resChar) { if (((char) b) != '0' && b != 0) { isXInput = false; break; } } if (isXInput) { result.Append("xinput"); } else { result.Append((char) resChar[0]); result.Append((char) resChar[1]); result.Append((char) resChar[2]); result.Append((char) resChar[3]); result.Append((char) resChar[4]); result.Append((char) resChar[5]); result.Append((char) resChar[6]); result.Append((char) resChar[7]); } } else { throw new NotSupportedException("Unhandled SDL2 platform!"); } INTERNAL_guids[which] = result.ToString(); // Initialize light bar if ( OSVersion.Equals("Linux") && INTERNAL_guids[which].Equals("4c05c405") ) { // Get all of the individual PS4 LED instances List<string> ledList = new List<string>(); string[] dirs = Directory.GetDirectories("/sys/class/leds/"); foreach (string dir in dirs) { if ( dir.Contains("054C:05C4") && dir.EndsWith("blue") ) { ledList.Add(dir.Substring(0, dir.LastIndexOf(':') + 1)); } } // Find how many of these are already in use int numLights = 0; for (int i = 0; i < INTERNAL_lightBars.Length; i += 1) { if (!String.IsNullOrEmpty(INTERNAL_lightBars[i])) { numLights += 1; } } // If all are not already in use, use the first unused light if (numLights < ledList.Count) { INTERNAL_lightBars[which] = ledList[numLights]; } } // Print controller information to stdout. Log( "Controller " + which.ToString() + ": " + SDL.SDL_GameControllerName(INTERNAL_devices[which]) ); }
/// <summary> /// Draw all data for a set of GamePad data and capabilities. /// </summary> /// <param name="gamePadState">The GamePad data.</param> /// <param name="gamePadCapabilities">The GamePad capabilities.</param> /// <remarks> /// The GamePad structures are passed by reference for speed. They are not /// modified in this method. /// </remarks> private void DrawData(ref GamePadState gamePadState, ref GamePadCapabilities gamePadCapabilities) { // // Draw the first column of data // Vector2 descriptionPosition = descriptionColumn1Position; Vector2 valuePosition = valueColumn1Position; // draw left thumbstick data DrawValue(InputReporterResources.LeftThumbstickX, ref descriptionPosition, gamePadState.ThumbSticks.Left.X.ToString("0.000"), ref valuePosition, gamePadCapabilities.HasLeftXThumbStick, gamePadState.ThumbSticks.Left.X != 0f); DrawValue(InputReporterResources.LeftThumbstickY, ref descriptionPosition, gamePadState.ThumbSticks.Left.Y.ToString("0.000"), ref valuePosition, gamePadCapabilities.HasLeftYThumbStick, gamePadState.ThumbSticks.Left.Y != 0f); // draw the right thumbstick data DrawValue(InputReporterResources.RightThumbstickX, ref descriptionPosition, gamePadState.ThumbSticks.Right.X.ToString("0.000"), ref valuePosition, gamePadCapabilities.HasRightXThumbStick, gamePadState.ThumbSticks.Right.X != 0f); DrawValue(InputReporterResources.RightThumbstickY, ref descriptionPosition, gamePadState.ThumbSticks.Right.Y.ToString("0.000"), ref valuePosition, gamePadCapabilities.HasRightYThumbStick, gamePadState.ThumbSticks.Right.Y != 0f); descriptionPosition.Y += dataSpacing; valuePosition.Y += dataSpacing; // draw the trigger data DrawValue(InputReporterResources.LeftTrigger, ref descriptionPosition, gamePadState.Triggers.Left.ToString("0.000"), ref valuePosition, gamePadCapabilities.HasLeftTrigger, gamePadState.Triggers.Left != 0f); DrawValue(InputReporterResources.RightTrigger, ref descriptionPosition, gamePadState.Triggers.Right.ToString("0.000"), ref valuePosition, gamePadCapabilities.HasRightTrigger, gamePadState.Triggers.Right != 0f); descriptionPosition.Y += dataSpacing; valuePosition.Y += dataSpacing; // draw the directional pad data DrawValue(InputReporterResources.DPadUp, ref descriptionPosition, (gamePadState.DPad.Up == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasDPadUpButton, gamePadState.DPad.Up == ButtonState.Pressed); DrawValue(InputReporterResources.DPadDown, ref descriptionPosition, (gamePadState.DPad.Down == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasDPadDownButton, gamePadState.DPad.Down == ButtonState.Pressed); DrawValue(InputReporterResources.DPadLeft, ref descriptionPosition, (gamePadState.DPad.Left == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasDPadLeftButton, gamePadState.DPad.Left == ButtonState.Pressed); DrawValue(InputReporterResources.DPadRight, ref descriptionPosition, (gamePadState.DPad.Right == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasDPadRightButton, gamePadState.DPad.Right == ButtonState.Pressed); descriptionPosition.Y += dataSpacing; valuePosition.Y += dataSpacing; // draw the vibration data if (gamePadCapabilities.HasLeftVibrationMotor) { if (gamePadCapabilities.HasRightVibrationMotor) { spriteBatch.DrawString(dataFont, InputReporterResources.BothVibrationMotors, descriptionPosition, descriptionColor); } else { spriteBatch.DrawString(dataFont, InputReporterResources.LeftVibrationMotor, descriptionPosition, descriptionColor); } } else if (gamePadCapabilities.HasRightVibrationMotor) { spriteBatch.DrawString(dataFont, InputReporterResources.RightVibrationMotor, descriptionPosition, descriptionColor); } else { spriteBatch.DrawString(dataFont, InputReporterResources.NoVibration, descriptionPosition, descriptionColor); } // // Draw the second column of data // descriptionPosition = descriptionColumn2Position; valuePosition = valueColumn2Position; // draw the button data DrawValue(InputReporterResources.A, ref descriptionPosition, (gamePadState.Buttons.A == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasAButton, gamePadState.Buttons.A == ButtonState.Pressed); DrawValue(InputReporterResources.B, ref descriptionPosition, (gamePadState.Buttons.B == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasBButton, gamePadState.Buttons.B == ButtonState.Pressed); DrawValue(InputReporterResources.X, ref descriptionPosition, (gamePadState.Buttons.X == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasXButton, gamePadState.Buttons.X == ButtonState.Pressed); DrawValue(InputReporterResources.Y, ref descriptionPosition, (gamePadState.Buttons.Y == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasYButton, gamePadState.Buttons.Y == ButtonState.Pressed); DrawValue(InputReporterResources.LeftShoulder, ref descriptionPosition, (gamePadState.Buttons.LeftShoulder == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasLeftShoulderButton, gamePadState.Buttons.LeftShoulder == ButtonState.Pressed); DrawValue(InputReporterResources.RightShoulder, ref descriptionPosition, (gamePadState.Buttons.RightShoulder == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasRightShoulderButton, gamePadState.Buttons.RightShoulder == ButtonState.Pressed); DrawValue(InputReporterResources.LeftStick, ref descriptionPosition, (gamePadState.Buttons.LeftStick == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasLeftStickButton, gamePadState.Buttons.LeftStick == ButtonState.Pressed); DrawValue(InputReporterResources.RightStick, ref descriptionPosition, (gamePadState.Buttons.RightStick == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasRightStickButton, gamePadState.Buttons.RightStick == ButtonState.Pressed); DrawValue(InputReporterResources.Start, ref descriptionPosition, (gamePadState.Buttons.Start == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasStartButton, gamePadState.Buttons.Start == ButtonState.Pressed); DrawValue(InputReporterResources.Back, ref descriptionPosition, (gamePadState.Buttons.Back == ButtonState.Pressed ? InputReporterResources.ButtonPressed : InputReporterResources.ButtonReleased), ref valuePosition, gamePadCapabilities.HasBackButton, gamePadState.Buttons.Back == ButtonState.Pressed); descriptionPosition.Y += dataSpacing; valuePosition.Y += dataSpacing; // draw the packet number data DrawValue(InputReporterResources.PacketNumber, ref descriptionPosition, gamePadState.PacketNumber.ToString(), ref valuePosition, gamePadCapabilities.IsConnected, false); }
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); }
public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) { GamePadCapabilities capabilities = new GamePadCapabilities(); capabilities.IsConnected = (playerIndex == PlayerIndex.One); capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasBackButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; return capabilities; }
public GamePadInfos(PlayerIndex playerIndex) { _playerIndex = playerIndex; _gamePadCapabilities = GamePad.GetCapabilities(playerIndex); }
private static GamePadCapabilities GetCapabilities(GCController controller) { //All iOS controllers have these basics var capabilities = new GamePadCapabilities() { IsConnected = false, GamePadType = GamePadType.GamePad, }; if (controller.ExtendedGamepad != null) { capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasBackButton = true; capabilities.HasDPadUpButton = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; capabilities.HasLeftTrigger = true; capabilities.HasRightTrigger = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; } else if (controller.Gamepad != null) { capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasBackButton = true; capabilities.HasDPadUpButton = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; } else if (controller.MicroGamepad != null) { capabilities.HasAButton = true; capabilities.HasXButton = true; capabilities.HasBackButton = true; capabilities.HasDPadUpButton = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; } return capabilities; }
private static GamePadCapabilities PlatformGetCapabilities(int index) { // If the device was disconneced then wait for // the timeout to elapsed before we test it again. if (!_connected[index] && !HasDisconnectedTimeoutElapsed(index)) { return(new GamePadCapabilities()); } // Check to see if the device is connected. var controller = _controllers[index]; _connected[index] = controller.IsConnected; // If the device is disconnected retry it after the // timeout period has elapsed to avoid the overhead. if (!_connected[index]) { SetDisconnectedTimeout(index); return(new GamePadCapabilities()); } var capabilities = controller.GetCapabilities(SharpDX.XInput.DeviceQueryType.Any); var ret = new GamePadCapabilities(); switch (capabilities.SubType) { #if DIRECTX11_1 case SharpDX.XInput.DeviceSubType.ArcadePad: Debug.WriteLine("XInput's DeviceSubType.ArcadePad is not supported in XNA"); ret.GamePadType = Input.GamePadType.Unknown; // TODO: Should this be BigButtonPad? break; case SharpDX.XInput.DeviceSubType.FlightStick: ret.GamePadType = Input.GamePadType.FlightStick; break; case SharpDX.XInput.DeviceSubType.GuitarAlternate: ret.GamePadType = Input.GamePadType.AlternateGuitar; break; case SharpDX.XInput.DeviceSubType.GuitarBass: // Note: XNA doesn't distinguish between Guitar and GuitarBass, but // GuitarBass is identical to Guitar in XInput, distinguished only // to help setup for those controllers. ret.GamePadType = Input.GamePadType.Guitar; break; case SharpDX.XInput.DeviceSubType.Unknown: ret.GamePadType = Input.GamePadType.Unknown; break; #endif case SharpDX.XInput.DeviceSubType.ArcadeStick: ret.GamePadType = GamePadType.ArcadeStick; break; case SharpDX.XInput.DeviceSubType.DancePad: ret.GamePadType = GamePadType.DancePad; break; case SharpDX.XInput.DeviceSubType.DrumKit: ret.GamePadType = GamePadType.DrumKit; break; case SharpDX.XInput.DeviceSubType.Gamepad: ret.GamePadType = GamePadType.GamePad; break; case SharpDX.XInput.DeviceSubType.Guitar: ret.GamePadType = GamePadType.Guitar; break; case SharpDX.XInput.DeviceSubType.Wheel: ret.GamePadType = GamePadType.Wheel; break; default: Debug.WriteLine("unexpected XInput DeviceSubType: {0}", capabilities.SubType.ToString()); ret.GamePadType = GamePadType.Unknown; break; } var gamepad = capabilities.Gamepad; // digital buttons var buttons = gamepad.Buttons; ret.HasAButton = (buttons & GBF.A) == GBF.A; ret.HasBackButton = (buttons & GBF.Back) == GBF.Back; ret.HasBButton = (buttons & GBF.B) == GBF.B; ret.HasBigButton = false; // TODO: what IS this? Is it related to GamePadType.BigGamePad? ret.HasDPadDownButton = (buttons & GBF.DPadDown) == GBF.DPadDown; ret.HasDPadLeftButton = (buttons & GBF.DPadLeft) == GBF.DPadLeft; ret.HasDPadRightButton = (buttons & GBF.DPadRight) == GBF.DPadRight; ret.HasDPadUpButton = (buttons & GBF.DPadUp) == GBF.DPadUp; ret.HasLeftShoulderButton = (buttons & GBF.LeftShoulder) == GBF.LeftShoulder; ret.HasLeftStickButton = (buttons & GBF.LeftThumb) == GBF.LeftThumb; ret.HasRightShoulderButton = (buttons & GBF.RightShoulder) == GBF.RightShoulder; ret.HasRightStickButton = (buttons & GBF.RightThumb) == GBF.RightThumb; ret.HasStartButton = (buttons & GBF.Start) == GBF.Start; ret.HasXButton = (buttons & GBF.X) == GBF.X; ret.HasYButton = (buttons & GBF.Y) == GBF.Y; // analog controls ret.HasRightTrigger = gamepad.RightTrigger > 0; ret.HasRightXThumbStick = gamepad.RightThumbX != 0; ret.HasRightYThumbStick = gamepad.RightThumbY != 0; ret.HasLeftTrigger = gamepad.LeftTrigger > 0; ret.HasLeftXThumbStick = gamepad.LeftThumbX != 0; ret.HasLeftYThumbStick = gamepad.LeftThumbY != 0; // vibration #if DIRECTX11_1 bool hasForceFeedback = (capabilities.Flags & SharpDX.XInput.CapabilityFlags.FfbSupported) == SharpDX.XInput.CapabilityFlags.FfbSupported; ret.HasLeftVibrationMotor = hasForceFeedback && capabilities.Vibration.LeftMotorSpeed > 0; ret.HasRightVibrationMotor = hasForceFeedback && capabilities.Vibration.RightMotorSpeed > 0; #else ret.HasLeftVibrationMotor = (capabilities.Vibration.LeftMotorSpeed > 0); ret.HasRightVibrationMotor = (capabilities.Vibration.RightMotorSpeed > 0); #endif // other ret.IsConnected = controller.IsConnected; ret.HasVoiceSupport = (capabilities.Flags & SharpDX.XInput.CapabilityFlags.VoiceSupported) == SharpDX.XInput.CapabilityFlags.VoiceSupported; return(ret); }
private static GamePadCapabilities CapabilitiesOfDevice(InputDevice device) { //TODO: There is probably a better way to do this. Maybe device.GetMotionRange and device.GetKeyCharacterMap? //Or not http://stackoverflow.com/questions/11686703/android-enumerating-the-buttons-on-a-gamepad var capabilities = new GamePadCapabilities(); capabilities.IsConnected = true; capabilities.GamePadType = GamePadType.GamePad; capabilities.HasLeftVibrationMotor = capabilities.HasRightVibrationMotor = device.Vibrator.HasVibrator; switch (device.Name) { case "OUYA Game Controller": capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; capabilities.HasLeftTrigger = true; capabilities.HasRightTrigger = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasDPadUpButton = true; break; case "Microsoft X-Box 360 pad": capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; capabilities.HasLeftTrigger = true; capabilities.HasRightTrigger = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasDPadUpButton = true; capabilities.HasStartButton = true; capabilities.HasBackButton = true; break; } return(capabilities); }
private static GamePadCapabilities PlatformGetCapabilities(int index) { // If the device was disconneced then wait for // the timeout to elapsed before we test it again. if (!_connected[index] && _timeout[index] > DateTime.UtcNow.Ticks) return new GamePadCapabilities(); // Check to see if the device is connected. var controller = _controllers[index]; _connected[index] = controller.IsConnected; // If the device is disconnected retry it after the // timeout period has elapsed to avoid the overhead. if (!_connected[index]) { _timeout[index] = DateTime.UtcNow.Ticks + TimeoutTicks; return new GamePadCapabilities(); } var capabilities = controller.GetCapabilities(SharpDX.XInput.DeviceQueryType.Any); var ret = new GamePadCapabilities(); switch (capabilities.SubType) { #if DIRECTX11_1 case SharpDX.XInput.DeviceSubType.ArcadePad: Debug.WriteLine("XInput's DeviceSubType.ArcadePad is not supported in XNA"); ret.GamePadType = Input.GamePadType.Unknown; // TODO: Should this be BigButtonPad? break; case SharpDX.XInput.DeviceSubType.FlightStick: ret.GamePadType = Input.GamePadType.FlightStick; break; case SharpDX.XInput.DeviceSubType.GuitarAlternate: ret.GamePadType = Input.GamePadType.AlternateGuitar; break; case SharpDX.XInput.DeviceSubType.GuitarBass: // Note: XNA doesn't distinguish between Guitar and GuitarBass, but // GuitarBass is identical to Guitar in XInput, distinguished only // to help setup for those controllers. ret.GamePadType = Input.GamePadType.Guitar; break; case SharpDX.XInput.DeviceSubType.Unknown: ret.GamePadType = Input.GamePadType.Unknown; break; #endif case SharpDX.XInput.DeviceSubType.ArcadeStick: ret.GamePadType = GamePadType.ArcadeStick; break; case SharpDX.XInput.DeviceSubType.DancePad: ret.GamePadType = GamePadType.DancePad; break; case SharpDX.XInput.DeviceSubType.DrumKit: ret.GamePadType = GamePadType.DrumKit; break; case SharpDX.XInput.DeviceSubType.Gamepad: ret.GamePadType = GamePadType.GamePad; break; case SharpDX.XInput.DeviceSubType.Guitar: ret.GamePadType = GamePadType.Guitar; break; case SharpDX.XInput.DeviceSubType.Wheel: ret.GamePadType = GamePadType.Wheel; break; default: Debug.WriteLine("unexpected XInput DeviceSubType: {0}", capabilities.SubType.ToString()); ret.GamePadType = GamePadType.Unknown; break; } var gamepad = capabilities.Gamepad; // digital buttons var buttons = gamepad.Buttons; ret.HasAButton = (buttons & GBF.A) == GBF.A; ret.HasBackButton = (buttons & GBF.Back) == GBF.Back; ret.HasBButton = (buttons & GBF.B) == GBF.B; ret.HasBigButton = false; // TODO: what IS this? Is it related to GamePadType.BigGamePad? ret.HasDPadDownButton = (buttons & GBF.DPadDown) == GBF.DPadDown; ret.HasDPadLeftButton = (buttons & GBF.DPadLeft) == GBF.DPadLeft; ret.HasDPadRightButton = (buttons & GBF.DPadRight) == GBF.DPadRight; ret.HasDPadUpButton = (buttons & GBF.DPadUp) == GBF.DPadUp; ret.HasLeftShoulderButton = (buttons & GBF.LeftShoulder) == GBF.LeftShoulder; ret.HasLeftStickButton = (buttons & GBF.LeftThumb) == GBF.LeftThumb; ret.HasRightShoulderButton = (buttons & GBF.RightShoulder) == GBF.RightShoulder; ret.HasRightStickButton = (buttons & GBF.RightThumb) == GBF.RightThumb; ret.HasStartButton = (buttons & GBF.Start) == GBF.Start; ret.HasXButton = (buttons & GBF.X) == GBF.X; ret.HasYButton = (buttons & GBF.Y) == GBF.Y; // analog controls ret.HasRightTrigger = gamepad.LeftTrigger > 0; ret.HasRightXThumbStick = gamepad.RightThumbX != 0; ret.HasRightYThumbStick = gamepad.RightThumbY != 0; ret.HasLeftTrigger = gamepad.LeftTrigger > 0; ret.HasLeftXThumbStick = gamepad.LeftThumbX != 0; ret.HasLeftYThumbStick = gamepad.LeftThumbY != 0; // vibration #if DIRECTX11_1 bool hasForceFeedback = (capabilities.Flags & SharpDX.XInput.CapabilityFlags.FfbSupported) == SharpDX.XInput.CapabilityFlags.FfbSupported; ret.HasLeftVibrationMotor = hasForceFeedback && capabilities.Vibration.LeftMotorSpeed > 0; ret.HasRightVibrationMotor = hasForceFeedback && capabilities.Vibration.RightMotorSpeed > 0; #else ret.HasLeftVibrationMotor = false; ret.HasRightVibrationMotor = false; #endif // other ret.IsConnected = controller.IsConnected; ret.HasVoiceSupport = (capabilities.Flags & SharpDX.XInput.CapabilityFlags.VoiceSupported) == SharpDX.XInput.CapabilityFlags.VoiceSupported; return ret; }
internal void Update() { GamePadState gamepadState; #if SILVERLIGHT || MONOGAME gamepadState = Microsoft.Xna.Framework.Input.GamePad.GetState(mPlayerIndex);//, GamePadDeadZone.Circular); #else gamepadState = Microsoft.Xna.Framework.Input.GamePad.GetState(mPlayerIndex, GamePadDeadZone.Circular); mCapabilities = Microsoft.Xna.Framework.Input.GamePad.GetCapabilities(mPlayerIndex); #endif Update(gamepadState); }
private static GamePadCapabilities PlatformGetCapabilities(int index) { var gamePad = GamePads[index]; if (gamePad != null) return gamePad._capabilities; GamePadCapabilities capabilities = new GamePadCapabilities(); capabilities.IsConnected = false; capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasBackButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; return capabilities; }
/* static void Events_JoystickHatMotion(object sender, JoystickHatEventArgs e) { if (e.Device > MaxSticks) return; _state[e.Device].PacketNumber++; // integer wrapping is handled by setter } static void Events_JoystickAxisMotion(object sender, JoystickAxisEventArgs e) { if (e.Device > MaxSticks) return; _state[e.Device].PacketNumber++; // integer wrapping is handled by setter } static void Events_JoystickButtonUp(object sender, JoystickButtonEventArgs e) { if (e.Device > MaxSticks) return; _state[e.Device].PacketNumber++; // integer wrapping is handled by setter } static void Events_JoystickButtonDown(object sender, JoystickButtonEventArgs e) { if (e.Device > MaxSticks) return; _state[e.Device].PacketNumber++; // integer wrapping is handled by setter } */ #endregion Constructors #region Public Methods public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) { if (playerIndex < PlayerIndex.One || playerIndex > PlayerIndex.Four) throw new InvalidOperationException(); GamePadCapabilities caps = new GamePadCapabilities(); IntPtr stick = _sticks[(int)playerIndex]; if (stick != null) { caps.hasAButton = Sdl.SDL_JoystickNumButtons(stick) > 1; caps.hasBButton = Sdl.SDL_JoystickNumButtons(stick) > 0; caps.hasDPadDownButton = caps.hasDPadLeftButton = caps.hasDPadRightButton = caps.hasDPadUpButton = Sdl.SDL_JoystickNumHats(stick) > 0; caps.hasLeftShoulderButton = Sdl.SDL_JoystickNumButtons(stick) > 4; caps.hasRightShoulderButton = Sdl.SDL_JoystickNumButtons(stick) > 5; caps.hasStartButton = Sdl.SDL_JoystickNumButtons(stick) > 7; caps.hasXButton = Sdl.SDL_JoystickNumButtons(stick) > 2; caps.hasYButton = Sdl.SDL_JoystickNumButtons(stick) > 3; caps.isConnected = true; caps.gamePadType = GamePadType.GamePad; } return caps; }
private static GamePadCapabilities CapabilitiesOfDevice(InputDevice device) { //TODO: There is probably a better way to do this. Maybe device.GetMotionRange and device.GetKeyCharacterMap? //Or not http://stackoverflow.com/questions/11686703/android-enumerating-the-buttons-on-a-gamepad var capabilities = new GamePadCapabilities(); capabilities.IsConnected = true; capabilities.GamePadType = GamePadType.GamePad; capabilities.HasLeftVibrationMotor = capabilities.HasRightVibrationMotor = device.Vibrator.HasVibrator; switch (device.Name) { case "OUYA Game Controller": capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; capabilities.HasLeftTrigger = true; capabilities.HasRightTrigger = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasDPadUpButton = true; break; case "Microsoft X-Box 360 pad": capabilities.HasAButton = true; capabilities.HasBButton = true; capabilities.HasXButton = true; capabilities.HasYButton = true; capabilities.HasLeftXThumbStick = true; capabilities.HasLeftYThumbStick = true; capabilities.HasRightXThumbStick = true; capabilities.HasRightYThumbStick = true; capabilities.HasLeftShoulderButton = true; capabilities.HasRightShoulderButton = true; capabilities.HasLeftTrigger = true; capabilities.HasRightTrigger = true; capabilities.HasDPadDownButton = true; capabilities.HasDPadLeftButton = true; capabilities.HasDPadRightButton = true; capabilities.HasDPadUpButton = true; capabilities.HasStartButton = true; capabilities.HasBackButton = true; break; } return capabilities; }
private static GamePadCapabilities PlatformGetCapabilities(int index) { if (!Gamepads.ContainsKey(index)) { return(new GamePadCapabilities()); } var gamecontroller = Gamepads[index].Device; var caps = new GamePadCapabilities(); var mapping = Sdl.GameController.GetMapping(gamecontroller).Split(','); caps.IsConnected = true; caps.DisplayName = Sdl.GameController.GetName(gamecontroller); caps.Identifier = Sdl.Joystick.GetGUID(Sdl.GameController.GetJoystick(gamecontroller)).ToString(); caps.HasLeftVibrationMotor = caps.HasRightVibrationMotor = (Gamepads[index].HapticType != 0); foreach (var map in mapping) { var split = map.Split(':'); if (split.Length != 2) { continue; } switch (split[0]) { case "a": caps.HasAButton = true; break; case "b": caps.HasBButton = true; break; case "x": caps.HasXButton = true; break; case "y": caps.HasYButton = true; break; case "back": caps.HasBackButton = true; break; case "guide": caps.HasBigButton = true; break; case "start": caps.HasStartButton = true; break; case "dpleft": caps.HasDPadLeftButton = true; break; case "dpdown": caps.HasDPadDownButton = true; break; case "dpright": caps.HasDPadRightButton = true; break; case "dpup": caps.HasDPadUpButton = true; break; case "leftshoulder": caps.HasLeftShoulderButton = true; break; case "lefttrigger": caps.HasLeftTrigger = true; break; case "rightshoulder": caps.HasRightShoulderButton = true; break; case "righttrigger": caps.HasRightTrigger = true; break; case "leftstick": caps.HasLeftStickButton = true; break; case "rightstick": caps.HasRightStickButton = true; break; case "leftx": caps.HasLeftXThumbStick = true; break; case "lefty": caps.HasLeftYThumbStick = true; break; case "rightx": caps.HasRightXThumbStick = true; break; case "righty": caps.HasRightYThumbStick = true; break; } } return(caps); }