Share via


GameControllerFactoryManager.TryGetFactoryControllerFromGameController Method

Definition

Tries to get a game controller that belongs to the specified factory and references the same underlying game controller as the one that was specified.

public:
 static IGameController ^ TryGetFactoryControllerFromGameController(ICustomGameControllerFactory ^ factory, IGameController ^ gameController);
 static IGameController TryGetFactoryControllerFromGameController(ICustomGameControllerFactory const& factory, IGameController const& gameController);
public static IGameController TryGetFactoryControllerFromGameController(ICustomGameControllerFactory factory, IGameController gameController);
function tryGetFactoryControllerFromGameController(factory, gameController)
Public Shared Function TryGetFactoryControllerFromGameController (factory As ICustomGameControllerFactory, gameController As IGameController) As IGameController

Parameters

factory
ICustomGameControllerFactory

The factory for the type of game controller that you want to get.

gameController
IGameController

The game controller that references the underlying device for which you want to get another game controller representation.

Returns

If found, a game controller that belongs to the specified factory and references the same underlying device as the specified game controller; otherwise, null.

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)

Remarks

This method provides the implementation for each game controller class's FromGameController method. A class's FromGameController method allows you to pass in an instance of one game controller class, and get an object from another game controller class that references the same underlying device. For example, if you have an ArcadeStick and you want to get a RawGameController representation of that same underlying controller, you would call RawGameController.FromGameController, passing in the ArcadeStick (which you can do, since the method takes an IGameController object, and ArcadeStick inherits from IGameController). Your custom game controller classes must also inherit from IGameController.

Since each game controller class implements ICustomGameControllerFactory (including your own custom classes), you can pass the factory for the game controller class that you want into GameControllerFactoryManager.TryGetFactoryControllerFromGameController, and then the GameControllerFactoryManager can try to return an object of that class that references the same underlying device as the game controller that you specified.

Applies to

See also