Overview of User Input and Input Devices
Input is a general term referring to the process of receiving actions from the user. In XNA Game Studio, the Microsoft.Xna.Framework.Input namespace provides support for most input devices.
|Methods related to input devices unavailable on the platform your game is running on are always available to your code. For example, you can access all GamePad methods on Windows Phone, but they will not return valid information. Although using these methods will not cause exceptions or build errors in your code, they will silently fail when run.|
Input Device and Platform Compatibility
Although the complete Input API is available to your code on any platform, input devices will often apply to just one or a couple of platforms. It's useful to familiarize yourself with what devices are available for each platform supported by XNA Game Studio.
The following table lists the input devices available for each platform.
|Input device||Windows Phone||Xbox 360||Windows|
* Only the Back button can be detected on Windows Phone.
Windows Phone Platform Notes
Physical keyboards may or may not be present on Windows Phone devices; you should not rely on the presence of a physical keyboard. For text input, you should use a software input panel (SIP), which will work on all devices, including those with physical keyboards. For more information, see Displaying a Software Input Panel (Windows Phone, Xbox 360).
If the Windows Phone device does have a physical keyboard, the same methods used for keyboards on Windows or Xbox 360 can be used, given a few caveats. For more information, see Working with Hardware Keyboards (Windows Phone).
Mouse methods may be used to track the position of the primary touchpoint on a Windows Phone device's touchpanel, which can simplify your code if you're interested in only one touchpoint on a multitouch device. For more information, see Getting the Mouse Position (Windows, Windows Phone).
For Windows Phone's multitouch device, you can use the raw touch data provided by the TouchPanel class, but you can also use 's support for predefined gestures if your input fits one of the supported gesture types. For information about working with raw multitouch input, see Working with Touch Input (Windows Phone). For information about gesture support, see Detecting Gestures on a Multitouch Screen (Windows Phone).
An Accelerometer API is not provided by XNA Game Studio. For more information about how to use Silverlight's Accelerometer class with XNA Game Studio, see Retrieving Accelerometer Input (Windows Phone).
The microphone on Windows Phone can be used to capture audio that can be used in your game. For more information, see Recording Sounds with Microphones.
Xbox 360 Platform Notes
For information about working with the Xbox 360 gamepad, see Detecting Xbox 360 Controller Button Presses (Xbox 360, Windows), Detecting an Xbox 360 Controller Button Press in the Current Frame (Xbox 360, Windows), and Determining If an Xbox 360 Controller Is Disconnected (Xbox 360, Windows).
For information about working with alternative input devices such as dance pads, guitar controllers, flight sticks, and racing wheels on Xbox 360, see Using Alternative Input Devices (Xbox 360). Kinect is not currently supported by XNA Game Studio.
For information about support for microphones and headsets on Xbox 360, see Recording Sounds with Microphones.
Windows Platform Notes
For information about handling mouse input on Windows, see Getting the Mouse Position (Windows, Windows Phone).
For information about handling keyboard input on Windows, see Detecting a Key Press (Windows, Windows Phone, Xbox 360).
For information about support for microphones and headsets on Windows, see Recording Sounds with Microphones