10#include <unordered_map>
48 Controller(uint8_t portIndex, std::vector<CONTROLLERBUTTONS_T> bitmasks,
49 std::shared_ptr<ConsoleVariable> consoleVariable =
nullptr,
50 std::shared_ptr<ControlDeck> controlDeck =
nullptr, std::shared_ptr<Window> window =
nullptr);
89 std::unordered_map<CONTROLLERBUTTONS_T, std::shared_ptr<ControllerButton>>
GetAllButtons();
163 std::unordered_map<CONTROLLERBUTTONS_T, std::shared_ptr<ControllerButton>>
170 void LoadButtonMappingFromConfig(std::string
id);
171 void SaveButtonMappingIdsToConfig();
173 std::shared_ptr<ControllerStick> mLeftStick, mRightStick;
174 std::shared_ptr<ControllerGyro> mGyro;
175 std::shared_ptr<ControllerRumble> mRumble;
176 std::shared_ptr<ControllerLED> mLED;
Abstract base class for all input devices that can be connected to a ControlPort.
Definition ControlDevice.h:15
Represents a single logical controller connected to a ControlPort.
Definition Controller.h:38
std::shared_ptr< ControllerStick > GetLeftStick()
Returns the left analog stick input aggregator.
std::shared_ptr< ControllerButton > GetButtonByBitmask(CONTROLLERBUTTONS_T bitmask)
Returns the ControllerButton for the given bitmask, or nullptr if not found.
void AddDefaultMappings(PhysicalDeviceType physicalDeviceType)
Applies the default mappings for the given physical device type.
bool HasMappingsForPhysicalDeviceType(PhysicalDeviceType physicalDeviceType)
Returns true if any mapping for this controller targets the given physical device type.
std::vector< std::shared_ptr< ControllerMapping > > GetAllMappings()
Returns a flat list of all ControllerMapping instances across all subsystems.
bool HasConfig()
Returns true if any Config key exists for this controller's mappings.
void Disconnect()
Marks the controller as "disconnected" and clears transient state.
void SetControlDeck(std::shared_ptr< ControlDeck > controlDeck)
Injects the owning ControlDeck into this controller and all of its subsystems.
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode)
Forwards a keyboard event to all button and stick mappings.
void Connect()
Marks the controller as "connected" (used by the mapping layer).
bool IsConnected() const
Returns true if at least one physical device mapping is active for any button.
std::shared_ptr< ControlDeck > mControlDeck
Definition Controller.h:166
bool ProcessMouseButtonEvent(bool isPressed, MouseBtn button)
Forwards a mouse-button event to all button and stick mappings.
std::unordered_map< CONTROLLERBUTTONS_T, std::shared_ptr< ControllerButton > > mButtons
Button subsystems keyed by bitmask.
Definition Controller.h:164
std::shared_ptr< Window > mWindow
Definition Controller.h:167
void ClearAllMappings()
Removes all mappings for all buttons, sticks, rumble, LED, and gyro.
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.
void ReloadAllMappingsFromConfig()
Discards all in-memory mappings and reloads them from Config.
std::shared_ptr< ControllerGyro > GetGyro()
Returns the gyroscope input aggregator.
std::shared_ptr< ControllerLED > GetLED()
Returns the LED output aggregator.
std::shared_ptr< ConsoleVariable > mConsoleVariable
Cached ConsoleVariable component.
Definition Controller.h:165
~Controller()
Destroys the Controller and releases all mapping resources.
std::shared_ptr< ControllerStick > GetRightStick()
Returns the right analog stick input aggregator.
uint8_t GetPortIndex()
Returns the zero-based port index this controller is bound to.
std::unordered_map< CONTROLLERBUTTONS_T, std::shared_ptr< ControllerButton > > GetAllButtons()
Returns the full bitmask→ControllerButton map.
virtual void ReadToPad(void *pad)=0
Reads aggregated input state and writes it to the game-specific pad structure.
std::shared_ptr< ControllerButton > GetButton(CONTROLLERBUTTONS_T bitmask)
Alias of GetButtonByBitmask().
void ClearAllMappingsForDeviceType(PhysicalDeviceType physicalDeviceType)
Removes all mappings that target the given physical device type.
std::shared_ptr< ControllerRumble > GetRumble()
Returns the rumble output aggregator.
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
PhysicalDeviceType
Identifies the category of a physical input device.
Definition PhysicalDeviceType.h:11
KbScancode
Platform-independent keyboard scan codes used by the input mapping system.
Definition KeyboardScancodes.h:26
KbEventType
Identifies the type of a keyboard event delivered to the input mapping system.
Definition KeyboardScancodes.h:12
MouseBtn
Identifies a mouse button delivered to the input mapping system.
Definition KeyboardScancodes.h:136