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

A fallback buttonmap to be used with the default keyboard profile. More...

#include <DefaultButtonMap.h>

Inheritance diagram for KODI::GAME::CDefaultButtonMap:
KODI::JOYSTICK::IButtonMap

Public Member Functions

 CDefaultButtonMap (PERIPHERALS::CPeripheral *device, std::string strControllerId)
 
 ~CDefaultButtonMap () override
 
std::string ControllerID () const override
 The add-on ID of the game controller associated with this button map.
 
std::string Location () const override
 The Location of the peripheral associated with this button map.
 
bool Load () override
 Load the button map into memory.
 
void Reset () override
 Reset the button map to its defaults, or clear button map if no defaults.
 
bool IsEmpty () 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 JOYSTICK::CDriverPrimitive &primitive, JOYSTICK::FeatureName &feature) override
 Get the feature associated with a driver primitive.
 
JOYSTICK::FEATURE_TYPE GetFeatureType (const JOYSTICK::FeatureName &feature) override
 Get the type of the feature for the given name.
 
bool GetScalar (const JOYSTICK::FeatureName &feature, JOYSTICK::CDriverPrimitive &primitive) override
 Get the driver primitive for a scalar feature.
 
void AddScalar (const JOYSTICK::FeatureName &feature, const JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a scalar feature.
 
bool GetAnalogStick (const JOYSTICK::FeatureName &feature, JOYSTICK::ANALOG_STICK_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
 Get an analog stick direction from the button map.
 
void AddAnalogStick (const JOYSTICK::FeatureName &feature, JOYSTICK::ANALOG_STICK_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
 Add or update an analog stick direction.
 
bool GetRelativePointer (const JOYSTICK::FeatureName &feature, JOYSTICK::RELATIVE_POINTER_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
 Get a relative pointer direction from the button map.
 
void AddRelativePointer (const JOYSTICK::FeatureName &feature, JOYSTICK::RELATIVE_POINTER_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a relative pointer direction.
 
bool GetAccelerometer (const JOYSTICK::FeatureName &feature, JOYSTICK::CDriverPrimitive &positiveX, JOYSTICK::CDriverPrimitive &positiveY, JOYSTICK::CDriverPrimitive &positiveZ) override
 Get an accelerometer from the button map.
 
void AddAccelerometer (const JOYSTICK::FeatureName &feature, const JOYSTICK::CDriverPrimitive &positiveX, const JOYSTICK::CDriverPrimitive &positiveY, const JOYSTICK::CDriverPrimitive &positiveZ) override
 Get or update an accelerometer.
 
bool GetWheel (const JOYSTICK::FeatureName &feature, JOYSTICK::WHEEL_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
 Get a wheel direction from the button map.
 
void AddWheel (const JOYSTICK::FeatureName &feature, JOYSTICK::WHEEL_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a wheel direction.
 
bool GetThrottle (const JOYSTICK::FeatureName &feature, JOYSTICK::THROTTLE_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
 Get a throttle direction from the button map.
 
void AddThrottle (const JOYSTICK::FeatureName &feature, JOYSTICK::THROTTLE_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a throttle direction.
 
bool GetKey (const JOYSTICK::FeatureName &feature, JOYSTICK::CDriverPrimitive &primitive) override
 Get the driver primitive for a keyboard key.
 
void AddKey (const JOYSTICK::FeatureName &feature, const JOYSTICK::CDriverPrimitive &primitive) override
 Add or update a key.
 
void SetIgnoredPrimitives (const std::vector< JOYSTICK::CDriverPrimitive > &primitives) override
 Set a list of driver primitives to be ignored.
 
bool IsIgnored (const 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
 

Detailed Description

A fallback buttonmap to be used with the default keyboard profile.

Constructor & Destructor Documentation

◆ CDefaultButtonMap()

CDefaultButtonMap::CDefaultButtonMap ( PERIPHERALS::CPeripheral * device,
std::string strControllerId )

◆ ~CDefaultButtonMap()

CDefaultButtonMap::~CDefaultButtonMap ( )
overridedefault

Member Function Documentation

◆ AddAccelerometer()

void KODI::GAME::CDefaultButtonMap::AddAccelerometer ( const JOYSTICK::FeatureName & feature,
const JOYSTICK::CDriverPrimitive & positiveX,
const JOYSTICK::CDriverPrimitive & positiveY,
const JOYSTICK::CDriverPrimitive & positiveZ )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::AddAnalogStick ( const JOYSTICK::FeatureName & feature,
JOYSTICK::ANALOG_STICK_DIRECTION direction,
const JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::AddKey ( const JOYSTICK::FeatureName & feature,
const JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::AddRelativePointer ( const JOYSTICK::FeatureName & feature,
JOYSTICK::RELATIVE_POINTER_DIRECTION direction,
const JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::AddScalar ( const JOYSTICK::FeatureName & feature,
const JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::AddThrottle ( const JOYSTICK::FeatureName & feature,
JOYSTICK::THROTTLE_DIRECTION direction,
const JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::AddWheel ( const JOYSTICK::FeatureName & feature,
JOYSTICK::WHEEL_DIRECTION direction,
const JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::ControllerID ( ) 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 KODI::GAME::CDefaultButtonMap::GetAccelerometer ( const JOYSTICK::FeatureName & feature,
JOYSTICK::CDriverPrimitive & positiveX,
JOYSTICK::CDriverPrimitive & positiveY,
JOYSTICK::CDriverPrimitive & positiveZ )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::GetAnalogStick ( const JOYSTICK::FeatureName & feature,
JOYSTICK::ANALOG_STICK_DIRECTION direction,
JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 CDefaultButtonMap::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 KODI::GAME::CDefaultButtonMap::GetAxisProperties ( unsigned int axisIndex,
int & center,
unsigned int & range )
inlineoverridevirtual

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 CDefaultButtonMap::GetFeature ( const JOYSTICK::CDriverPrimitive & primitive,
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()

JOYSTICK::FEATURE_TYPE KODI::GAME::CDefaultButtonMap::GetFeatureType ( const JOYSTICK::FeatureName & feature)
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::GetKey ( const JOYSTICK::FeatureName & feature,
JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::GetRelativePointer ( const JOYSTICK::FeatureName & feature,
JOYSTICK::RELATIVE_POINTER_DIRECTION direction,
JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::GetScalar ( const JOYSTICK::FeatureName & feature,
JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::GetThrottle ( const JOYSTICK::FeatureName & feature,
JOYSTICK::THROTTLE_DIRECTION direction,
JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::GetWheel ( const JOYSTICK::FeatureName & feature,
JOYSTICK::WHEEL_DIRECTION direction,
JOYSTICK::CDriverPrimitive & primitive )
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::IsEmpty ( ) const
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::IsIgnored ( const JOYSTICK::CDriverPrimitive & primitive)
inlineoverridevirtual

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 CDefaultButtonMap::Load ( )
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 CDefaultButtonMap::Location ( ) const
overridevirtual

The Location of the peripheral associated with this button map.

Returns
The peripheral's location

Implements KODI::JOYSTICK::IButtonMap.

◆ Reset()

void KODI::GAME::CDefaultButtonMap::Reset ( )
inlineoverridevirtual

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

Implements KODI::JOYSTICK::IButtonMap.

◆ RevertButtonMap()

void KODI::GAME::CDefaultButtonMap::RevertButtonMap ( )
inlineoverridevirtual

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

Implements KODI::JOYSTICK::IButtonMap.

◆ SaveButtonMap()

void KODI::GAME::CDefaultButtonMap::SaveButtonMap ( )
inlineoverridevirtual

Save the button map.

Implements KODI::JOYSTICK::IButtonMap.

◆ SetAppearance()

bool KODI::GAME::CDefaultButtonMap::SetAppearance ( const std::string & controllerId) const
inlineoverridevirtual

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 KODI::GAME::CDefaultButtonMap::SetIgnoredPrimitives ( const std::vector< JOYSTICK::CDriverPrimitive > & primitives)
inlineoverridevirtual

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: