IActionMapManager

IActionMapManagerabstract

Main interface to the action map manager, responsible for catching raw input from IInput and mapping it to actions registered by the user. More...

#include

Public Member Functions

virtual void Update ()=0
virtual void Reset ()=0
virtual void Clear ()=0
virtual bool InitActionMaps (const char *filename)=0
virtual void SetLoadFromXMLPath (const char *szPath)=0
virtual const char * GetLoadFromXMLPath () const =0
virtual bool LoadFromXML (const XmlNodeRef &node)=0
virtual bool LoadRebindDataFromXML (const XmlNodeRef &node)=0
virtual bool SaveRebindDataToXML (XmlNodeRef &node)=0
virtual bool AddExtraActionListener (IActionListener *pExtraActionListener, const char *szActionMap=nullptr)=0
virtual bool RemoveExtraActionListener (IActionListener *pExtraActionListener, const char *szActionMap=nullptr)=0
virtual const TActionListeners & GetExtraActionListeners () const =0
virtual bool AddFlowgraphNodeActionListener (IActionListener *pFlowgraphActionListener, const char *szActionMap=nullptr)=0
virtual bool RemoveFlowgraphNodeActionListener (IActionListener *pFlowgraphActionListener, const char *szActionMap=nullptr)=0
virtual void AddAlwaysActionListener (TBlockingActionListener pActionListener)=0
virtual void RemoveAlwaysActionListener (TBlockingActionListener pActionListener)=0
virtual void RemoveAllAlwaysActionListeners ()=0
virtual IActionMap * CreateActionMap (const char *szName)=0
virtual bool RemoveActionMap (const char *name)=0
virtual void RemoveAllActionMaps ()=0
virtual IActionMap * GetActionMap (const char *name)=0
virtual IActionFilter * CreateActionFilter (const char *name, EActionFilterType type)=0
virtual IActionFilter * GetActionFilter (const char *name)=0
virtual IActionMapIteratorPtr CreateActionMapIterator ()=0
virtual IActionFilterIteratorPtr CreateActionFilterIterator ()=0
virtual const SActionInput * GetActionInput (const char *actionMapName, const ActionId &actionId, const EActionInputDevice device, const int iByDeviceIndex) const =0
virtual void Enable (const bool enable, const bool resetStateOnDisable=false)=0
virtual void EnableActionMap (const char *name, bool enable)=0
virtual void EnableFilter (const char *name, bool enable)=0
virtual bool IsFilterEnabled (const char *name)=0
virtual void ReleaseFilteredActions ()=0
virtual void ClearStoredCurrentInputData ()=0
virtual bool ReBindActionInput (const char *actionMapName, const ActionId &actionId, const char *szCurrentInput, const char *szNewInput)=0
virtual int GetVersion () const =0
virtual void SetVersion (int version)=0
virtual void EnumerateActions (IActionMapPopulateCallBack *pCallBack) const =0
virtual int GetActionsCount () const =0
virtual int GetActionMapsCount () const =0
virtual bool AddInputDeviceMapping (const EActionInputDevice deviceType, const char *szDeviceTypeStr)=0
virtual bool RemoveInputDeviceMapping (const EActionInputDevice deviceType)=0
virtual void ClearInputDevicesMappings ()=0
virtual int GetNumInputDeviceData () const =0
virtual const SActionInputDeviceData * GetInputDeviceDataByIndex (const int iIndex)=0
virtual const SActionInputDeviceData * GetInputDeviceDataByType (const EActionInputDevice deviceType)=0
virtual const SActionInputDeviceData * GetInputDeviceDataByType (const char *szDeviceType)=0
virtual void RemoveAllRefireData ()=0
virtual bool LoadControllerLayoutFile (const char *szLayoutKeyName)=0
virtual EntityId GetDefaultActionEntity () const =0
virtual void SetDefaultActionEntity (EntityId id, bool bUpdateAll=true)=0
virtual void RegisterActionMapEventListener (IActionMapEventListener *pActionMapEventListener)=0
virtual void UnregisterActionMapEventListener (IActionMapEventListener *pActionMapEventListener)=0

