RawGameController RawGameController RawGameController RawGameController RawGameController Class

Definition

Represents any type of game controller.

public : sealed class RawGameController : IGameController, IGameControllerBatteryInfo, IRawGameController, IRawGameController2
struct winrt::Windows::Gaming::Input::RawGameController : IGameController, IGameControllerBatteryInfo, IRawGameController, IRawGameController2
public sealed class RawGameController : IGameController, IGameControllerBatteryInfo, IRawGameController, IRawGameController2
Public NotInheritable Class RawGameController Implements IGameController, IGameControllerBatteryInfo, IRawGameController, IRawGameController2
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Examples

The following code snippet shows how to loop through the RawGameController.RawGameControllers list and add each RawGameController to a vector. You'll need to put a lock on the vector, because things can change at any time (a controller might be disconnected or reconnected, for example).

void GetRawGameControllers()
{
    auto myControllers{ std::vector<RawGameController>() };
    critical_section myLock{};

    for (auto controller : RawGameController::RawGameControllers())
    {
        // Check if the controller is already in myControllers; if it isn't, add it.
        critical_section::scoped_lock lock{ myLock };
        auto it = std::find(begin(myControllers), end(myControllers), controller);

        if (it == end(myControllers))
        {
            // This code assumes that you're interested in all controllers.
            myControllers.emplace_back(controller);
        }
    }
}

Remarks

Instances of the RawGameController class cannot be created directly; instead, instances of the class are retrieved through the RawGameController.RawGameControllers property listing all connected game controllers or through the RawGameController.RawGameControllerAdded event.

All inputs available on a RawGameController are exposed as simple arrays of unnamed buttons, switches, and axes. Using this class, you can allow customers to create custom input mappings no matter what type of controller they're using.

You'll need to create these arrays yourself, and then populate them using RawGameController.GetCurrentReading to determine the states of the buttons, switches, and axes. See that function's documentation for more information.

See Raw game controller for information about how to use the RawGameController class.

Properties

AxisCount AxisCount AxisCount AxisCount AxisCount

The number of axes on the raw game controller.

ButtonCount ButtonCount ButtonCount ButtonCount ButtonCount

The number of buttons on the raw game controller.

DisplayName DisplayName DisplayName DisplayName DisplayName

The name of the controller, provided by the hardware.

ForceFeedbackMotors ForceFeedbackMotors ForceFeedbackMotors ForceFeedbackMotors ForceFeedbackMotors

The list of force feedback motors in the raw game controller.

HardwareProductId HardwareProductId HardwareProductId HardwareProductId HardwareProductId

The hardware product ID of the raw game controller.

HardwareVendorId HardwareVendorId HardwareVendorId HardwareVendorId HardwareVendorId

The hardware vendor ID of the raw game controller.

Headset Headset Headset Headset Headset

The audio headset attached to the raw game controller.

IsWireless IsWireless IsWireless IsWireless IsWireless

Gets a value that indicates the wireless state of the raw game controller.

NonRoamableId NonRoamableId NonRoamableId NonRoamableId NonRoamableId

A unique ID that identifies the controller. As long as the controller is connected, the ID will never change.

RawGameControllers RawGameControllers RawGameControllers RawGameControllers RawGameControllers

The list of all connected raw game controllers.

SimpleHapticsControllers SimpleHapticsControllers SimpleHapticsControllers SimpleHapticsControllers SimpleHapticsControllers

A collection of SimpleHapticsController objects representing all available haptic feedback motors available on the device.

SwitchCount SwitchCount SwitchCount SwitchCount SwitchCount

The number of switches on the raw game controller.

User User User User User

The user associated with the raw game controller.

Methods

FromGameController(IGameController) FromGameController(IGameController) FromGameController(IGameController) FromGameController(IGameController) FromGameController(IGameController)

Returns the given game controller as a raw game controller.

GetButtonLabel(Int32) GetButtonLabel(Int32) GetButtonLabel(Int32) GetButtonLabel(Int32) GetButtonLabel(Int32)

Retrieves the button label for the specified button.

GetCurrentReading(Boolean[], GameControllerSwitchPosition[], Double[]) GetCurrentReading(Boolean[], GameControllerSwitchPosition[], Double[]) GetCurrentReading(Boolean[], GameControllerSwitchPosition[], Double[]) GetCurrentReading(Boolean[], GameControllerSwitchPosition[], Double[]) GetCurrentReading(Boolean[], GameControllerSwitchPosition[], Double[])

Gets a snapshot of the raw game controller's state.

GetSwitchKind(Int32) GetSwitchKind(Int32) GetSwitchKind(Int32) GetSwitchKind(Int32) GetSwitchKind(Int32)

Gets the type of the specified switch on the raw game controller.

TryGetBatteryReport() TryGetBatteryReport() TryGetBatteryReport() TryGetBatteryReport() TryGetBatteryReport()

Gets information about the raw game controller's current battery state.

Events

HeadsetConnected HeadsetConnected HeadsetConnected HeadsetConnected HeadsetConnected

Signals when a headset is attached to the raw game controller.

HeadsetDisconnected HeadsetDisconnected HeadsetDisconnected HeadsetDisconnected HeadsetDisconnected

Signals when a headset is disconnected from the raw game controller.

RawGameControllerAdded RawGameControllerAdded RawGameControllerAdded RawGameControllerAdded RawGameControllerAdded

Signals when a new raw game controller is connected.

RawGameControllerRemoved RawGameControllerRemoved RawGameControllerRemoved RawGameControllerRemoved RawGameControllerRemoved

Signals when a raw game controller is disconnected.

UserChanged UserChanged UserChanged UserChanged UserChanged

Signals when the user associated with the raw game controller has changed.

See Also