GameInput readings
GameInput readings
The raw input packets received from every device are encapsulated in “reading” objects. Readings contain the original raw packet data, and (usually) one or more transformations of the raw data into higher-level formats. In addition to their role as data containers, readings also serve as identifiers that reference a specific position within the input stream.
Calling GetCurrentReading retrieves the most recent reading from the input stream. An optional GameInputKind filter can be passed in that limits the returned readings to specific kinds of input, such as gamepad or keyboard. An optional IGameInputDevice filter can also be passed in that limits the returned readings to only the ones that were generated by the specified device. These filters can be applied individually or together.
IGameInputReading instances are reference-counted singletons. Retrieving a reading is an extremely fast and lightweight operation - no memory allocations or copies are performed, and the API call is lock-free with no kernel mode transitions. Because readings are singletons, an application can compare the reading pointers for equality to tell whether two calls to GetCurrentReading have returned the same reading (meaning no new input was generated).
Games with less complex input needs might simply poll for new input once per frame, and compare the state stored in the two readings for differences (if they aren’t the same reading). Games with more complex input needs, however, might need to walk the input stream to get a complete picture of all the input state changes that have occurred since the previous frame. This is enabled by the GetNextReading and GetPreviousReading methods, which allow the same filters as GetCurrentReading. The input stream maintains the last half second of historical readings in its buffer.
Alternatively, applications can register a callback that’s invoked whenever input is generated. Like the previous synchronous methods, several filters can be applied to control what kinds of readings are returned, and from which devices. For more information, see GameInput callbacks in the Advanced GameInput topics section.
The kinds of data available in a reading depend on the input device and its physical properties. For example, a reading from a standard keyboard might only contain keyboard data, whereas a reading from a keyboard with an integrated trackball might contain both keyboard and mouse data.
Nearly all game controllers produce readings that contain generic “controller” data, which is simply a collection of anonymous axis and button states. This enables broad device support for applications with an input mapping UI. However, many game controllers (like gamepads) also expose familiar fixed-format state in their readings, which is much easier for typical games to consume.
The IGameInputReading interface contains methods for retrieving state in any of the formats the reading supports. All the different representations available from readings are precomputed, so these methods simply copy a few bytes of data and return.
Last modified on August 4, 2026
