|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Aggregates all ControllerButtonMapping instances for a single logical button. More...
#include <ControllerButton.h>
Public Member Functions | |
| void | SetControlDeck (std::shared_ptr< ControlDeck > controlDeck) |
| Injects the owning ControlDeck. | |
| ControllerButton (uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr, std::shared_ptr< ControlDeck > controlDeck=nullptr, std::shared_ptr< Window > window=nullptr) | |
| Constructs a ControllerButton for a specific port and bitmask. | |
| ~ControllerButton () | |
| std::shared_ptr< ControllerButtonMapping > | GetButtonMappingById (std::string id) |
| Returns the mapping with the given unique ID, or nullptr if not found. | |
| std::unordered_map< std::string, std::shared_ptr< ControllerButtonMapping > > | GetAllButtonMappings () |
| Returns a copy of the full id → mapping map. | |
| void | AddButtonMapping (std::shared_ptr< ControllerButtonMapping > mapping) |
| Adds a new mapping to this button's collection. | |
| void | ClearButtonMappingId (std::string id) |
| Removes the ID from Config without destroying the in-memory mapping object. | |
| void | ClearButtonMapping (std::string id) |
| Removes the mapping with the given ID from both the in-memory map and Config. | |
| void | ClearButtonMapping (std::shared_ptr< ControllerButtonMapping > mapping) |
| Removes the given mapping instance from both the in-memory map and Config. | |
| void | AddDefaultMappings (PhysicalDeviceType physicalDeviceType) |
| Applies the default mappings for the given physical device type. | |
| void | LoadButtonMappingFromConfig (std::string id) |
Loads the mapping identified by id from Config and adds it to the collection. | |
| void | SaveButtonMappingIdsToConfig () |
| Writes the current set of mapping IDs to Config so they can be reloaded later. | |
| void | ReloadAllMappingsFromConfig () |
| Clears all in-memory mappings and reloads them from Config. | |
| void | ClearAllButtonMappings () |
| Removes every in-memory mapping (does not touch Config). | |
| void | ClearAllButtonMappingsForDeviceType (PhysicalDeviceType physicalDeviceType) |
| Removes all mappings that target the given physical device type. | |
| bool | AddOrEditButtonMappingFromRawPress (CONTROLLERBUTTONS_T bitmask, std::string id) |
| Listens for the next raw physical input and adds or replaces a mapping for it. | |
| void | UpdatePad (CONTROLLERBUTTONS_T &padButtons) |
Evaluates all active mappings and sets the corresponding bits in padButtons. | |
| bool | ProcessKeyboardEvent (KbEventType eventType, KbScancode scancode) |
| Forwards a keyboard event to all mappings that handle keyboard input. | |
| bool | ProcessMouseButtonEvent (bool isPressed, Ship::MouseBtn button) |
| Forwards a mouse-button event to all mappings that handle mouse input. | |
| bool | HasMappingsForPhysicalDeviceType (PhysicalDeviceType physicalDeviceType) |
| Returns true if any mapping targets the given physical device type. | |
Aggregates all ControllerButtonMapping instances for a single logical button.
ControllerButton represents one digital button bitmask on a Controller (e.g. the A button). It can hold multiple ControllerButtonMapping instances simultaneously, allowing the same logical button to be triggered by a keyboard key, a gamepad face button, or a mouse click all at the same time.
Mappings are persisted in Config and can be loaded/saved via the Config methods. The class also supports "listen for raw press" mode, where the next physical input received is automatically captured as a new mapping.
| Ship::ControllerButton::ControllerButton | ( | uint8_t | portIndex, |
| CONTROLLERBUTTONS_T | bitmask, | ||
| std::shared_ptr< ConsoleVariable > | consoleVariable = nullptr, |
||
| std::shared_ptr< ControlDeck > | controlDeck = nullptr, |
||
| std::shared_ptr< Window > | window = nullptr |
||
| ) |
Constructs a ControllerButton for a specific port and bitmask.
| portIndex | Zero-based port index. |
| bitmask | Single-bit bitmask representing this button (e.g. 0x0001 for A). |
| consoleVariable | Optional ConsoleVariable dependency; falls back to Context lookup if nullptr. |
| Ship::ControllerButton::~ControllerButton | ( | ) |
| void Ship::ControllerButton::AddButtonMapping | ( | std::shared_ptr< ControllerButtonMapping > | mapping | ) |
Adds a new mapping to this button's collection.
| mapping | Mapping to add. Its ID must be unique within this button. |
| void Ship::ControllerButton::AddDefaultMappings | ( | PhysicalDeviceType | physicalDeviceType | ) |
Applies the default mappings for the given physical device type.
| physicalDeviceType | Type of device (keyboard, SDL gamepad, etc.). |
| bool Ship::ControllerButton::AddOrEditButtonMappingFromRawPress | ( | CONTROLLERBUTTONS_T | bitmask, |
| std::string | id | ||
| ) |
Listens for the next raw physical input and adds or replaces a mapping for it.
If id is non-empty, the existing mapping with that ID is replaced; otherwise a new mapping is created.
| bitmask | Button bitmask to associate with the captured input. |
| id | Optional UUID of an existing mapping to replace. |
| void Ship::ControllerButton::ClearAllButtonMappings | ( | ) |
Removes every in-memory mapping (does not touch Config).
| void Ship::ControllerButton::ClearAllButtonMappingsForDeviceType | ( | PhysicalDeviceType | physicalDeviceType | ) |
Removes all mappings that target the given physical device type.
| physicalDeviceType | Device type whose mappings should be cleared. |
| void Ship::ControllerButton::ClearButtonMapping | ( | std::shared_ptr< ControllerButtonMapping > | mapping | ) |
Removes the given mapping instance from both the in-memory map and Config.
| mapping | Mapping to remove. |
| void Ship::ControllerButton::ClearButtonMapping | ( | std::string | id | ) |
Removes the mapping with the given ID from both the in-memory map and Config.
| id | Mapping UUID to remove. |
| void Ship::ControllerButton::ClearButtonMappingId | ( | std::string | id | ) |
Removes the ID from Config without destroying the in-memory mapping object.
| id | Mapping UUID to unregister. |
| std::unordered_map< std::string, std::shared_ptr< ControllerButtonMapping > > Ship::ControllerButton::GetAllButtonMappings | ( | ) |
Returns a copy of the full id → mapping map.
| std::shared_ptr< ControllerButtonMapping > Ship::ControllerButton::GetButtonMappingById | ( | std::string | id | ) |
Returns the mapping with the given unique ID, or nullptr if not found.
| id | Mapping UUID. |
| bool Ship::ControllerButton::HasMappingsForPhysicalDeviceType | ( | PhysicalDeviceType | physicalDeviceType | ) |
Returns true if any mapping targets the given physical device type.
| physicalDeviceType | Device type to query. |
| void Ship::ControllerButton::LoadButtonMappingFromConfig | ( | std::string | id | ) |
| bool Ship::ControllerButton::ProcessKeyboardEvent | ( | KbEventType | eventType, |
| KbScancode | scancode | ||
| ) |
Forwards a keyboard event to all mappings that handle keyboard input.
| eventType | Key-down or key-up. |
| scancode | Platform-independent scan code. |
| bool Ship::ControllerButton::ProcessMouseButtonEvent | ( | bool | isPressed, |
| Ship::MouseBtn | button | ||
| ) |
Forwards a mouse-button event to all mappings that handle mouse input.
| isPressed | true for button-down, false for button-up. |
| button | Mouse button identifier. |
| void Ship::ControllerButton::ReloadAllMappingsFromConfig | ( | ) |
Clears all in-memory mappings and reloads them from Config.
| void Ship::ControllerButton::SaveButtonMappingIdsToConfig | ( | ) |
Writes the current set of mapping IDs to Config so they can be reloaded later.
|
inline |
Injects the owning ControlDeck.
| void Ship::ControllerButton::UpdatePad | ( | CONTROLLERBUTTONS_T & | padButtons | ) |
Evaluates all active mappings and sets the corresponding bits in padButtons.
| padButtons | Reference to the pad button bitfield to update. |