Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
PERIPHERALS::CAddonButtonMap Class Reference

#include <AddonButtonMap.h>

Inheritance diagram for PERIPHERALS::CAddonButtonMap:
KODI::JOYSTICK::IButtonMap

Public Member Functions

 CAddonButtonMap (CPeripheral *device, const std::weak_ptr< CPeripheralAddon > &addon, const std::string &strControllerId, CPeripherals &manager)
 
 ~CAddonButtonMap (void) override
 
std::string ControllerID (void) const override
 The add-on ID of the game controller associated with this button map.
 
std::string Location (void) const override
 The Location of the peripheral associated with this button map.
 
bool Load (void) override
 Load the button map into memory.
 
void Reset (void) override
 Reset the button map to its defaults, or clear button map if no defaults.
 
bool IsEmpty (void) const override
 Check if the button map is empty.
 
std::string GetAppearance () const override
 Get the ID of the controller profile that best represents the appearance of the peripheral.
 
bool SetAppearance (const std::string &controllerId) const override
 Set the ID of the controller that best represents the appearance of the peripheral.
 
bool GetFeature (const KODI::JOYSTICK::CDriverPrimitive &primitive, KODI::JOYSTICK::FeatureName &feature) override
 Get the feature associated with a driver primitive.
 
KODI::JOYSTICK::FEATURE_TYPE GetFeatureType (const KODI::JOYSTICK::FeatureName &feature) override
 Get the type of the feature for the given name.
 
