GameKit  0.0.1a
C++ gamedev tools
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gk::InputHandler Class Reference

Give access to the real time state of an input device (keyboard, gamepad, etc...) More...

#include <InputHandler.hpp>

Inheritance diagram for gk::InputHandler:
gk::KeyboardHandler

Public Member Functions

virtual ~InputHandler ()=default
 
virtual bool isKeyPressed (GameKey key)
 Check if a key is pressed. More...
 
virtual bool isKeyPressedOnce (GameKey key)
 Check if a key is pressed only one time. More...
 
virtual bool isKeyPressedWithDelay (GameKey key, u16 delay)
 Check if a key is pressed with delay. More...
 
const std::map< GameKey, bool > & keysPressed () const
 Get current keys state. More...
 

Protected Member Functions

void addKey (GameKey key)
 Add a new key to this input handler. More...
 

Protected Attributes

std::map< GameKey, bool > m_keysPressed
 Keys state. More...
 
std::map< GameKey, bool > m_keysPressedOnce
 Keys state for isKeyPressedOnce. More...
 
std::map< GameKey, u32m_lastTimePressed
 Keys state for isKeyPressedWithDelay. More...
 

Detailed Description

Give access to the real time state of an input device (keyboard, gamepad, etc...)

gk::InputHandler is a base class for your own input handler.

See also
gk::GamePad

Definition at line 29 of file InputHandler.hpp.

Constructor & Destructor Documentation

§ ~InputHandler()

virtual gk::InputHandler::~InputHandler ( )
virtualdefault

Member Function Documentation

§ addKey()

void gk::InputHandler::addKey ( GameKey  key)
protected

Add a new key to this input handler.

The key you want to add

Definition at line 43 of file InputHandler.cpp.

§ isKeyPressed()

virtual bool gk::InputHandler::isKeyPressed ( GameKey  key)
inlinevirtual

Check if a key is pressed.

Parameters
keyKey to check
Returns
True if the key is pressed, false otherwise

Reimplemented in gk::KeyboardHandler.

Definition at line 41 of file InputHandler.hpp.

§ isKeyPressedOnce()

bool gk::InputHandler::isKeyPressedOnce ( GameKey  key)
virtual

Check if a key is pressed only one time.

Parameters
keyKey to check
Returns
True if the key is pressed, false otherwise or if true has already been returned once

Definition at line 19 of file InputHandler.cpp.

§ isKeyPressedWithDelay()

bool gk::InputHandler::isKeyPressedWithDelay ( GameKey  key,
u16  delay 
)
virtual

Check if a key is pressed with delay.

Parameters
keyKey to check
delayDelay between key presses (in milliseconds)
Returns
True if the key is pressed, false otherwise or if true has already been returned before <delay> ms

Definition at line 33 of file InputHandler.cpp.

§ keysPressed()

const std::map<GameKey, bool>& gk::InputHandler::keysPressed ( ) const
inline

Get current keys state.

Returns
The current keys state

Definition at line 70 of file InputHandler.hpp.

Member Data Documentation

§ m_keysPressed

std::map<GameKey, bool> gk::InputHandler::m_keysPressed
protected

Keys state.

Definition at line 84 of file InputHandler.hpp.

§ m_keysPressedOnce

std::map<GameKey, bool> gk::InputHandler::m_keysPressedOnce
protected

Keys state for isKeyPressedOnce.

Definition at line 85 of file InputHandler.hpp.

§ m_lastTimePressed

std::map<GameKey, u32> gk::InputHandler::m_lastTimePressed
protected

Keys state for isKeyPressedWithDelay.

Definition at line 86 of file InputHandler.hpp.


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