6#include <unordered_map>
15#define DEFAULT_STICK_SENSITIVITY_PERCENTAGE 100
17#define DEFAULT_STICK_DEADZONE_PERCENTAGE 20
19#define DEFAULT_NOTCH_SNAP_ANGLE 0
36 mControlDeck = std::move(controlDeck);
50 std::shared_ptr<ConsoleVariable> consoleVariable =
nullptr,
51 std::shared_ptr<ControlDeck> controlDeck =
nullptr, std::shared_ptr<Window> window =
nullptr);
92 std::unordered_map<Direction, std::unordered_map<std::string, std::shared_ptr<ControllerAxisDirectionMapping>>>
99 std::unordered_map<std::string, std::shared_ptr<ControllerAxisDirectionMapping>>
219 double GetClosestNotch(
double angle,
double approximationThreshold);
220 void LoadAxisDirectionMappingFromConfig(std::string
id);
221 float GetAxisDirectionValue(
Direction direction);
226 uint8_t mSensitivityPercentage;
230 uint8_t mDeadzonePercentage;
232 uint8_t mNotchSnapAngle;
234 std::unordered_map<Direction, std::unordered_map<std::string, std::shared_ptr<ControllerAxisDirectionMapping>>>
235 mAxisDirectionMappings;
237 bool mUseEventInputToCreateNewMapping;
241 std::shared_ptr<ConsoleVariable> mConsoleVariable;
242 std::shared_ptr<ControlDeck> mControlDeck;
243 std::shared_ptr<Window> mWindow;
Aggregates axis-direction mappings and applies sensitivity, dead-zone, and notch-snap to a stick.
Definition ControllerStick.h:32
std::unordered_map< std::string, std::shared_ptr< ControllerAxisDirectionMapping > > GetAllAxisDirectionMappingByDirection(Direction direction)
Returns the id → mapping map for a single direction.
bool ProcessMouseButtonEvent(bool isPressed, Ship::MouseBtn button)
Forwards a mouse-button event to all directional mappings that handle mouse input.
void ClearAxisDirectionMapping(Direction direction, std::shared_ptr< ControllerAxisDirectionMapping > mapping)
Removes the given mapping instance from both in-memory and Config.
uint8_t GetDeadzonePercentage()
Returns the current dead-zone percentage.
void UpdatePad(int8_t &x, int8_t &y)
Evaluates all axis mappings and writes the processed stick values to x and y.
bool DeadzoneIsDefault()
Returns true if dead-zone is at the default value.
void SetNotchSnapAngle(uint8_t notchSnapAngle)
Sets the notch snap angle and saves to Config.
bool NotchSnapAngleIsDefault()
Returns true if the notch snap angle is at the default value.
void ResetDeadzoneToDefault()
Resets dead-zone to DEFAULT_STICK_DEADZONE_PERCENTAGE and saves to Config.
void SetControlDeck(std::shared_ptr< ControlDeck > controlDeck)
Injects the owning ControlDeck.
Definition ControllerStick.h:35
bool HasMappingsForPhysicalDeviceType(PhysicalDeviceType physicalDeviceType)
Returns true if any directional mapping targets the given device type.
std::unordered_map< Direction, std::unordered_map< std::string, std::shared_ptr< ControllerAxisDirectionMapping > > > GetAllAxisDirectionMappings()
Returns a copy of the full direction → (id → mapping) map.
void ClearAxisDirectionMapping(Direction direction, std::string id)
Removes the mapping by ID from both in-memory and Config.
void SetDeadzone(uint8_t deadzonePercentage)
Sets the dead-zone and saves to Config.
uint8_t GetSensitivityPercentage()
Returns the current sensitivity percentage.
void AddDefaultMappings(PhysicalDeviceType physicalDeviceType)
Applies the default axis-direction mappings for the given device type.
void ResetSensitivityToDefault()
Resets sensitivity to DEFAULT_STICK_SENSITIVITY_PERCENTAGE and saves to Config.
uint8_t GetNotchSnapAngle()
Returns the current notch snap angle in degrees.
void Process(int8_t &x, int8_t &y)
Reads raw axis values, applies processing, and writes to x and y.
void ClearAllMappingsForDeviceType(PhysicalDeviceType physicalDeviceType)
Removes all axis-direction mappings that target the given device type.
void ReloadAllMappingsFromConfig()
Clears all in-memory mappings and reloads them from Config.
void ResetNotchSnapAngleToDefault()
Resets notch snap angle to DEFAULT_NOTCH_SNAP_ANGLE and saves to Config.
void SetSensitivity(uint8_t sensitivityPercentage)
Sets the stick sensitivity and saves to Config.
std::shared_ptr< ControllerAxisDirectionMapping > GetAxisDirectionMappingById(Direction direction, std::string id)
Returns the mapping for the given direction and ID, or nullptr if not found.
bool SensitivityIsDefault()
Returns true if sensitivity is at the default value.
void ClearAxisDirectionMappingId(Direction direction, std::string id)
Removes the mapping ID from Config without destroying the in-memory object.
void AddAxisDirectionMapping(Direction direction, std::shared_ptr< ControllerAxisDirectionMapping > mapping)
Adds a mapping for the given direction.
StickIndex GetStickIndex()
Returns the stick index (left or right).
void SaveAxisDirectionMappingIdsToConfig()
Writes the current set of mapping IDs for all directions to Config.
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode)
Forwards a keyboard event to all directional mappings that handle keyboard input.
void ClearAllMappings()
Removes all axis-direction mappings for all directions.
bool AddOrEditAxisDirectionMappingFromRawPress(Direction direction, std::string id)
Listens for the next raw physical input and adds or replaces a directional mapping.
ControllerStick(uint8_t portIndex, StickIndex stickIndex, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr, std::shared_ptr< ControlDeck > controlDeck=nullptr, std::shared_ptr< Window > window=nullptr)
Constructs a ControllerStick for a given port and stick index.
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
Direction
Identifies the direction component of an axis mapping.
Definition ControllerAxisDirectionMapping.h:18
MouseBtn
Identifies a mouse button delivered to the input mapping system.
Definition KeyboardScancodes.h:136
StickIndex
Identifies which analog stick an axis mapping applies to.
Definition ControllerAxisDirectionMapping.h:15