Share via


InputInjector.InitializeGamepadInjection Method

Definition

Initializes a virtual gamepad device that can synthesize input events and provide corresponding input data to the system.

public:
 virtual void InitializeGamepadInjection() = InitializeGamepadInjection;
void InitializeGamepadInjection();
public void InitializeGamepadInjection();
function initializeGamepadInjection()
Public Sub InitializeGamepadInjection ()

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Examples

Here are some downloadable samples demonstrating basic input and input injection:

Remarks

Important

The APIs in this namespace require the inputInjectionBrokered restricted capability.

Using input injection requires the following be added to the Package.appxmanifest:

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

Calling this method is analogous to connecting a physical gamepad, which also triggers a GamepadAdded event.

A physical gamepad is assigned a persistent unique ID (see NonRoamableId) that does not change when the device is connected and disconnected. Similarly, a virtual gamepad created with InitializeGamepadInjection is also assigned a unique ID that persists across calls to UninitializeGamepadInjection and InitializeGamepadInjection for the same InputInjector instance.

Applies to

See also