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

Main input processing class. More...

#include <InputManager.h>

Inheritance diagram for CInputManager:
ISettingCallback KODI::ACTION::IActionListener Observable

Public Member Functions

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

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.
 
- Protected Attributes inherited from Observable
std::atomic< boolm_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 ( )

◆ 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 KEYMAP::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.

◆ IsControllerEnabled()

bool CInputManager::IsControllerEnabled ( ) const

Get the status of the controller-enable setting.

Returns
True if controller input is enabled for the UI, false otherwise

◆ IsMouseActive()

bool CInputManager::IsMouseActive ( )

Check if the mouse is currently active.

Returns
true if active, false otherwise

◆ KeymapEnvironment()

const KEYMAP::IKeymapEnvironment * CInputManager::KeymapEnvironment ( ) const

◆ LoadKeymaps()

bool CInputManager::LoadKeymaps ( )

◆ OnAction()

bool CInputManager::OnAction ( const CAction & action)
overridevirtual

Handle a GUI action.

Parameters
actionThe GUI action
Returns
True if the action was handled, false otherwise

Implements KODI::ACTION::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 ( const 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: