RawGameController.RawGameControllerAdded 이벤트

정의

새 원시 게임 컨트롤러가 연결되면 신호를 보냅니다.

// Register
static event_token RawGameControllerAdded(EventHandler<RawGameController> const& handler) const;

// Revoke with event_token
static void RawGameControllerAdded(event_token const* cookie) const;

// Revoke with event_revoker
static RawGameController::RawGameControllerAdded_revoker RawGameControllerAdded(auto_revoke_t, EventHandler<RawGameController> const& handler) const;
public static event System.EventHandler<RawGameController> RawGameControllerAdded;
function onRawGameControllerAdded(eventArgs) { /* Your code */ }
Windows.Gaming.Input.RawGameController.addEventListener("rawgamecontrolleradded", onRawGameControllerAdded);
Windows.Gaming.Input.RawGameController.removeEventListener("rawgamecontrolleradded", onRawGameControllerAdded);
- or -
Windows.Gaming.Input.RawGameController.onrawgamecontrolleradded = onRawGameControllerAdded;
Public Shared Custom Event RawGameControllerAdded As EventHandler(Of RawGameController) 

이벤트 유형

예제

다음 예제에서는 추가된 원시 게임 컨트롤러 추적을 시작합니다.

#include <winrt/Windows.Gaming.Input.h>
using namespace winrt;
using namespace Windows::Gaming::Input;
...
std::vector<RawGameController> m_myRawGameControllers;
...
RawGameController::RawGameControllerAdded([this](IInspectable const& /* sender */, RawGameController const& args)
    {
        m_myRawGameControllers.push_back(args);
    });
// `myRawGameControllers` is a `Vector<RawGameController^>` that contains the raw game controllers that your game is tracking.
RawGameController::RawGameControllerAdded += ref new EventHandler<RawGameController^>(
		[] (Platform::Object^, RawGameController^ args)
{
    // This code assumes that you're interested in all new raw game controllers.
    myRawGameControllers->Append(args);
});

설명

이미 추가된 컨트롤러를 식별하려면 RawGameController.RawGameControllers를 사용하여 연결된 컨트롤러 목록을 쿼리합니다. 그러나 연결된 원시 게임 컨트롤러 중 일부에만 관심이 있을 수 있으므로 RawGameControllers를 통해 액세스하는 대신 고유한 컬렉션을 유지하는 것이 좋습니다.

적용 대상