V-Gears 0
Free Final Fantasy VII engine.
InputManager Class Reference

The input manager. More...

#include <InputManager.h>

Inheritance diagram for InputManager:
Collaboration diagram for InputManager:

Classes

struct  BindGameEventInfo
 A game event binding. More...
 
struct  BindInfo
 A command binding. More...
 

Public Member Functions

 InputManager ()
 Constructor. More...
 
virtual ~InputManager ()
 Destructor. More...
 
void Input (const VGears::Event &event) override
 Makes the input manager itself handles an input event. More...
 
void Update ()
 Update keyboard and mouse buttons, movements and scroll status. More...
 
void UpdateDebug () override
 Updates the input manager with debug information. More...
 
void OnResize () override
 Handles resizing events. More...
 
void ClearField () override
 Clears all field information in the input manager. More...
 
void ClearBattle () override
 Clears all battle information in the input manager. More...
 
void ClearWorld () override
 Clears all world map information in the input manager. More...
 
void ButtonPressed (int button, char text, bool down)
 Triggered when a keyboard button is pressed or released. More...
 
void MousePressed (int button, bool down)
 Triggered when a mouse button is pressed or released. More...
 
void MouseMoved (int x, int y)
 Triggered when a mouse moves. More...
 
void MouseScrolled (int value)
 Triggered when a mouse scrolls. More...
 
void Reset ()
 Resets all keyboard and mouse events to their default state. More...
 
bool IsButtonPressed (int button) const
 Checks if a button is being pressed. More...
 
void GetInputEvents (InputEventArray &input_events)
 Retrieves the current input events. More...
 
void InitCmd ()
 Initializes all command bindings. More...
 
void BindCommand (ConfigCmd *cmd, const Ogre::StringVector &params, const ButtonList &buttons)
 Binds a command to an input event. More...
 
void BindGameEvent (const Ogre::String &event, const ButtonList &buttons)
 Binds a game event to an input event. More...
 
void ActivateBinds (const int button)
 Activates all bindings for a button. More...
 
void AddGameEvents (const int button, const VGears::EventType type)
 Adds a game event associated to a button. More...
 
- Public Member Functions inherited from Manager
 Manager ()
 Constructor. More...
 
virtual ~Manager ()
 Destructor. More...
 
Module GetModule () const
 Retrieves the currently selected module. More...
 
bool IsModule (const Module module) const
 Checks the currently selected module. More...
 
bool IsFieldModule () const
 Checks if the currently selected module is the field module. More...
 
bool IsBattleModule () const
 Checks if the currently selected module is the battle module. More...
 
bool IsWorldModule () const
 Checks if the currently selected module is the world module. More...
 
void SetModule (const Module module)
 Sets the current module for the entity manager. More...
 
void SetFieldModule ()
 Sets the current module to the field mode. More...
 
void SetBattleModule ()
 Sets the current module to the battle mode. More...
 
void SetWorldModule ()
 Sets the current module to the world map mode. More...
 
void SetPreviousModule ()
 Sets the module that was loaded before a battle. More...
 
virtual void Input (const VGears::Event &event)=0
 Handles an input event. More...
 
void Update ()
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void UpdateDebug ()=0
 Called every frame, performs an update on the things controlled by the manager. More...
 
virtual void OnResize ()=0
 Handles resizing events. More...
 
void Clear ()
 Clears the manager. More...
 
void Clear (const Module module)
 Clears the manager. More...
 
virtual void ClearField ()=0
 Clear all field information in the manager. More...
 
virtual void ClearBattle ()=0
 Clear all battle information in the manager. More...
 
virtual void ClearWorld ()=0
 Clear all world map information in the manager. More...
 
void ClearAll ()
 Clears the manager. More...
 
void ScriptSetPaused (const bool paused)
 Handles game pausing. More...
 

Private Member Functions

void UpdateField () override
 Updates the input manager while on the fields. More...
 
void UpdateBattle () override
 Updates the input manager while on a battle. More...
 
void UpdateWorld () override
 Updates the input manager while on the world map. More...
 

Private Attributes

bool button_state_ [256]
 The state of eahc button. More...
 
char button_text_ [256]
 The text of each button. More...
 
bool repeat_first_wait_
 Indicates if a key held down is waiting to repeat events. More...
 
float repeat_timer_
 The time a key has been pressed. More...
 
InputEventArray event_queue_
 The event queue. More...
 
std::vector< BindInfobinds_
 List of command bindings. More...
 
std::vector< BindGameEventInfobind_game_events_
 List of game event bindings. More...
 

Additional Inherited Members

- Public Types inherited from Manager
enum  Module { FIELD = 0 , BATTLE = 1 , WORLD = 2 }
 The modules the entity manager can handle. More...
 
- Protected Member Functions inherited from Manager
virtual void UpdateField ()=0
 Updates the field entities in the manager. More...
 
virtual void UpdateBattle ()=0
 Updates the battle entities in the manager. More...
 
virtual void UpdateWorld ()=0
 Updates the world map entities in the manager. More...
 
void Update (Module module)
 Updates the entities of one module in the manager. More...
 
- Protected Attributes inherited from Manager
Module module_
 The currently selected module. More...
 
Module prev_module_
 The previous module. More...
 
bool paused_
 Indicates if the game is paused. More...
 

Detailed Description

The input manager.

It handles input events and creates {

See also
Event}s.

Constructor & Destructor Documentation

◆ InputManager()

InputManager::InputManager ( )

Constructor.

◆ ~InputManager()

InputManager::~InputManager ( )
virtual

Destructor.

Member Function Documentation

◆ ActivateBinds()

void InputManager::ActivateBinds ( const int  button)

Activates all bindings for a button.

Parameters
[in]buttonID of the button.

◆ AddGameEvents()

void InputManager::AddGameEvents ( const int  button,
const VGears::EventType  type 
)

Adds a game event associated to a button.

Parameters
[in]buttonID of the button.
[in]typeEvent type.

◆ BindCommand()

void InputManager::BindCommand ( ConfigCmd cmd,
const Ogre::StringVector &  params,
const ButtonList buttons 
)

Binds a command to an input event.

Parameters
[in]cmdCommand to bind.
[in]paramsCommand arguments.
[in]buttonsButtons to bind to the command.

◆ BindGameEvent()

void InputManager::BindGameEvent ( const Ogre::String &  event,
const ButtonList buttons 
)

Binds a game event to an input event.

Parameters
[in]eventThe game event to bind.
[in]buttonsButtons to bind to the event.

◆ ButtonPressed()

void InputManager::ButtonPressed ( int  button,
char  text,
bool  down 
)

Triggered when a keyboard button is pressed or released.

Creates an {

See also
Event}.
Parameters
[in]buttonPressed button ID.
[in]text
Todo:
The key code? It gets assigned to parameter 1 of the generated event.
Parameters
[in]downTrue if the button has been pressed, false if it has been released. It gets assigned to parameter 2 of the event.

◆ ClearBattle()

void InputManager::ClearBattle ( )
overridevirtual

Clears all battle information in the input manager.

It does nothing.

Implements Manager.

◆ ClearField()

void InputManager::ClearField ( )
overridevirtual

Clears all field information in the input manager.

It does nothing.

Implements Manager.

◆ ClearWorld()

void InputManager::ClearWorld ( )
overridevirtual

Clears all world map information in the input manager.

It does nothing.

Implements Manager.

◆ GetInputEvents()

void InputManager::GetInputEvents ( InputEventArray input_events)

Retrieves the current input events.

The input event queue will be empty after calling this function.

Parameters
[out]input_eventsThe current events will be loaded here.

◆ InitCmd()

void InputManager::InitCmd ( )

Initializes all command bindings.

◆ Input()

void InputManager::Input ( const VGears::Event event)
overridevirtual

Makes the input manager itself handles an input event.

Parameters
[in]eventEvent to handle.

Implements Manager.

◆ IsButtonPressed()

bool InputManager::IsButtonPressed ( int  button) const

Checks if a button is being pressed.

Parameters
[in]buttonButton code.
Returns
true if the button is being pressed, false otherwise.

◆ MouseMoved()

void InputManager::MouseMoved ( int  x,
int  y 
)

Triggered when a mouse moves.

Creates an {

See also
Event}.
Parameters
[in]xNew mouse's X coordinate. It gets assigned to parameter 1 of the event.
[in]yNew mouse's Y coordinate. It gets assigned to parameter 2 of the event.

◆ MousePressed()

void InputManager::MousePressed ( int  button,
bool  down 
)

Triggered when a mouse button is pressed or released.

Creates an {

See also
Event}.
Parameters
[in]buttonPressed button ID.
[in]downTrue if the button has been pressed, false if it has been released. It gets assigned to parameter 1 of the event.

◆ MouseScrolled()

void InputManager::MouseScrolled ( int  value)

Triggered when a mouse scrolls.

Creates an {

See also
Event}.
Parameters
[in]valueNumber of lines scrolled. Positive for scroll down, negative for scroll up. It gets assigned to parameter 1 of the event.

◆ OnResize()

void InputManager::OnResize ( )
overridevirtual

Handles resizing events.

Implements Manager.

◆ Reset()

void InputManager::Reset ( )

Resets all keyboard and mouse events to their default state.

Keyboard and mouse are considered to not pressed, the mouse movement and scroll are considered 0.

◆ Update()

void InputManager::Update ( )

Update keyboard and mouse buttons, movements and scroll status.

◆ UpdateBattle()

void InputManager::UpdateBattle ( )
overrideprivatevirtual

Updates the input manager while on a battle.

It just calls the generic {

See also
Update()}.

Implements Manager.

◆ UpdateDebug()

void InputManager::UpdateDebug ( )
overridevirtual

Updates the input manager with debug information.

Implements Manager.

◆ UpdateField()

void InputManager::UpdateField ( )
overrideprivatevirtual

Updates the input manager while on the fields.

It just calls the generic {

See also
Update()}.

Implements Manager.

◆ UpdateWorld()

void InputManager::UpdateWorld ( )
overrideprivatevirtual

Updates the input manager while on the world map.

It just calls the generic {

See also
Update()}.

Implements Manager.

Member Data Documentation

◆ bind_game_events_

std::vector<BindGameEventInfo> InputManager::bind_game_events_
private

List of game event bindings.

◆ binds_

std::vector<BindInfo> InputManager::binds_
private

List of command bindings.

◆ button_state_

bool InputManager::button_state_[256]
private

The state of eahc button.

◆ button_text_

char InputManager::button_text_[256]
private

The text of each button.

Todo:
The text is the keycode?

◆ event_queue_

InputEventArray InputManager::event_queue_
private

The event queue.

◆ repeat_first_wait_

bool InputManager::repeat_first_wait_
private

Indicates if a key held down is waiting to repeat events.

Todo:
Verify this.

◆ repeat_timer_

float InputManager::repeat_timer_
private

The time a key has been pressed.


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