Detailed Description

Main interface to the action map manager, responsible for catching raw input from IInput and mapping it to actions registered by the user.

Member Function Documentation

◆ AddExtraActionListener()

virtual bool IActionMapManager::AddExtraActionListener ( IActionListener * pExtraActionListener,
const char * szActionMap = nullptr
)
pure virtual

Adds a listener to receive events when actions are triggered

Parameters
pExtraActionListenerThe listener in which we want to receive events
actionMapThe action map we want to receive events for, or if unspecified sends events for all action maps
#include 

// Example of how action maps can be registered, and how to receive callbacks when their actions are triggered
class CMyActionListener final : public IActionListener
{
    // Define the name of the action map in which our action will reside
    const char* m_szMyActionMapName = "MyActionGroup";
    // Define the identifier of the action we are registering, this should be a constant over the runtime of the application
    const ActionId m_myActionId = ActionId("MyAction");

    virtual ~CMyActionListener()
    {
        // Make sure to remove the listener when we are done
        gEnv->pGameFramework->GetIActionMapManager()->RemoveExtraActionListener(this, m_szMyActionMapName);
    }

    void RegisterAction()
    {
        IActionMapManager* pActionMapManager = gEnv->pGameFramework->GetIActionMapManager();

        // Create the action map in which our action will reside
        IActionMap* pActionMap = pActionMapManager->CreateActionMap(m_szMyActionMapName);
        // Register a listener to receive callbacks when actions in our action map are triggered
        pActionMapManager->AddExtraActionListener(this, m_szMyActionMapName);

        // Register the action in the group
        pActionMap->CreateAction(m_myActionId);

        // Now define the first input with which the user can trigger the input
        SActionInput input;
        // Define that this input is triggered with the keyboard or mouse
        input.inputDevice = eAID_KeyboardMouse;
        // Set the input to "enter"
        // defaultInput is used in case of future rebinding by the end-user at runtime
        input.input = input.defaultInput = "enter";
        // Determine the activation modes we want to listen for
        input.activationMode = eIS_Pressed | eIS_Released;

        // Now bind the input to the action we created earlier
        pActionMap->AddAndBindActionInput(m_myActionId, input);

        // Make sure that the action map is enabled by default
        // This function can also be used to toggle action maps at runtime, for example to disable vehicle inputs when exiting
        pActionMap->Enable(true);
    }

    // Called when any action is triggered
    virtual void OnAction(const ActionId &actionId, int activationMode, float value) override
    {
        const bool isInputPressed = (activationMode & eIS_Pressed) != 0;
        const bool isInputReleased = (activationMode & eIS_Released) != 0;

        // Check if the triggered action
        if (actionId == m_myActionId)
        {
            if (isInputPressed)
            {
                CryLogAlways("Action pressed!");
            }
            else if (isInputReleased)
            {
                CryLogAlways("Action released!");
            }
        }
    }
};

◆ CreateActionMap()

virtual IActionMap* IActionMapManager::CreateActionMap ( const char * szName)
pure virtual

Creates an action map that can contain multiple actions inside

Parameters
szNameName of the action map
#include 

// Example of how action maps can be registered, and how to receive callbacks when their actions are triggered
class CMyActionListener final : public IActionListener
{
    // Define the name of the action map in which our action will reside
    const char* m_szMyActionMapName = "MyActionGroup";
    // Define the identifier of the action we are registering, this should be a constant over the runtime of the application
    const ActionId m_myActionId = ActionId("MyAction");

    virtual ~CMyActionListener()
    {
        // Make sure to remove the listener when we are done
        gEnv->pGameFramework->GetIActionMapManager()->RemoveExtraActionListener(this, m_szMyActionMapName);
    }

