Share via


XInput Controller

Glossary Item Box

VPL User Interface Services: Game Controller

See Also Microsoft Robotics Developer Studio Send feedback on this topic

XInput Controller

XInput Controller Icon

The Xbox 360 console uses a gaming controller that is compatible with Windows. You can use the XInput Controller service to communicate with these controllers when they are plugged into a Windows PC; up to four unique controllers can be plugged in at a time. (XInput is an API, Application Programming Interface, that is part of DirectX.) Using this service, any connected Xbox 360 controller can be queried for its state, and vibration effects can be set.

You will need an Xbox 360 Controlller or other controller that is compatible with XInput to use this service. Xbox 360 controllers come in wired (USB) and wireless forms. If you have a conventional joystick, look at the Game Controller service instead. Note that the Xbox 360 controller will also work with the Game Controller service as a joystick.

Dd145260.hs-caution(en-us,MSDN.10).gif

If you have previously paired a wireless control with an Xbox 360, you may need to re-pair it to work with your PC. Also note that if you are unable to pair, it may be due to interference from other wireless devices. For further information on using an Xbox 360 Controller with you PC, check the support information (e.g. https://support.microsoft.com/kb/906947?sd=xbox).
Drivers for the Xbox 360 Controller are not included in the RDS package. The drivers are available via Windows Update.

Operations

Xbox 360 controllers typically have two analog directional sticks, each with a digital button, two analog triggers, a digital directional pad with four directions, and eight digital buttons. The XInput Controller service provides the following operations to access the state of a controller.

Operation Description
ButtonsChanged Indicates when one or more buttons are pressed or released.
ControllerChanged Send this message to change which controller this service instance is using. This notification is sent when the controller is changed or when the controller is connected or disconnected.
DPadChanged Indicates when the directional pad position is changed.
Get Returns the current state of the controller service.
Poll Requests the controller to read current values. However, you do not need to issue this request because the service updates itself 20 times per second.
QueryControllers Returns a list of attached controllers.
Replace Configures a controller or indicates when the controller's state has changed. This notification is also generated when service receives a subscription request (has a connection to its notifications).
SetVibration Sets the amount of vibration in the left and right rumble motors. The left motor is the low-frequency rumble motor. The right motor is the high-frequency rumble motor. This notification is sent when the vibration settings are changed.
ThumbsticksChanged Indicates when a thumbstick position is changed.
TriggersChanged Indicates when the position of a Point-Of-View (POV) hat switch is changed.

Get, Poll, and QueryControllers are supported as requests only (no notifications are generated).

Service State

The XInput Controller service state contains the following properties. Note that each of the different fields has its own data type. All of the types associated with input devices have a TimeStamp property.

Name Type Description
Buttons Buttons Current state of all the buttons. See below.
Controller Controller Information about the current controller.
DPad DPad Current direction of the DPad as a set of Boolean fields: Left, Down, Right, Up.
Thumbsticks Thumbsticks Contains two sets of float values: LeftX, LeftY and RightX, RightY.
Triggers Triggers Current positions of the triggers as floats: Left and Right.
Vibration Vibration Current values of the vibration motors as floats: Left and Right.
TimeStamp DateTime The timestamp of the most recent update.

The values returned in the controller state are also accessible through the notifications and requests (i.e. SetVibrationMotor) provided for the individual controller components.

Buttons (and the ButtonsChanged notification) returns a set of Boolean values corresponding to the controller's buttons and the timestamp of the button reading. If a button's state is True the button was pressed.

Name Type Description
A Boolean Indicates if the A button on the controller was pressed.
B Boolean Indicates if the B button on the controller was pressed.
X Boolean Indicates if the X button on the controller was pressed.
Y Boolean Indicates if the Y button on the controller was pressed.
Back Boolean Indicates if the Back button on the controller was pressed.
Start Boolean Indicates if the Start button on the controller was pressed.
LeftStick Boolean Indicates if the left thumbstick on the controller was pressed.
RightStick Boolean Indicates if the right thumbstick on the controller was pressed.
LeftShoulder Boolean Indicates if the left shoulder (bumper) button on the controller was pressed.
RightShoulder Boolean Indicates if the right shoulder (bumper) button on the controller was pressed.
TimeStamp DateTime Indicates the timestamp of the current reading.

Controller (and the ControllerChanged notification) returns the following values.

Name Type Description
IsConnected Boolean Indicates if a controller is connected.
PlayerIndex PlayerIndex Indicates which player the controller represents. The choices are 0-3.
TimeStamp DateTiime Indicates the timestamp of the current reading.

Each controller displays which ID it is using by lighting up a quadrant on the "ring of light" in the center of the controller. The PlayIndex can be set on the service's initial configuration, either by another service or by explicitly setting its Configuration properties.

DPad (and the DPadChanged notification) returns the following values.

Name Type Description
Down Boolean Indicates if the direction pad was moved down.
Left Boolean Indicates if the direction pad was moved left.
Right Boolean Indicates if the direction pad was moved right.
Up Boolean Indicates if the direction pad was moved up.
TimeStamp DateTime Indicates the timestamp of the current reading.

Thumbsticks (and the ThumbsticksChanged notification) returns the following values.

Name Type Description
LeftX float Indicates the X value of the left thumbstick.
LeftY float Indicates the Y value of the left thumbstick.
RightX float Indicates the X value of the right thumbstick..
RightY float Indicates the Y value of the right thumbstick.
TimeStamp DateTime Indicates the timestamp of the current reading.

Triggers (and the TriggersChanged notification) returns the following values.

Name Type Description
Left float Indicates the current reading of the left trigger.
Right float Indicates the current reading of the right trigger.
TimeStamp DateTime Indicates the timestamp of the current reading.

Vibration (and the SetVibrationMotor notification) returns the following values.

Name Type Description
Left float Indicates the current reading of the left vibration motor.
Right float Indicates the current reading of the right vibration motor.
TimeStamp DateTime Indicates the timestamp of the current reading.

 

See Also 

VPL User Interface Services: Game Controller

 

 

© 2012 Microsoft Corporation. All Rights Reserved.