RawGameController.HeadsetDisconnected 事件

定義

當頭戴裝置與原始遊戲控制器中斷連線時發出訊號。

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

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

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

事件類型

實作

範例

下列範例示範如何註冊此事件的處理常式。

#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.HeadsetDisconnected([this](IGameController const& /* sender */, Headset const& /* args */)
    {
        // Disable headset capture and playback on this device.
    });
// `rawGameController` is a **RawGameController** that's connected to the device.
rawGameController.HeadsetDisconnected += ref new TypedEventHandler<IGameController^, Headset^>(
        [] (IGameController^ device, Headset^ headset)
{
    // DIsable headset capture and playback on this device.
});

備註

如需偵測、追蹤和使用頭戴式裝置的詳細資訊,請參閱 頭戴式裝置

適用於

另請參閱