|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Represents a single logical controller connected to a ControlPort. More...
#include <Controller.h>
Public Member Functions | |
| void | SetControlDeck (std::shared_ptr< ControlDeck > controlDeck) |
| Injects the owning ControlDeck into this controller and all of its subsystems. | |
| Controller (uint8_t portIndex, std::vector< CONTROLLERBUTTONS_T > bitmasks, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr, std::shared_ptr< ControlDeck > controlDeck=nullptr, std::shared_ptr< Window > window=nullptr) | |
| Constructs a Controller for the given port with a set of button bitmasks. | |
| ~Controller () | |
| Destroys the Controller and releases all mapping resources. | |
| void | ReloadAllMappingsFromConfig () |
| Discards all in-memory mappings and reloads them from Config. | |
| bool | IsConnected () const |
| Returns true if at least one physical device mapping is active for any button. | |
| void | Connect () |
| Marks the controller as "connected" (used by the mapping layer). | |
| void | Disconnect () |
| Marks the controller as "disconnected" and clears transient state. | |
| void | ClearAllMappings () |
| Removes all mappings for all buttons, sticks, rumble, LED, and gyro. | |
| void | ClearAllMappingsForDeviceType (PhysicalDeviceType physicalDeviceType) |
| Removes all mappings that target the given physical device type. | |
| void | AddDefaultMappings (PhysicalDeviceType physicalDeviceType) |
| Applies the default mappings for the given physical device type. | |
| std::unordered_map< CONTROLLERBUTTONS_T, std::shared_ptr< ControllerButton > > | GetAllButtons () |
| Returns the full bitmask→ControllerButton map. | |
| std::shared_ptr< ControllerButton > | GetButtonByBitmask (CONTROLLERBUTTONS_T bitmask) |
| Returns the ControllerButton for the given bitmask, or nullptr if not found. | |
| std::shared_ptr< ControllerButton > | GetButton (CONTROLLERBUTTONS_T bitmask) |
| Alias of GetButtonByBitmask(). | |
| std::shared_ptr< ControllerStick > | GetLeftStick () |
| Returns the left analog stick input aggregator. | |
| std::shared_ptr< ControllerStick > | GetRightStick () |
| Returns the right analog stick input aggregator. | |
| std::shared_ptr< ControllerGyro > | GetGyro () |
| Returns the gyroscope input aggregator. | |
| std::shared_ptr< ControllerRumble > | GetRumble () |
| Returns the rumble output aggregator. | |
| std::shared_ptr< ControllerLED > | GetLED () |
| Returns the LED output aggregator. | |
| virtual void | ReadToPad (void *pad)=0 |
| Reads aggregated input state and writes it to the game-specific pad structure. | |
| bool | HasConfig () |
| Returns true if any Config key exists for this controller's mappings. | |
| uint8_t | GetPortIndex () |
| Returns the zero-based port index this controller is bound to. | |
| std::vector< std::shared_ptr< ControllerMapping > > | GetAllMappings () |
| Returns a flat list of all ControllerMapping instances across all subsystems. | |
| bool | ProcessKeyboardEvent (KbEventType eventType, KbScancode scancode) |
| Forwards a keyboard event to all button and stick mappings. | |
| bool | ProcessMouseButtonEvent (bool isPressed, MouseBtn button) |
| Forwards a mouse-button event to all button and stick mappings. | |
| bool | HasMappingsForPhysicalDeviceType (PhysicalDeviceType physicalDeviceType) |
| Returns true if any mapping for this controller targets the given physical device type. | |
Public Member Functions inherited from Ship::ControlDevice | |
| ControlDevice (uint8_t portIndex) | |
| Constructs a ControlDevice bound to the given port. | |
| virtual | ~ControlDevice () |
Protected Attributes | |
| std::unordered_map< CONTROLLERBUTTONS_T, std::shared_ptr< ControllerButton > > | mButtons |
| Button subsystems keyed by bitmask. | |
| std::shared_ptr< ConsoleVariable > | mConsoleVariable |
| Cached ConsoleVariable component. | |
| std::shared_ptr< ControlDeck > | mControlDeck |
| std::shared_ptr< Window > | mWindow |
Protected Attributes inherited from Ship::ControlDevice | |
| uint8_t | mPortIndex |
| Zero-based port index this device is connected to. | |
Represents a single logical controller connected to a ControlPort.
Controller aggregates a set of ControllerButton, two ControllerStick, a ControllerGyro, a ControllerRumble, and a ControllerLED — each of which holds a collection of ControllerMapping instances that translate physical device events into logical input.
Subclass Controller and implement ReadToPad() to convert the aggregated input state into whatever structure the game expects (e.g. an N64 OSContPad).
Mappings are persisted in Config under a key derived from the port index and are (re-)loaded via ReloadAllMappingsFromConfig().
| Ship::Controller::Controller | ( | uint8_t | portIndex, |
| std::vector< CONTROLLERBUTTONS_T > | bitmasks, | ||
| std::shared_ptr< ConsoleVariable > | consoleVariable = nullptr, |
||
| std::shared_ptr< ControlDeck > | controlDeck = nullptr, |
||
| std::shared_ptr< Window > | window = nullptr |
||
| ) |
Constructs a Controller for the given port with a set of button bitmasks.
| portIndex | Zero-based port index. |
| bitmasks | All button bitmasks this controller should track (one ControllerButton per entry). |
| consoleVariable | Optional ConsoleVariable dependency; falls back to Context lookup if nullptr. |
| Ship::Controller::~Controller | ( | ) |
Destroys the Controller and releases all mapping resources.
| void Ship::Controller::AddDefaultMappings | ( | PhysicalDeviceType | physicalDeviceType | ) |
Applies the default mappings for the given physical device type.
| physicalDeviceType | Device type to apply defaults for. |
| void Ship::Controller::ClearAllMappings | ( | ) |
Removes all mappings for all buttons, sticks, rumble, LED, and gyro.
| void Ship::Controller::ClearAllMappingsForDeviceType | ( | PhysicalDeviceType | physicalDeviceType | ) |
Removes all mappings that target the given physical device type.
| physicalDeviceType | Type of device whose mappings should be cleared (e.g. keyboard, SDL gamepad). |
| void Ship::Controller::Connect | ( | ) |
Marks the controller as "connected" (used by the mapping layer).
| void Ship::Controller::Disconnect | ( | ) |
Marks the controller as "disconnected" and clears transient state.
| std::unordered_map< CONTROLLERBUTTONS_T, std::shared_ptr< ControllerButton > > Ship::Controller::GetAllButtons | ( | ) |
Returns the full bitmask→ControllerButton map.
| std::vector< std::shared_ptr< ControllerMapping > > Ship::Controller::GetAllMappings | ( | ) |
Returns a flat list of all ControllerMapping instances across all subsystems.
| std::shared_ptr< ControllerButton > Ship::Controller::GetButton | ( | CONTROLLERBUTTONS_T | bitmask | ) |
Alias of GetButtonByBitmask().
| bitmask | Single-bit button bitmask. |
| std::shared_ptr< ControllerButton > Ship::Controller::GetButtonByBitmask | ( | CONTROLLERBUTTONS_T | bitmask | ) |
Returns the ControllerButton for the given bitmask, or nullptr if not found.
| bitmask | Single-bit button bitmask. |
| std::shared_ptr< ControllerGyro > Ship::Controller::GetGyro | ( | ) |
Returns the gyroscope input aggregator.
| std::shared_ptr< ControllerLED > Ship::Controller::GetLED | ( | ) |
Returns the LED output aggregator.
| std::shared_ptr< ControllerStick > Ship::Controller::GetLeftStick | ( | ) |
Returns the left analog stick input aggregator.
| uint8_t Ship::Controller::GetPortIndex | ( | ) |
Returns the zero-based port index this controller is bound to.
| std::shared_ptr< ControllerStick > Ship::Controller::GetRightStick | ( | ) |
Returns the right analog stick input aggregator.
| std::shared_ptr< ControllerRumble > Ship::Controller::GetRumble | ( | ) |
Returns the rumble output aggregator.
| bool Ship::Controller::HasConfig | ( | ) |
Returns true if any Config key exists for this controller's mappings.
| bool Ship::Controller::HasMappingsForPhysicalDeviceType | ( | PhysicalDeviceType | physicalDeviceType | ) |
Returns true if any mapping for this controller targets the given physical device type.
| physicalDeviceType | Device type to query. |
| bool Ship::Controller::IsConnected | ( | ) | const |
Returns true if at least one physical device mapping is active for any button.
| bool Ship::Controller::ProcessKeyboardEvent | ( | KbEventType | eventType, |
| KbScancode | scancode | ||
| ) |
Forwards a keyboard event to all button and stick mappings.
| eventType | Key-down or key-up. |
| scancode | Platform-independent scan code. |
| bool Ship::Controller::ProcessMouseButtonEvent | ( | bool | isPressed, |
| MouseBtn | button | ||
| ) |
Forwards a mouse-button event to all button and stick mappings.
| isPressed | true for button-down, false for button-up. |
| button | Mouse button identifier. |
|
pure virtual |
Reads aggregated input state and writes it to the game-specific pad structure.
Must be implemented by a game-specific subclass.
| pad | Pointer to the game's pad buffer for this controller's port. |
Implemented in LUS::Controller.
| void Ship::Controller::ReloadAllMappingsFromConfig | ( | ) |
Discards all in-memory mappings and reloads them from Config.
Called on startup and whenever the user saves mapping changes.
| void Ship::Controller::SetControlDeck | ( | std::shared_ptr< ControlDeck > | controlDeck | ) |
Injects the owning ControlDeck into this controller and all of its subsystems.
|
protected |
Button subsystems keyed by bitmask.
|
protected |
Cached ConsoleVariable component.
|
protected |
|
protected |