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

Class to translate input from the driver into higher-level features. More...

#include <InputHandling.h>

Inheritance diagram for KODI::JOYSTICK::CInputHandling:
KODI::JOYSTICK::IDriverHandler

Public Member Functions

 CInputHandling (IInputHandler *handler, IButtonMap *buttonMap)
 
 ~CInputHandling () override
 
bool OnButtonMotion (unsigned int buttonIndex, bool bPressed) override
 Handle button motion.
 
bool OnHatMotion (unsigned int hatIndex, HAT_STATE state) override
 Handle hat motion.
 
bool OnAxisMotion (unsigned int axisIndex, float position, int center, unsigned int range) override
 Handle axis motion.
 
void OnInputFrame () override
 Handle buffered input motion for features that require multiple axes.
 
- Public Member Functions inherited from KODI::JOYSTICK::IDriverHandler
virtual ~IDriverHandler ()=default
 

Detailed Description

Class to translate input from the driver into higher-level features.

Raw driver input arrives for three elements: buttons, hats and axes. When driver input is handled by this class, it translates the raw driver elements into physical joystick features, such as buttons, analog sticks, etc.

A button map is used to translate driver primitives to controller features. The button map has been abstracted away behind the IButtonMap interface so that it can be provided by an add-on.

Constructor & Destructor Documentation

◆ CInputHandling()

CInputHandling::CInputHandling ( IInputHandler * handler,
IButtonMap * buttonMap )

◆ ~CInputHandling()

CInputHandling::~CInputHandling ( )
overridedefault

Member Function Documentation

◆ OnAxisMotion()

bool CInputHandling::OnAxisMotion ( unsigned int axisIndex,
float position,
int center,
unsigned int range )
overridevirtual

Handle axis motion.

If a joystick feature requires multiple axes (analog sticks, accelerometers), they can be buffered for later processing.

Parameters
axisIndexThe index of the axis as reported by the driver
positionThe position of the axis in the closed interval [-1.0, 1.0]
centerThe center point of the axis (either -1, 0 or 1)
rangeThe maximum distance the axis can move (either 1 or 2)
Returns
True if the motion was handled, false otherwise

Implements KODI::JOYSTICK::IDriverHandler.

◆ OnButtonMotion()

bool CInputHandling::OnButtonMotion ( unsigned int buttonIndex,
bool bPressed )
overridevirtual

Handle button motion.

Parameters
buttonIndexThe index of the button as reported by the driver
bPressedtrue for press motion, false for release motion
Returns
True if a press was handled, false otherwise

Implements KODI::JOYSTICK::IDriverHandler.

◆ OnHatMotion()

bool CInputHandling::OnHatMotion ( unsigned int hatIndex,
HAT_STATE state )
overridevirtual

Handle hat motion.

Parameters
hatIndexThe index of the hat as reported by the driver
stateThe direction the hat is now being pressed
Returns
True if the new direction was handled, false otherwise

Implements KODI::JOYSTICK::IDriverHandler.

◆ OnInputFrame()

void CInputHandling::OnInputFrame ( )
overridevirtual

Handle buffered input motion for features that require multiple axes.

OnInputFrame() is called at the end of the frame when all axis motions have been reported. This has several uses, including:

  • Combining multiple axes into a single analog stick or accelerometer event
  • Imitating an analog feature with a digital button so that events can be dispatched every frame.

Implements KODI::JOYSTICK::IDriverHandler.


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