Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
CInputManager Class Reference

Main input processing class. More...

#include <InputManager.h>

Inheritance diagram for CInputManager:
ISettingCallback IActionListener Observable

Public Member Functions

 CInputManager (const CAppParamParser &params)
 
 CInputManager (const CInputManager &)=delete
 
CInputManager const & operator= (CInputManager const &)=delete
 
 ~CInputManager () override
 
bool ProcessMouse (int windowId)
 decode a mouse event and reset idle timers. More...
 
bool ProcessEventServer (int windowId, float frameTime)
 decode an event from the event service, this can be mouse, key, joystick, reset idle timers. More...
 
bool ProcessPeripherals (float frameTime)
 decode an event from peripherals. More...
 
bool Process (int windowId, float frameTime)
 Process all inputs. More...
 
void InitializeInputs ()
 Call once during application startup to initialize peripherals that need it. More...
 
void Deinitialize ()
 Deinitialize input and keymaps. More...
 
bool OnEvent (XBMC_Event &newEvent)
 Handle an input event. More...
 
void SetMouseActive (bool active=true)
 Control if the mouse is actively used or not. More...
 
void SetMouseEnabled (bool mouseEnabled=true)
 Control if we should use a mouse or not. More...
 
void SetMouseState (MOUSE_STATE mouseState)
 Set the current state of the mouse such as click, drag operation. More...
 
bool IsMouseActive ()
 Check if the mouse is currently active. More...
 
MOUSE_STATE GetMouseState ()
 Get the current state of the mouse, such as click or drag operation. More...
 
MousePosition GetMousePosition ()
 Get the current mouse positions x and y coordinates. More...
 
void SetMouseResolution (int maxX, int maxY, float speedX, float speedY)
 Set the current screen resolution and pointer speed. More...
 
bool HasBuiltin (const std::string &command)
 Returns whether or not we can handle a given built-in command. More...
 
int ExecuteBuiltin (const std::string &execute, const std::vector< std::string > &params)
 Parse a builtin command and execute any input action currently only LIRC commands implemented. More...
 
bool LoadKeymaps ()
 
bool ReloadKeymaps ()
 
void ClearKeymaps ()
 
void AddKeymap (const std::string &keymap)
 
void RemoveKeymap (const std::string &keymap)
 
const IKeymapEnvironmentKeymapEnvironment () const
 
CAction GetAction (int window, const CKey &key, bool fallback=true)
 Obtain the action configured for a given window and key. More...
 
bool TranslateCustomControllerString (int windowId, const std::string &controllerName, int buttonId, int &action, std::string &strAction)
 
bool TranslateTouchAction (int windowId, int touchAction, int touchPointers, int &action, std::string &actionString)
 
std::vector< std::shared_ptr< const IWindowKeymap > > GetJoystickKeymaps () const
 
void QueueAction (const CAction &action)
 Queue an action to be processed on the next call to Process() More...
 
virtual void OnSettingChanged (std::shared_ptr< const CSetting > setting) override
 The value of the given setting has changed. More...
 
virtual bool OnAction (const CAction &action) override
 
void RegisterKeyboardDriverHandler (KODI::KEYBOARD::IKeyboardDriverHandler *handler)
 
void UnregisterKeyboardDriverHandler (KODI::KEYBOARD::IKeyboardDriverHandler *handler)
 
virtual void RegisterMouseDriverHandler (KODI::MOUSE::IMouseDriverHandler *handler)
 
virtual void UnregisterMouseDriverHandler (KODI::MOUSE::IMouseDriverHandler *handler)
 
- Public Member Functions inherited from ISettingCallback
virtual ~ISettingCallback ()=default
 
virtual bool OnSettingChanging (std::shared_ptr< const CSetting > setting)
 The value of the given setting is being changed. More...
 
virtual void OnSettingAction (std::shared_ptr< const CSetting > setting)
 The given setting has been activated. More...
 
virtual bool OnSettingUpdate (std::shared_ptr< CSetting > setting, const char *oldSettingId, const TiXmlNode *oldSettingNode)
 The given setting needs to be updated. More...
 
virtual void OnSettingPropertyChanged (std::shared_ptr< const CSetting > setting, const char *propertyName)
 The given property of the given setting has changed. More...
 
- Public Member Functions inherited from IActionListener
virtual ~IActionListener ()=default
 
- Public Member Functions inherited from Observable
 Observable ()=default
 
virtual ~Observable ()=default
 
virtual Observableoperator= (const Observable &observable)
 
virtual void RegisterObserver (Observer *obs)
 Register an observer. More...
 
virtual void UnregisterObserver (Observer *obs)
 Unregister an observer. More...
 
virtual void NotifyObservers (const ObservableMessage message=ObservableMessageNone)
 Send a message to all observers when m_bObservableChanged is true. More...
 
virtual void SetChanged (bool bSetTo=true)
 Mark an observable changed. More...
 
virtual bool IsObserving (const Observer &obs) const
 Check whether this observable is being observed by an observer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Observable
void SendMessage (const ObservableMessage message)
 Send a message to all observer when m_bObservableChanged is true. More...
 
- Protected Attributes inherited from Observable
std::atomic< bool > m_bObservableChanged {false}
 
std::vector< Observer * > m_observers
 
CCriticalSection m_obsCritSection
 

Detailed Description

Main input processing class.

This class consolidates all input generated from different sources such as mouse, keyboard, joystick or touch (in OnEvent).

Keyboard input is processed by CInputManager and forwarded to registered keyboard handlers (e.g. game clients) or as actions to the UI:

  • If no keyboard handlers are registered or if they don't consume events, the keyboard events are forwarded to the UI via CInputManager::OnKey.
  • Clients (e.g. game clients implementing KEYBOARD::IKeyboardHandler) call CInputManager::RegisterKeyboardHandler to register themselves as eligible for keyboard input events.
  • Keyboards can emulate Joysticks as described in KEYBOARD::CJoystickEmulation.

    Everything around mouse

Mouse input is processed by CInputManager and forwarded to registered mouse handlers (e.g. game clients) or as actions to the UI:

  • If no mouse handlers are registered or if they don't consume events, the mouse input events are forwarded to the UI via CInputManager::ProcessMouse.
  • Clients (e.g. game clients implementing MOUSE::IMouseInputHandler) call CInputManager::RegisterMouseHandler to register themselves as eligible for mouse input events.
  • Mouse events (from CInputManager::OnEvent) are collected via implementations of MOUSE::IMouseDriverHandler and transformed into higher level features by MOUSE::IMouseButtonMap instances before they are sent to the handlers.

Constructor & Destructor Documentation

◆ CInputManager() [1/2]

CInputManager::CInputManager ( const CAppParamParser params)
explicit

◆ CInputManager() [2/2]

CInputManager::CInputManager ( const CInputManager )
delete

◆ ~CInputManager()

CInputManager::~CInputManager ( )
override

Member Function Documentation

◆ AddKeymap()

void CInputManager::AddKeymap ( const std::string &  keymap)

◆ ClearKeymaps()

void CInputManager::ClearKeymaps ( )

◆ Deinitialize()

void CInputManager::Deinitialize ( )

Deinitialize input and keymaps.

◆ ExecuteBuiltin()

int CInputManager::ExecuteBuiltin ( const std::string &  execute,
const std::vector< std::string > &  params 
)

Parse a builtin command and execute any input action currently only LIRC commands implemented.

Parameters
[in]executeCommand to execute
[in]paramsparameters that was passed to the command
Returns
0 on success, -1 on failure

◆ GetAction()

CAction CInputManager::GetAction ( int  window,
const CKey key,
bool  fallback = true 
)

Obtain the action configured for a given window and key.

Parameters
windowthe window id
keythe key to query the action for
fallbackif no action is directly configured for the given window, obtain the action from fallback window, if exists or from global config as last resort
Returns
the action matching the key

◆ GetJoystickKeymaps()

std::vector< std::shared_ptr< const IWindowKeymap > > CInputManager::GetJoystickKeymaps ( ) const

◆ GetMousePosition()

MousePosition CInputManager::GetMousePosition ( )

Get the current mouse positions x and y coordinates.

Returns
a struct containing the x and y coordinates
See also
MousePosition

◆ GetMouseState()

MOUSE_STATE CInputManager::GetMouseState ( )

Get the current state of the mouse, such as click or drag operation.

Returns
the current state of the mouse as a value from MOUSE_STATE
See also
MOUSE_STATE

◆ HasBuiltin()

bool CInputManager::HasBuiltin ( const std::string &  command)

Returns whether or not we can handle a given built-in command.

◆ InitializeInputs()

void CInputManager::InitializeInputs ( )

Call once during application startup to initialize peripherals that need it.

◆ IsMouseActive()

bool CInputManager::IsMouseActive ( )

Check if the mouse is currently active.

Returns
true if active, false otherwise

◆ KeymapEnvironment()

const IKeymapEnvironment * CInputManager::KeymapEnvironment ( ) const
inline

◆ LoadKeymaps()

bool CInputManager::LoadKeymaps ( )

◆ OnAction()

bool CInputManager::OnAction ( const CAction action)
overridevirtual

Implements IActionListener.

◆ OnEvent()

bool CInputManager::OnEvent ( XBMC_Event newEvent)

Handle an input event.

Parameters
newEventevent details
Returns
true on successfully handled event
See also
XBMC_Event

◆ OnSettingChanged()

void CInputManager::OnSettingChanged ( std::shared_ptr< const CSetting setting)
overridevirtual

The value of the given setting has changed.

This callback is triggered whenever the value of a setting has been successfully changed (i.e. none of the OnSettingChanging() handlers) has reverted the change.

Parameters
settingThe setting whose value has been changed

Reimplemented from ISettingCallback.

◆ operator=()

CInputManager const & CInputManager::operator= ( CInputManager const &  )
delete

◆ Process()

bool CInputManager::Process ( int  windowId,
float  frameTime 
)

Process all inputs.

Parameters
windowIdCurrently active window
frameTimeTime in seconds since last call
Returns
true on success, false otherwise

◆ ProcessEventServer()

bool CInputManager::ProcessEventServer ( int  windowId,
float  frameTime 
)

decode an event from the event service, this can be mouse, key, joystick, reset idle timers.

Parameters
windowIdCurrently active window
frameTimeTime in seconds since last call
Returns
true if event is handled, false otherwise

◆ ProcessMouse()

bool CInputManager::ProcessMouse ( int  windowId)

decode a mouse event and reset idle timers.

Parameters
windowIdCurrently active window
Returns
true if event is handled, false otherwise

◆ ProcessPeripherals()

bool CInputManager::ProcessPeripherals ( float  frameTime)

decode an event from peripherals.

Parameters
frameTimeTime in seconds since last call
Returns
true if event is handled, false otherwise

◆ QueueAction()

void CInputManager::QueueAction ( const CAction action)

Queue an action to be processed on the next call to Process()

◆ RegisterKeyboardDriverHandler()

void CInputManager::RegisterKeyboardDriverHandler ( KODI::KEYBOARD::IKeyboardDriverHandler handler)

◆ RegisterMouseDriverHandler()

void CInputManager::RegisterMouseDriverHandler ( KODI::MOUSE::IMouseDriverHandler handler)
virtual

◆ ReloadKeymaps()

bool CInputManager::ReloadKeymaps ( )

◆ RemoveKeymap()

void CInputManager::RemoveKeymap ( const std::string &  keymap)

◆ SetMouseActive()

void CInputManager::SetMouseActive ( bool  active = true)

Control if the mouse is actively used or not.

Parameters
[in]activesets mouse active or inactive

◆ SetMouseEnabled()

void CInputManager::SetMouseEnabled ( bool  mouseEnabled = true)

Control if we should use a mouse or not.

Parameters
[in]mouseEnabledsets mouse enabled or disabled

◆ SetMouseResolution()

void CInputManager::SetMouseResolution ( int  maxX,
int  maxY,
float  speedX,
float  speedY 
)

Set the current screen resolution and pointer speed.

Parameters
[in]maxXscreen width
[in]maxYscreen height
[in]speedXmouse speed in x dimension
[in]speedYmouse speed in y dimension
Returns

◆ SetMouseState()

void CInputManager::SetMouseState ( MOUSE_STATE  mouseState)

Set the current state of the mouse such as click, drag operation.

Parameters
[in]mouseStatewhich state the mouse should be set to
See also
MOUSE_STATE

◆ TranslateCustomControllerString()

bool CInputManager::TranslateCustomControllerString ( int  windowId,
const std::string &  controllerName,
int  buttonId,
int &  action,
std::string &  strAction 
)

◆ TranslateTouchAction()

bool CInputManager::TranslateTouchAction ( int  windowId,
int  touchAction,
int  touchPointers,
int &  action,
std::string &  actionString 
)

◆ UnregisterKeyboardDriverHandler()

void CInputManager::UnregisterKeyboardDriverHandler ( KODI::KEYBOARD::IKeyboardDriverHandler handler)

◆ UnregisterMouseDriverHandler()

void CInputManager::UnregisterMouseDriverHandler ( KODI::MOUSE::IMouseDriverHandler handler)
virtual

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