GameInputDeviceCallback

Title-defined callback for device events, such as device connection and disconnection. This function is registered with IGameInput::RegisterDeviceCallback. This function is triggered by the conditions set from the registration function.

Syntax

void GameInputDeviceCallback(
    GameInputCallbackToken callbackToken,
    void* context,
    GameInputDeviceEvent deviceEvent,
    IGameInputDevice* device
);

Parameters

callbackToken   _In_
Type: GameInputCallbackToken

Callback token for the registered function. Token returned by IGameInput::RegisterDeviceCallback.

context   _In_
Type: void*

The context passed to IGameInput::RegisterDeviceCallback.

deviceEvent   _In_
Type: GameInputDeviceEvent

The event that triggered the callback.

device   _In_
Type: IGameInputDevice*

Device which triggered the callback.

Return value

This callback function doesn't return a value.

Remarks

Handle each GameInputDeviceEvent value explicitly. Don't treat every event other than GameInputDeviceEventConnected as a disconnection, because property update events such as GameInputDeviceEventKeyboardLayoutUpdated are also delivered for connected devices. Ignore event values that your application doesn't recognize.

To check whether a device is currently connected outside of a callback, call IGameInputDevice::IsConnected.

For an example, see IGameInput::RegisterDeviceCallback.

Requirements

Header: GameInput.h

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

See also

Input API Overview
GameInput
IGameInput::RegisterDeviceCallback

Version History

Version Changes
v4 Replaced the timestamp, currentStatus, and previousStatus parameters with a single deviceEvent parameter. Reordered the device parameter to follow deviceEvent.
v0 Introduced.

Appendix: Previous versions

v0, v1, v2, v3

void GameInputDeviceCallback(
    GameInputCallbackToken callbackToken,
    void* context,
    IGameInputDevice* device,
    uint64_t timestamp,
    GameInputDeviceStatus currentStatus,
    GameInputDeviceStatus previousStatus
);

timestamp   _In_
Type: uint64_t

Microsecond timestamp denoting when the status change occurred.

currentStatus   _In_
Type: GameInputDeviceStatus

Current connection and input status of the device.

previousStatus   _In_
Type: GameInputDeviceStatus

Previous connection and input status of the device.