Share via


RawGameController.HeadsetConnected Event

Definition

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

// Register
event_token HeadsetConnected(TypedEventHandler<IGameController, Headset const&> const& handler) const;

// Revoke with event_token
void HeadsetConnected(event_token const* cookie) const;

// Revoke with event_revoker
RawGameController::HeadsetConnected_revoker HeadsetConnected(auto_revoke_t, TypedEventHandler<IGameController, Headset const&> const& handler) const;
public event TypedEventHandler<IGameController,Headset> HeadsetConnected;
function onHeadsetConnected(eventArgs) { /* Your code */ }
rawGameController.addEventListener("headsetconnected", onHeadsetConnected);
rawGameController.removeEventListener("headsetconnected", onHeadsetConnected);
- or -
rawGameController.onheadsetconnected = onHeadsetConnected;
Public Custom Event HeadsetConnected As TypedEventHandler(Of IGameController, Headset) Implements HeadsetConnected

Event Type

Implements

Examples

The following example shows how to register a handler for this event.

#include <winrt/Windows.Gaming.Input.h>
using namespace winrt;
using namespace Windows::Gaming::Input;
...
RawGameController m_rawGameController{ nullptr }; // Need to initialize this to a **RawGameController** that's connected to the device.
...
m_rawGameController.HeadsetConnected([this](IGameController const& /* sender */, Headset const& /* args */)
    {
        // Enable headset capture and playback on this device.
    });
// `rawGameController` is a **RawGameController** that's connected to the device.
rawGameController.HeadsetConnected += ref new TypedEventHandler<IGameController^, Headset^>(
        [] (IGameController^ device, Headset^ headset)
{
    // Enable headset capture and playback on this device.
});

Remarks

For more information on detecting, tracking, and using headsets, see Headset.

Applies to

See also