The Table Engine
Input Class Reference

Component for handling and storing the state of input devices. More...

#include <input.h>

+ Inheritance diagram for Input:
+ Collaboration diagram for Input:

Public Member Functions

 Input ()
 Constructor for the Input component. More...
 
 ~Input ()
 Destructor for the Input component. More...
 
void update () override
 Updates the state of the input based on the latest user interactions. More...
 
- Public Member Functions inherited from Component
 Component ()
 Default constructor for the Component. More...
 
 Component (std::string name)
 Constructs a Component with a specified name. More...
 
virtual ~Component ()
 Virtual destructor for safe polymorphic use. More...
 
std::string getName ()
 Retrieves the name of the component. More...
 
GameObjectgetOwner ()
 Retrieves the GameObject that owns this component. More...
 
void setName (std::string name)
 Sets the name of the component. More...
 
void setOwner (GameObject *owner)
 Sets the GameObject owner of this component. More...
 
virtual void input ()
 Virtual method for handling input, intended to be overridden by derived components. More...
 
virtual void render ()
 Virtual method for rendering, intended to be overridden by derived components. More...
 

Public Attributes

bool spacePressed = false
 True if the space bar is pressed, false otherwise. More...
 
bool leftPressed = false
 True if the left arrow key is pressed, false otherwise. More...
 
bool rightPressed = false
 True if the right arrow key is pressed, false otherwise. More...
 
bool upPressed = false
 True if the up arrow key is pressed, false otherwise. More...
 
bool downPressed = false
 True if the down arrow key is pressed, false otherwise. More...
 
int m_mouseX
 
int m_mouseY
 Current position of the mouse cursor. More...
 
bool mouseLeftPressed = false
 True if the left mouse button is pressed, false otherwise. More...
 
bool mouseRightPressed = false
 True if the right mouse button is pressed, false otherwise. More...
 
bool mouseMiddlePressed = false
 True if the middle mouse button is pressed, false otherwise. More...
 

Additional Inherited Members

- Protected Attributes inherited from Component
std::string m_name
 Name of the component, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this component. More...
 

Detailed Description

Component for handling and storing the state of input devices.

The Input class extends the Component class and is used to track the state of various keys and mouse buttons, as well as the mouse's position, providing a centralized way to handle user interactions.

Definition at line 20 of file input.h.

Constructor & Destructor Documentation

◆ Input()

Input::Input ( )

Constructor for the Input component.

Definition at line 6 of file input.cpp.

◆ ~Input()

Input::~Input ( )

Destructor for the Input component.

Definition at line 13 of file input.cpp.

Member Function Documentation

◆ update()

void Input::update ( )
overridevirtual

Updates the state of the input based on the latest user interactions.

This method should be called every frame to update the input states (e.g., which keys are pressed).

Reimplemented from Component.

Definition at line 17 of file input.cpp.

Member Data Documentation

◆ downPressed

bool Input::downPressed = false

True if the down arrow key is pressed, false otherwise.

Definition at line 27 of file input.h.

◆ leftPressed

bool Input::leftPressed = false

True if the left arrow key is pressed, false otherwise.

Definition at line 24 of file input.h.

◆ m_mouseX

int Input::m_mouseX

Definition at line 29 of file input.h.

◆ m_mouseY

int Input::m_mouseY

Current position of the mouse cursor.

Definition at line 29 of file input.h.

◆ mouseLeftPressed

bool Input::mouseLeftPressed = false

True if the left mouse button is pressed, false otherwise.

Definition at line 31 of file input.h.

◆ mouseMiddlePressed

bool Input::mouseMiddlePressed = false

True if the middle mouse button is pressed, false otherwise.

Definition at line 33 of file input.h.

◆ mouseRightPressed

bool Input::mouseRightPressed = false

True if the right mouse button is pressed, false otherwise.

Definition at line 32 of file input.h.

◆ rightPressed

bool Input::rightPressed = false

True if the right arrow key is pressed, false otherwise.

Definition at line 25 of file input.h.

◆ spacePressed

bool Input::spacePressed = false

True if the space bar is pressed, false otherwise.

Definition at line 22 of file input.h.

◆ upPressed

bool Input::upPressed = false

True if the up arrow key is pressed, false otherwise.

Definition at line 26 of file input.h.


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