bool GetScalar (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Get the driver primitive for a scalar feature.
 
void AddScalar (const KODI::JOYSTICK::FeatureName &feature, const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a scalar feature.
 
bool GetAnalogStick (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::ANALOG_STICK_DIRECTION direction, KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Get an analog stick direction from the button map.
 
void AddAnalogStick (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::ANALOG_STICK_DIRECTION direction, const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Add or update an analog stick direction.
 
bool GetRelativePointer (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::RELATIVE_POINTER_DIRECTION direction, KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Get a relative pointer direction from the button map.
 
void AddRelativePointer (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::RELATIVE_POINTER_DIRECTION direction, const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a relative pointer direction.
 
bool GetAccelerometer (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::CDriverPrimitive &positiveX, KODI::JOYSTICK::CDriverPrimitive &positiveY, KODI::JOYSTICK::CDriverPrimitive &positiveZ) override
 Get an accelerometer from the button map.
 
void AddAccelerometer (const KODI::JOYSTICK::FeatureName &feature, const KODI::JOYSTICK::CDriverPrimitive &positiveX, const KODI::JOYSTICK::CDriverPrimitive &positiveY, const KODI::JOYSTICK::CDriverPrimitive &positiveZ) override
 Get or update an accelerometer.
 
bool GetWheel (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::WHEEL_DIRECTION direction, KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Get a wheel direction from the button map.
 
void AddWheel (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::WHEEL_DIRECTION direction, const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a wheel direction.
 
bool GetThrottle (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::THROTTLE_DIRECTION direction, KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Get a throttle direction from the button map.
 
void AddThrottle (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::THROTTLE_DIRECTION direction, const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a throttle direction.
 
bool GetKey (const KODI::JOYSTICK::FeatureName &feature, KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Get the driver primitive for a keyboard key.
 
void AddKey (const KODI::JOYSTICK::FeatureName &feature, const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a key.
 
void SetIgnoredPrimitives (const std::vector< KODI::JOYSTICK::CDriverPrimitive > &primitives) override
 Set a list of driver primitives to be ignored.
 
bool IsIgnored (const KODI::JOYSTICK::CDriverPrimitive &primitive) override
 Check if a primitive is in the list of primitives to be ignored.
 
bool GetAxisProperties (unsigned int axisIndex, int &center, unsigned int &range) override
 Get the properties of an axis.
 
void SaveButtonMap () override
 Save the button map.
 
void RevertButtonMap () override
 Revert changes to the button map since the last time it was loaded or committed to disk.
 
- Public Member Functions inherited from KODI::JOYSTICK::IButtonMap
virtual ~IButtonMap ()=default
 

Constructor & Destructor Documentation

◆ CAddonButtonMap()

CAddonButtonMap::CAddonButtonMap ( CPeripheral * device,
const std::weak_ptr< CPeripheralAddon > & addon,
const std::string & strControllerId,
CPeripherals & manager )

◆ ~CAddonButtonMap()

CAddonButtonMap::~CAddonButtonMap ( void )
override

Member Function Documentation

◆ AddAccelerometer()

void CAddonButtonMap::AddAccelerometer ( const KODI::JOYSTICK::FeatureName & feature,
const KODI::JOYSTICK::CDriverPrimitive & positiveX,
const KODI::JOYSTICK::CDriverPrimitive & positiveY,
const KODI::JOYSTICK::CDriverPrimitive & positiveZ )
overridevirtual

Get or update an accelerometer.

Parameters
featureMust be an accelerometer or this will return false
positiveXThe semiaxis corresponding to the positive X direction
positiveYThe semiaxis corresponding to the positive Y direction
positiveZThe semiaxis corresponding to the positive Z direction

The driver primitives must be mapped to a semiaxis or this function will fail.

Returns
True if the accelerometer was updated, false if unchanged or failure occurred

Implements KODI::JOYSTICK::IButtonMap.

◆ AddAnalogStick()

void CAddonButtonMap::AddAnalogStick ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::ANALOG_STICK_DIRECTION direction,
const KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Add or update an analog stick direction.

Parameters
featureMust be an analog stick or this will return false
directionThe direction being mapped
primitiveThe driver primitive for the specified analog stick and direction
Returns
True if the analog stick was updated, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ AddKey()

void CAddonButtonMap::AddKey ( const KODI::JOYSTICK::FeatureName & feature,
const KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Add or update a key.

Parameters
featureMust be a key
primitiveThe feature's driver primitive
Returns
True if the feature was updated, false if the feature is unchanged or failure occurs

Implements KODI::JOYSTICK::IButtonMap.

◆ AddRelativePointer()

void CAddonButtonMap::AddRelativePointer ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::RELATIVE_POINTER_DIRECTION direction,
const KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Add or update a relative pointer direction.

Parameters
featureMust be a relative pointer or this will return false
directionThe direction being mapped
primitiveThe driver primitive for the specified analog stick and direction
Returns
True if the analog stick was updated, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ AddScalar()

void CAddonButtonMap::AddScalar ( const KODI::JOYSTICK::FeatureName & feature,
const KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Add or update a scalar feature.

Parameters
featureMust be a scalar feature
primitiveThe feature's driver primitive
Returns
True if the feature was updated, false if the feature is unchanged or failure occurs

Implements KODI::JOYSTICK::IButtonMap.

◆ AddThrottle()

void CAddonButtonMap::AddThrottle ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::THROTTLE_DIRECTION direction,
const KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Add or update a throttle direction.

Parameters
featureMust be a throttle or this will return false
directionThe direction being mapped
primitiveThe driver primitive for the specified analog stick and direction
Returns
True if the analog stick was updated, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ AddWheel()

void CAddonButtonMap::AddWheel ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::WHEEL_DIRECTION direction,
const KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Add or update a wheel direction.

Parameters
featureMust be a wheel or this will return false
directionThe direction being mapped
primitiveThe driver primitive for the specified analog stick and direction
Returns
True if the analog stick was updated, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ ControllerID()

std::string PERIPHERALS::CAddonButtonMap::ControllerID ( void ) const
inlineoverridevirtual

The add-on ID of the game controller associated with this button map.

The controller ID provided by the implementation serves as the context for the feature names below.

Returns
The ID of this button map's game controller add-on

Implements KODI::JOYSTICK::IButtonMap.

◆ GetAccelerometer()

bool CAddonButtonMap::GetAccelerometer ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::CDriverPrimitive & positiveX,
KODI::JOYSTICK::CDriverPrimitive & positiveY,
KODI::JOYSTICK::CDriverPrimitive & positiveZ )
overridevirtual

Get an accelerometer from the button map.

Parameters
featureMust be an accelerometer or this will return false
positiveXThe semiaxis mapped to the positive X direction (possibly unknown)
positiveYThe semiaxis mapped to the positive Y direction (possibly unknown)
positiveZThe semiaxis mapped to the positive Z direction (possibly unknown)
Returns
True if the feature resolved to an accelerometer with at least 1 known axis

Implements KODI::JOYSTICK::IButtonMap.

◆ GetAnalogStick()

bool CAddonButtonMap::GetAnalogStick ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::ANALOG_STICK_DIRECTION direction,
KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Get an analog stick direction from the button map.

Parameters
featureMust be an analog stick or this will return false
directionThe direction whose primitive is to be retrieved
[out]primitiveThe primitive mapped to the specified direction
Returns
True if the feature and direction resolved to a driver primitive

Implements KODI::JOYSTICK::IButtonMap.

◆ GetAppearance()

std::string CAddonButtonMap::GetAppearance ( ) const
overridevirtual

Get the ID of the controller profile that best represents the appearance of the peripheral.

Returns
The controller ID, or empty if the appearance is unknown

Implements KODI::JOYSTICK::IButtonMap.

◆ GetAxisProperties()

bool CAddonButtonMap::GetAxisProperties ( unsigned int axisIndex,
int & center,
unsigned int & range )
overridevirtual

Get the properties of an axis.

Parameters
axisIndexThe index of the axis to check
center[out]The center, if known
range[out]The range, if known
Returns
True if the properties are known, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ GetFeature()

bool CAddonButtonMap::GetFeature ( const KODI::JOYSTICK::CDriverPrimitive & primitive,
KODI::JOYSTICK::FeatureName & feature )
overridevirtual

Get the feature associated with a driver primitive.

Multiple primitives can be mapped to the same feature. For example, analog sticks use one primitive for each direction.

Parameters
primitiveThe driver primitive
featureThe name of the resolved joystick feature, or invalid if false is returned
Returns
True if the driver primitive is associated with a feature, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ GetFeatureType()

FEATURE_TYPE CAddonButtonMap::GetFeatureType ( const KODI::JOYSTICK::FeatureName & feature)
overridevirtual

Get the type of the feature for the given name.

Parameters
featureThe feature to look up
Returns
The feature's type

Implements KODI::JOYSTICK::IButtonMap.

◆ GetKey()

bool CAddonButtonMap::GetKey ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Get the driver primitive for a keyboard key.

Parameters
featureMust be a key
primitiveThe resolved driver primitive
Returns
True if the feature resolved to a driver primitive, false if the feature didn't resolve or isn't a scalar feature

Implements KODI::JOYSTICK::IButtonMap.

◆ GetRelativePointer()

bool CAddonButtonMap::GetRelativePointer ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::RELATIVE_POINTER_DIRECTION direction,
KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Get a relative pointer direction from the button map.

Parameters
featureMust be a relative pointer stick or this will return false
directionThe direction whose primitive is to be retrieved
[out]primitiveThe primitive mapped to the specified direction
Returns
True if the feature and direction resolved to a driver primitive

Implements KODI::JOYSTICK::IButtonMap.

◆ GetScalar()

bool CAddonButtonMap::GetScalar ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Get the driver primitive for a scalar feature.

When a feature can be represented by a single driver primitive, it is called a scalar feature.

  • This includes buttons and triggers, because they can be mapped to a single button/hat/semiaxis
  • This does not include analog sticks, because they require two axes and four driver primitives (one for each semiaxis)
Parameters
featureMust be a scalar feature (a feature that only requires a single driver primitive)
primitiveThe resolved driver primitive
Returns
True if the feature resolved to a driver primitive, false if the feature didn't resolve or isn't a scalar feature

Implements KODI::JOYSTICK::IButtonMap.

◆ GetThrottle()

bool CAddonButtonMap::GetThrottle ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::THROTTLE_DIRECTION direction,
KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Get a throttle direction from the button map.

Parameters
featureMust be a throttle or this will return false
directionThe direction whose primitive is to be retrieved
[out]primitiveThe primitive mapped to the specified direction
Returns
True if the feature and direction resolved to a driver primitive

Implements KODI::JOYSTICK::IButtonMap.

◆ GetWheel()

bool CAddonButtonMap::GetWheel ( const KODI::JOYSTICK::FeatureName & feature,
KODI::JOYSTICK::WHEEL_DIRECTION direction,
KODI::JOYSTICK::CDriverPrimitive & primitive )
overridevirtual

Get a wheel direction from the button map.

Parameters
featureMust be a wheel or this will return false
directionThe direction whose primitive is to be retrieved
[out]primitiveThe primitive mapped to the specified direction
Returns
True if the feature and direction resolved to a driver primitive

Implements KODI::JOYSTICK::IButtonMap.

◆ IsEmpty()

bool CAddonButtonMap::IsEmpty ( void ) const
overridevirtual

Check if the button map is empty.

Returns
True if the button map is empty, false if it has features

Implements KODI::JOYSTICK::IButtonMap.

◆ IsIgnored()

bool CAddonButtonMap::IsIgnored ( const KODI::JOYSTICK::CDriverPrimitive & primitive)
overridevirtual

Check if a primitive is in the list of primitives to be ignored.

Parameters
primitiveThe primitive to check
Returns
True if the primitive should be ignored in the mapping process

Implements KODI::JOYSTICK::IButtonMap.

◆ Load()

bool CAddonButtonMap::Load ( void )
overridevirtual

Load the button map into memory.

Returns
True if button map is ready to start translating buttons, false otherwise

Implements KODI::JOYSTICK::IButtonMap.

◆ Location()

std::string CAddonButtonMap::Location ( void ) const
overridevirtual

The Location of the peripheral associated with this button map.

Returns
The peripheral's location

Implements KODI::JOYSTICK::IButtonMap.

◆ Reset()

void CAddonButtonMap::Reset ( void )
overridevirtual

Reset the button map to its defaults, or clear button map if no defaults.

Implements KODI::JOYSTICK::IButtonMap.

◆ RevertButtonMap()

void CAddonButtonMap::RevertButtonMap ( )
overridevirtual

Revert changes to the button map since the last time it was loaded or committed to disk.

Implements KODI::JOYSTICK::IButtonMap.

◆ SaveButtonMap()

void CAddonButtonMap::SaveButtonMap ( )
overridevirtual

Save the button map.

Implements KODI::JOYSTICK::IButtonMap.

◆ SetAppearance()

bool CAddonButtonMap::SetAppearance ( const std::string & controllerId) const
overridevirtual

Set the ID of the controller that best represents the appearance of the peripheral.

Parameters
controllerIdThe controller ID, or empty to unset the appearance
Returns
True if the appearance was set, false on error

Implements KODI::JOYSTICK::IButtonMap.

◆ SetIgnoredPrimitives()

void CAddonButtonMap::SetIgnoredPrimitives ( const std::vector< KODI::JOYSTICK::CDriverPrimitive > & primitives)
overridevirtual

Set a list of driver primitives to be ignored.

This is necessary to prevent features from interfering with the button mapping process. This includes accelerometers, as well as PS4 triggers which send both a button press and an analog value.

Parameters
primitivesThe driver primitives to be ignored

Implements KODI::JOYSTICK::IButtonMap.


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