matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
engine::platform::Key Class Referencefinal

Represents the state of the key in a given frame. More...

#include <Input.hpp>

Public Types

enum class  State { Released , JustPressed , Pressed , JustReleased }
 The state of the key with regard to whether it is pressed or not. More...
 

Public Member Functions

Statestate ()
 
KeyId id () const
 
std::string_view name ()
 
State state () const
 
std::string_view state_str () const
 
bool is_down () const
 Shorthand method for checking whether the key is down.
 
bool is_up () const
 Shorthand method for checking whether the key is up.
 

Private Attributes

KeyId m_key = KEY_COUNT
 
State m_state = State::Released
 

Friends

class PlatformController
 

Detailed Description

Represents the state of the key in a given frame.

Member Enumeration Documentation

◆ State

enum class engine::platform::Key::State
strong

The state of the key with regard to whether it is pressed or not.

Enumerator
Released 

The key is up.

JustPressed 

The key has just been pressed in the current frame. This state only lasts for the frame in which the key was first registered as pressed.

Pressed 

The key is being held down. If the key was JustPressed in the previous frame, and it is still down in the current frame, its state transitions into Pressed.

JustReleased 

Lasts only for the frame in which the key was released. In the next frame, if the key is not pressed again, it transitions into Released.

Member Function Documentation

◆ state() [1/2]

State & engine::platform::Key::state ( )
inline
Returns
The state of the key in the current frame.

◆ id()

KeyId engine::platform::Key::id ( ) const
inline
Returns
The id of the key.

◆ name()

std::string_view engine::platform::Key::name ( )
Returns
The KeyId as a string.

◆ state() [2/2]

State engine::platform::Key::state ( ) const
inline

◆ state_str()

std::string_view engine::platform::Key::state_str ( ) const
Returns
The State of the key as a string_view.

◆ is_down()

bool engine::platform::Key::is_down ( ) const
inline

Shorthand method for checking whether the key is down.

Returns
True if the key is Pressed or JustPressed

◆ is_up()

bool engine::platform::Key::is_up ( ) const
inline

Shorthand method for checking whether the key is up.

Returns
True if the key is Released or JustReleased

Friends And Related Symbol Documentation

◆ PlatformController

friend class PlatformController
friend

Member Data Documentation

◆ m_key

KeyId engine::platform::Key::m_key = KEY_COUNT
private

◆ m_state

State engine::platform::Key::m_state = State::Released
private

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