Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
KODI::JOYSTICK::IButtonMapper Class Referenceabstract

Button mapper interface to assign the driver's raw button/hat/axis elements to physical joystick features using a provided button map. More...

#include <IButtonMapper.h>

Inheritance diagram for KODI::JOYSTICK::IButtonMapper:
KODI::GAME::CGUIConfigurationWizard KODI::GAME::CGUIDialogButtonCapture KODI::GAME::CGUIDialogAxisDetection KODI::GAME::CGUIDialogIgnoreInput

Public Member Functions

 IButtonMapper ()=default
 
virtual ~IButtonMapper ()=default
 
virtual std::string ControllerID (void) const =0
 The add-on ID of the game controller associated with this button mapper.
 
virtual bool NeedsCooldown (void) const =0
 Return true if the button mapper wants a cooldown between button mapping commands.
 
virtual bool AcceptsPrimitive (PRIMITIVE_TYPE type) const =0
 Return true if the button mapper accepts primitives of the given type.
 
virtual bool MapPrimitive (IButtonMap *buttonMap, KEYMAP::IKeymap *keyMap, const CDriverPrimitive &primitive)=0
 Handle button/hat press or axis threshold.
 
virtual void OnEventFrame (const IButtonMap *buttonMap, bool bMotion)=0
 Called once per event frame to notify the implementation of motion status.
 
virtual void OnLateAxis (const IButtonMap *buttonMap, unsigned int axisIndex)=0
 Called when an axis has been detected after mapping began.
 
void SetButtonMapCallback (const std::string &deviceLocation, IButtonMapCallback *callback)
 
void ResetButtonMapCallbacks (void)
 
std::map< std::string, IButtonMapCallback * > & ButtonMapCallbacks (void)
 

Detailed Description

Button mapper interface to assign the driver's raw button/hat/axis elements to physical joystick features using a provided button map.

See also
IButtonMap

Constructor & Destructor Documentation

◆ IButtonMapper()

KODI::JOYSTICK::IButtonMapper::IButtonMapper ( )
default

◆ ~IButtonMapper()

virtual KODI::JOYSTICK::IButtonMapper::~IButtonMapper ( )
virtualdefault

Member Function Documentation

◆ AcceptsPrimitive()

virtual bool KODI::JOYSTICK::IButtonMapper::AcceptsPrimitive ( PRIMITIVE_TYPE type) const
pure virtual

Return true if the button mapper accepts primitives of the given type.

Parameters
typeThe primitive type
Returns
True if the button mapper can map the primitive type, false otherwise

Implemented in KODI::GAME::CGUIConfigurationWizard, KODI::GAME::CGUIDialogAxisDetection, and KODI::GAME::CGUIDialogIgnoreInput.

◆ ButtonMapCallbacks()

std::map< std::string, IButtonMapCallback * > & KODI::JOYSTICK::IButtonMapper::ButtonMapCallbacks ( void )
inline

◆ ControllerID()

virtual std::string KODI::JOYSTICK::IButtonMapper::ControllerID ( void ) const
pure virtual

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

Returns
The ID of the add-on extending kodi.game.controller

Implemented in KODI::GAME::CGUIConfigurationWizard, and KODI::GAME::CGUIDialogButtonCapture.

◆ MapPrimitive()

virtual bool KODI::JOYSTICK::IButtonMapper::MapPrimitive ( IButtonMap * buttonMap,
KEYMAP::IKeymap * keyMap,
const CDriverPrimitive & primitive )
pure virtual

Handle button/hat press or axis threshold.

Parameters
buttonMapThe button map being manipulated
keymapAn interface capable of translating features to Kodi actions
primitiveThe driver primitive

Called in the same thread as IButtonMapper::OnFrame.

Returns
True if driver primitive was mapped to a feature

Implemented in KODI::GAME::CGUIConfigurationWizard, and KODI::GAME::CGUIDialogButtonCapture.

◆ NeedsCooldown()

virtual bool KODI::JOYSTICK::IButtonMapper::NeedsCooldown ( void ) const
pure virtual

Return true if the button mapper wants a cooldown between button mapping commands.

Returns
True to only send button mapping commands that occur after a small timeout from the previous command.

Implemented in KODI::GAME::CGUIConfigurationWizard, and KODI::GAME::CGUIDialogButtonCapture.

◆ OnEventFrame()

virtual void KODI::JOYSTICK::IButtonMapper::OnEventFrame ( const IButtonMap * buttonMap,
bool bMotion )
pure virtual

Called once per event frame to notify the implementation of motion status.

Parameters
buttonMapThe button map passed to MapPrimitive() (shall not be modified)
bMotionTrue if a previously-mapped axis is still in motion

This allows the implementer to wait for an axis to be centered before allowing it to be used as Kodi input.

If mapping finishes on an axis, then the axis will still be pressed and sending input every frame when the mapping ends. For example, when the right analog stick is the last feature to be mapped, it is still pressed when mapping ends and immediately sends Volume Down actions.

The fix is to allow implementers to wait until all axes are motionless before detaching themselves.

Called in the same thread as IButtonMapper::MapPrimitive.

Implemented in KODI::GAME::CGUIConfigurationWizard, and KODI::GAME::CGUIDialogButtonCapture.

◆ OnLateAxis()

virtual void KODI::JOYSTICK::IButtonMapper::OnLateAxis ( const IButtonMap * buttonMap,
unsigned int axisIndex )
pure virtual

Called when an axis has been detected after mapping began.

Parameters
axisIndexThe index of the axis being discovered

Some joystick drivers don't report an initial value for analog axes.

Called in the same thread as IButtonMapper::MapPrimitive.

Implemented in KODI::GAME::CGUIConfigurationWizard, KODI::GAME::CGUIDialogAxisDetection, and KODI::GAME::CGUIDialogButtonCapture.

◆ ResetButtonMapCallbacks()

void KODI::JOYSTICK::IButtonMapper::ResetButtonMapCallbacks ( void )
inline

◆ SetButtonMapCallback()

void KODI::JOYSTICK::IButtonMapper::SetButtonMapCallback ( const std::string & deviceLocation,
IButtonMapCallback * callback )
inline

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