Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Enumerates the device events that are reported to a GameInputDeviceCallback function.
Syntax
enum GameInputDeviceEvent
{
GameInputDeviceEventConnected = 0,
GameInputDeviceEventDisconnected = 1,
GameInputDeviceEventKeyboardLayoutUpdated = 2,
GameInputDeviceEventHapticInfoUpdated = 3,
GameInputDeviceEventXInputIndexUpdated = 4,
};
Constants
| Constant | Description |
|---|---|
| GameInputDeviceEventConnected | The device was connected. This event is also sent once for each device that is already connected when the callback is registered with IGameInput::RegisterDeviceCallback. |
| GameInputDeviceEventDisconnected | The device was disconnected. The IGameInputDevice object remains valid, but IGameInputDevice::IsConnected returns false and the device no longer produces readings. |
| GameInputDeviceEventKeyboardLayoutUpdated | The keyboard layout of the device changed. The layout member returned by IGameInputDevice::GetKeyboardInfo now reflects the new layout. |
| GameInputDeviceEventHapticInfoUpdated | The haptic information of the device became available or unavailable. Call IGameInputDevice::GetHapticInfo to get the current haptic information. |
| GameInputDeviceEventXInputIndexUpdated | The XInput user index assigned to the device changed. Call IGameInputDevice::GetXInputDeviceIndex to get the current index. |
Remarks
This enumeration is passed as the deviceEvent parameter of the GameInputDeviceCallback function that is registered with IGameInput::RegisterDeviceCallback. Each callback invocation reports exactly one event for one device. The runtime performs the change detection, so the callback is invoked only when something actually changed.
Handle each event value explicitly. Any value other than GameInputDeviceEventConnected doesn't necessarily mean that the device was disconnected. For example, a keyboard layout or haptic information change is reported for a device that is still connected. Ignore event values that your application doesn't recognize, because new values may be added in future versions of GameInput.
Most device properties are fixed for the lifetime of an IGameInputDevice object. The keyboard layout, haptic information, XInput user index, and connection state are the exceptions, and each change is reported by one of these events.
The following example shows how to handle each event.
void CALLBACK OnDeviceEvent(
_In_ GameInputCallbackToken callbackToken,
_In_ void* context,
_In_ GameInputDeviceEvent deviceEvent,
_In_ IGameInputDevice* device)
{
switch (deviceEvent)
{
case GameInputDeviceEventConnected:
// Add the device to the application's list of devices.
break;
case GameInputDeviceEventDisconnected:
// Remove the device from the application's list of devices.
break;
case GameInputDeviceEventKeyboardLayoutUpdated:
// Refresh any cached keyboard layout by calling GetKeyboardInfo.
break;
case GameInputDeviceEventHapticInfoUpdated:
// Refresh any cached haptic information by calling GetHapticInfo.
break;
case GameInputDeviceEventXInputIndexUpdated:
// Refresh any cached XInput index by calling GetXInputDeviceIndex.
break;
default:
// Ignore events that this version of the application doesn't recognize.
break;
}
}
Requirements
Header: GameInput.h
Supported platforms: Windows, XBOX One family consoles and XBOX Series consoles
See also
Overview of GameInput
GameInput
GameInputDeviceCallback
IGameInput::RegisterDeviceCallback
IGameInputDevice::IsConnected
Version History
| Version | Changes |
|---|---|
| v4 | Introduced. |