    void RegisterAction()
    {
        IActionMapManager* pActionMapManager = gEnv->pGameFramework->GetIActionMapManager();

        // Create the action map in which our action will reside
        IActionMap* pActionMap = pActionMapManager->CreateActionMap(m_szMyActionMapName);
        // Register a listener to receive callbacks when actions in our action map are triggered
        pActionMapManager->AddExtraActionListener(this, m_szMyActionMapName);

        // Register the action in the group
        pActionMap->CreateAction(m_myActionId);

        // Now define the first input with which the user can trigger the input
        SActionInput input;
        // Define that this input is triggered with the keyboard or mouse
        input.inputDevice = eAID_KeyboardMouse;
        // Set the input to "enter"
        // defaultInput is used in case of future rebinding by the end-user at runtime
        input.input = input.defaultInput = "enter";
        // Determine the activation modes we want to listen for
        input.activationMode = eIS_Pressed | eIS_Released;

        // Now bind the input to the action we created earlier
        pActionMap->AddAndBindActionInput(m_myActionId, input);

        // Make sure that the action map is enabled by default
        // This function can also be used to toggle action maps at runtime, for example to disable vehicle inputs when exiting
        pActionMap->Enable(true);
    }

    // Called when any action is triggered
    virtual void OnAction(const ActionId &actionId, int activationMode, float value) override
    {
        const bool isInputPressed = (activationMode & eIS_Pressed) != 0;
        const bool isInputReleased = (activationMode & eIS_Released) != 0;

        // Check if the triggered action
        if (actionId == m_myActionId)
        {
            if (isInputPressed)
            {
                CryLogAlways("Action pressed!");
            }
            else if (isInputReleased)
            {
                CryLogAlways("Action released!");
            }
        }
    }
};

◆ RemoveExtraActionListener()

virtual bool IActionMapManager::RemoveExtraActionListener ( IActionListener * pExtraActionListener,
const char * szActionMap = nullptr
)
pure virtual

Removes action map listener

Parameters
pExtraActionListenerThe listener that is currently registered to receive events
actionMapThe action map that we are receiving events for, or if unspecified removes from all action maps
#include 

// Example of how action maps can be registered, and how to receive callbacks when their actions are triggered
class CMyActionListener final : public IActionListener
{
    // Define the name of the action map in which our action will reside
    const char* m_szMyActionMapName = "MyActionGroup";
    // Define the identifier of the action we are registering, this should be a constant over the runtime of the application
    const ActionId m_myActionId = ActionId("MyAction");

    virtual ~CMyActionListener()
    {
        // Make sure to remove the listener when we are done
        gEnv->pGameFramework->GetIActionMapManager()->RemoveExtraActionListener(this, m_szMyActionMapName);
    }

    void RegisterAction()
    {
        IActionMapManager* pActionMapManager = gEnv->pGameFramework->GetIActionMapManager();

        // Create the action map in which our action will reside
        IActionMap* pActionMap = pActionMapManager->CreateActionMap(m_szMyActionMapName);
        // Register a listener to receive callbacks when actions in our action map are triggered
        pActionMapManager->AddExtraActionListener(this, m_szMyActionMapName);

        // Register the action in the group
        pActionMap->CreateAction(m_myActionId);

        // Now define the first input with which the user can trigger the input
        SActionInput input;
        // Define that this input is triggered with the keyboard or mouse
        input.inputDevice = eAID_KeyboardMouse;
        // Set the input to "enter"
        // defaultInput is used in case of future rebinding by the end-user at runtime
        input.input = input.defaultInput = "enter";
        // Determine the activation modes we want to listen for
        input.activationMode = eIS_Pressed | eIS_Released;

        // Now bind the input to the action we created earlier
        pActionMap->AddAndBindActionInput(m_myActionId, input);

        // Make sure that the action map is enabled by default
        // This function can also be used to toggle action maps at runtime, for example to disable vehicle inputs when exiting
        pActionMap->Enable(true);
    }

    // Called when any action is triggered
    virtual void OnAction(const ActionId &actionId, int activationMode, float value) override
    {
        const bool isInputPressed = (activationMode & eIS_Pressed) != 0;
        const bool isInputReleased = (activationMode & eIS_Released) != 0;

        // Check if the triggered action
        if (actionId == m_myActionId)
        {
            if (isInputPressed)
            {
                CryLogAlways("Action pressed!");
            }
            else if (isInputReleased)
            {
                CryLogAlways("Action released!");
            }
        }
    }
};