RavEngine
Loading...
Searching...
No Matches
RavEngine::InputManager Class Reference
Collaboration diagram for RavEngine::InputManager:
[legend]

Classes

class  ActionBinding
 
struct  aid_eq
 
struct  aid_hasher
 
class  AxisBinding
 
struct  AxisData
 
struct  AxisID
 
struct  AxisInput
 

Public Member Functions

void TickAxes ()
 
void ProcessInput (const SDL_Event &, uint32_t windowflags, float scale, int windowWidth, int windowHeight, float dpiScale)
 
void AddActionMap (const std::string &name, int Id)
 
void AddAxisMap (const std::string &name, int Id, float scale=1)
 
void RemoveActionMap (const std::string &name, int Id)
 
void RemoveAxisMap (const std::string &name, int Id, float scale=1)
 
template<class U , typename T >
void BindAction (const std::string &name, T thisptr, void(U::*f)(), ActionState type, CID controllers)
 
template<typename U , typename T >
void BindAxis (const std::string &name, T thisptr, void(U::*f)(float), CID controllers, float deadZone=0)
 
template<typename U , typename T >
void UnbindAction (const std::string &name, T thisptr, void(U::*f)(), ActionState type, CID controllers)
 
template<typename U , typename T >
void UnbindAxis (const std::string &name, T thisptr, void(U::*f)(float), CID controllers, float deadZone)
 
void BindAnyAction (Ref< IInputListener > listener)
 
void UnbindAnyAction (Ref< IInputListener > listener)
 

Static Public Member Functions

static vector2 GetMousePosPixels (float dpiScaleFactor)
 

Protected Member Functions

void ProcessActionID (int ID, ActionState state_in, CID controller)
 
void ProcessAxisID (int ID, float value, CID controller)
 
void CleanupBindings ()
 

Protected Attributes

locked_hashmap< int, locked_hashset< std::string, SpinLock >, SpinLock > CodeToAction
 
locked_hashmap< std::string, LinkedList< ActionBinding >, SpinLock > ActionBindings
 
locked_hashmap< int, locked_hashset< AxisID, SpinLock, aid_hasher, aid_eq >, SpinLock > CodeToAxis
 
UnorderedMap< std::string, AxisData > AxisBindings
 
LinkedList< WeakPtrKey< IInputListener > > AnyEventBindings
 

Member Function Documentation

◆ AddActionMap()

void RavEngine::InputManager::AddActionMap ( const std::string &  name,
int  Id 
)
inline

Create an action mapping entry. Action mappings correspond to items that have two states: pressed and released.

Parameters
namethe identifer to use when binding or unbinding actions
Idthe button identifier to use. See the SDL key bindings for more information. To bind controllers, see the special bindings at the top of this file.

◆ AddAxisMap()

void RavEngine::InputManager::AddAxisMap ( const std::string &  name,
int  Id,
float  scale = 1 
)
inline

Create an axis mapping entry. Axis mappings correspond to items that have a range of values, such as the mouse or analog sticks.

Parameters
namethe identifer to use when binding or unbinding axes
Idthe button identifier to use. See the SDL key bindings for more information. To bind controllers, see the special bindings at the top of this file.
scalethe scale factor to apply to all bindings mapped to this axis

◆ BindAction()

template<class U , typename T >
void RavEngine::InputManager::BindAction ( const std::string &  name,
T  thisptr,
void(U::*)()  f,
ActionState  type,
CID  controllers 
)
inline

Bind an action map to a member function

Parameters
namethe name of the action map to bind to
thisptrthe object to bind to. Use this if within the class you want to bind to
fthe method to invoke when the action is triggered. Must take no parameters. Use &Classname::Methodname.
typethe required state of the action to invoke the method.

◆ BindAnyAction()

void RavEngine::InputManager::BindAnyAction ( Ref< IInputListener >  listener)
inline

Bind an object to recieve AnyEvents. This will invoke its AnyDown and AnyUp virtual methods

◆ BindAxis()

template<typename U , typename T >
void RavEngine::InputManager::BindAxis ( const std::string &  name,
T  thisptr,
void(U::*)(float)  f,
CID  controllers,
float  deadZone = 0 
)
inline

Bind a function to an Axis mapping

Parameters
namethe Axis mapping to bind to
thisptrthe object to bind to. Use this if within the class you want to bind to
fthe method to invoke when the action is triggered. Must take one float parameter. Use &Classname::Methodname.
deadZonethe minimum value (+/-) required to activate this binding

◆ CleanupBindings()

void InputManager::CleanupBindings ( )
protected

Purge invalid bindings from the lists

◆ ProcessActionID()

void InputManager::ProcessActionID ( int  ID,
ActionState  state_in,
CID  controller 
)
protected

Process a single action event

Parameters
IDthe event ID. It may need to be transformed if there is overlap in SDL
state_inthe state of the event
controllerthe source controller

◆ ProcessAxisID()

void InputManager::ProcessAxisID ( int  ID,
float  value,
CID  controller 
)
protected

Buffer an Axis value

Parameters
IDthe event ID. It may need to be transformed if there is overlap in SDL
valuethe axis' value
controllerthe source controller

◆ ProcessInput()

void InputManager::ProcessInput ( const SDL_Event &  event,
uint32_t  windowflags,
float  scale,
int  windowWidth,
int  windowHeight,
float  dpiScale 
)

Prcocess an input from SDL

◆ RemoveActionMap()

void RavEngine::InputManager::RemoveActionMap ( const std::string &  name,
int  Id 
)
inline

Remove an action mapping entry. Both the name and ID must match to complete removal.

Parameters
namethe identifer to look for
Idthe button identifier to use. See the SDL key bindings for more information.

◆ RemoveAxisMap()

void RavEngine::InputManager::RemoveAxisMap ( const std::string &  name,
int  Id,
float  scale = 1 
)
inline

Remove an axis mapping entry. Both the name and ID must match to complete removal.

Parameters
namethe identifer to look for
Idthe button identifier to use. See the SDL key bindings for more information.

◆ UnbindAction()

template<typename U , typename T >
void RavEngine::InputManager::UnbindAction ( const std::string &  name,
T  thisptr,
void(U::*)()  f,
ActionState  type,
CID  controllers 
)
inline

Bind a function to an Action mapping

Parameters
namethe Action mapping to unbind
thisptrthe object to bind to. Use this if within the class you want to bind to
fthe method to invoke when the action is triggered. Must take no parameters. Use &Classname::Methodname.
statethe state to use to match the callback

◆ UnbindAnyAction()

void RavEngine::InputManager::UnbindAnyAction ( Ref< IInputListener >  listener)
inline

Unbind an object to recieve AnyEvents. This is done automatically when an IInputListener is destructed.

◆ UnbindAxis()

template<typename U , typename T >
void RavEngine::InputManager::UnbindAxis ( const std::string &  name,
T  thisptr,
void(U::*)(float)  f,
CID  controllers,
float  deadZone 
)
inline

Unbind an Axis mapping

Parameters
thisptrthe object to bind to. Use this if within the class you want to bind to
fthe method to invoke when the action is triggered. Must take one float parameter. Use &Classname::Methodname.
deadZonethe minimum value (+/-) required to activate this binding

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