Compartir a través de


RawGameController.RawGameControllerAdded Evento

Definición

Indica cuándo se conecta un nuevo controlador de juego sin procesar.

// 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) 

Tipo de evento

Ejemplos

En el ejemplo siguiente se inicia el seguimiento de un controlador de juego sin procesar que se ha agregado.

#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);
});

Comentarios

Para identificar los controladores que ya se han agregado, consulta la lista de controladores conectados mediante RawGameController.RawGameControllers. Sin embargo, dado que es posible que solo te interesen algunos de los controladores de juegos sin procesar conectados, te recomendamos que mantengas tu propia colección en lugar de acceder a ellos a través de RawGameControllers.

Se aplica a