共用方式為


IGameInput

A per-process singleton used to access the device input stream.

The IGameInput interface is the starting point for using the GameInput API. This interface provides methods for synchronously retrieving cached readings from the input stream (the polling API), and methods for registering asynchronous callbacks for state changes (the event-based API).

Syntax

class IGameInput : public IUnknown

Methods

Method Description
CreateAggregateDevice Creates a virtual device that aggregates all inputs of an input kind.
DisableAggregateDevice Disables aggregation of an aggregate device.
CreateDispatcher Creates a dispatcher for background tasks.
FindDeviceFromId Retrieves an IGameInputDevice interface using its identifier.
FindDeviceFromPlatformString Retrieves an IGameInputDevice interface using a matching platform string.
GetCurrentReading Gets the latest reading from the input stream that matches a specified filter.
GetCurrentTimestamp Gets the current time in microseconds.
GetNextReading Gets the next available IGameInputReading interface based on a reference reading from an optionally filtered input stream.
GetPreviousReading Gets the previous IGameInputReading based on a reference reading from an optionally filtered input stream.
RegisterDeviceCallback Registers a callback function that is called when the device status changes.
RegisterKeyboardLayoutCallback Registers a callback function for keyboard layout changes.
RegisterReadingCallback Registers a callback function that is called when a new reading is available.
RegisterSystemButtonCallback Registers a callback function for Guide or Share button press and release events.
SetFocusPolicy Sets the focus policy for a game's input devices.
StopCallback Stops a registered callback without waiting for any executing callbacks to complete.
UnregisterCallback Stops a registered callback, waiting for any executing callbacks to complete.

Requirements

Header: GameInput.h

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

Input API Overview
GameInput

Version History

Version Changes
v3 Added CreateAggregateDevice (previously E_NOTIMPL in v0, absent v1/v2). Added DisableAggregateDevice.
v1 Removed CreateAggregateDevice, EnableOemDeviceSupport, FindDeviceFromObject, FindDeviceFromPlatformHandle, GetTemporalReading, RegisterGuideButtonCallback.
v0 Introduced.

Appendix: Previous versions

v0

In addition to all methods present in the current version, the following methods existed in v0 and were removed in v1:

Method Description
CreateAggregateDevice (E_NOTIMPL) Present but returned E_NOTIMPL. Re-introduced as functional in v3.
EnableOemDeviceSupport Enabled support for OEM devices with custom protocols. This is now supported by default.
FindDeviceFromObject Retrieves a device from a platform COM object reference.
FindDeviceFromPlatformHandle Retrieves a device by platform window or file handle.
GetTemporalReading Gets a reading interpolated to a specified timestamp.
RegisterGuideButtonCallback Registers a callback for Guide/Xbox button press and release events.