libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::ControlPort Class Reference

Represents a single physical controller port on the console. More...

#include <ControlPort.h>

Public Member Functions

 ControlPort (uint8_t portIndex)
 Constructs an empty port with no device attached.
 
 ControlPort (uint8_t portIndex, std::shared_ptr< ControlDevice > device)
 Constructs a port with an initial device already connected.
 
 ~ControlPort ()
 
void Connect (std::shared_ptr< ControlDevice > device)
 Attaches a device to this port, replacing any previously connected device.
 
void Disconnect ()
 Detaches any device currently connected to this port.
 
std::shared_ptr< ControlDeviceGetConnectedDevice ()
 Returns the device connected to this port, or nullptr if the port is empty.
 
std::shared_ptr< ControllerGetConnectedController ()
 Returns the connected device cast to Controller, or nullptr.
 

Detailed Description

Represents a single physical controller port on the console.

A ControlPort holds a reference to the ControlDevice (usually a Controller) currently connected to it, or nullptr when the port is empty. It is owned by ControlDeck and indexed from 0.

Constructor & Destructor Documentation

◆ ControlPort() [1/2]

Ship::ControlPort::ControlPort ( uint8_t  portIndex)

Constructs an empty port with no device attached.

Parameters
portIndexZero-based port index.

◆ ControlPort() [2/2]

Ship::ControlPort::ControlPort ( uint8_t  portIndex,
std::shared_ptr< ControlDevice device 
)

Constructs a port with an initial device already connected.

Parameters
portIndexZero-based port index.
deviceDevice to connect immediately.

◆ ~ControlPort()

Ship::ControlPort::~ControlPort ( )

Member Function Documentation

◆ Connect()

void Ship::ControlPort::Connect ( std::shared_ptr< ControlDevice device)

Attaches a device to this port, replacing any previously connected device.

Parameters
deviceDevice to connect; pass nullptr to disconnect.

◆ Disconnect()

void Ship::ControlPort::Disconnect ( )

Detaches any device currently connected to this port.

◆ GetConnectedController()

std::shared_ptr< Controller > Ship::ControlPort::GetConnectedController ( )

Returns the connected device cast to Controller, or nullptr.

Convenience wrapper around GetConnectedDevice() that performs a dynamic cast.

◆ GetConnectedDevice()

std::shared_ptr< ControlDevice > Ship::ControlPort::GetConnectedDevice ( )

Returns the device connected to this port, or nullptr if the port is empty.


The documentation for this class was generated from the following file: