Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::Input Class Reference

Manages keyboard and mouse input. More...

#include <input.hpp>

Classes

struct  ButtonInfo
 Stores information about a mouse button's state. More...
 
struct  KeyInfo
 Stores information about a key's state. More...
 

Public Types

enum class  Buttons { Mouse_Left , Mouse_Right , Mouse_Middle , Button_Count }
 Enumeration of mouse buttons. More...
 
enum class  Keys {
  Key_Q , Key_W , Key_E , Key_R ,
  Key_T , Key_Y , Key_U , Key_I ,
  Key_O , Key_P , Key_A , Key_S ,
  Key_D , Key_F , Key_G , Key_H ,
  Key_J , Key_K , Key_L , Key_Z ,
  Key_X , Key_C , Key_V , Key_B ,
  Key_N , Key_M , Key_Space , Key_Escape ,
  Key_Enter , Key_Tab , Key_Backspace , Key_Delete ,
  Key_Left , Key_Right , Key_Up , Key_Down ,
  Key_Control , Key_Alt , Key_Shift , Key_1 ,
  Key_2 , Key_3 , Key_4 , Key_5 ,
  Key_6 , Key_7 , Key_8 , Key_9 ,
  Key_0 , Key_Count
}
 Enumeration of keyboard keys. More...
 

Public Member Functions

 Input (GLFWwindow *window)
 Constructs an Input object.
 
 ~Input ()
 Destructor for Input.
 
bool isKeyPressed (Keys key)
 Checks if a key is currently pressed.
 
bool isKeyRelease (Keys key)
 Checks if a key was just released.
 
bool isKeyDown (Keys key) const
 Checks if a key is currently held down.
 
bool isKeyUp (Keys key) const
 Checks if a key is currently up.
 
bool isMouseButtonPressed (Buttons button)
 Checks if a mouse button is currently pressed.
 
bool isMouseButtonRelease (Buttons button)
 Checks if a mouse button was just released.
 
bool isMouseButtonDown (Buttons button) const
 Checks if a mouse button is currently held down.
 
bool isMouseButtonUp (Buttons button) const
 Checks if a mouse button is currently up.
 
glm::vec2 getScrollDelta ()
 Retrieves the scroll delta from the last input frame.
 
void resetScrollTracking ()
 Resets scroll tracking data.
 
void updateKeys ()
 Updates the key states for the current frame.
 
glm::vec2 getMouseDelta ()
 Retrieves the mouse movement delta.
 
glm::vec2 getMousePosition ()
 Retrieves the current mouse position.
 
void resetMouseTracking ()
 Resets mouse movement tracking data.
 

Friends

void key_callback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
void mouse_button_callback (GLFWwindow *window, int button, int action, int mods)
 
void scroll_callback (GLFWwindow *window, double xoffset, double yoffset)
 

Detailed Description

Manages keyboard and mouse input.

Definition at line 17 of file input.hpp.

Member Enumeration Documentation

◆ Buttons

enum class Raftel::Input::Buttons
strong

Enumeration of mouse buttons.

Enumerator
Mouse_Left 

Left mouse button.

Mouse_Right 

Right mouse button.

Mouse_Middle 

Middle mouse button.

Button_Count 

Number of buttons.

Definition at line 22 of file input.hpp.

◆ Keys

enum class Raftel::Input::Keys
strong

Enumeration of keyboard keys.

Enumerator
Key_Count 

Number of keys.

Definition at line 33 of file input.hpp.

Constructor & Destructor Documentation

◆ Input()

Raftel::Input::Input ( GLFWwindow * window)

Constructs an Input object.

Parameters
windowPointer to the GLFW window.

Member Function Documentation

◆ getMouseDelta()

glm::vec2 Raftel::Input::getMouseDelta ( )

Retrieves the mouse movement delta.

Returns
The mouse movement delta as a glm::vec2.

◆ getMousePosition()

glm::vec2 Raftel::Input::getMousePosition ( )

Retrieves the current mouse position.

Returns
The mouse position as a glm::vec2.

◆ getScrollDelta()

glm::vec2 Raftel::Input::getScrollDelta ( )

Retrieves the scroll delta from the last input frame.

Returns
The scroll delta as a glm::vec2.

◆ isKeyDown()

bool Raftel::Input::isKeyDown ( Keys key) const

Checks if a key is currently held down.

Parameters
keyThe key to check.
Returns
True if the key is down, false otherwise.

◆ isKeyPressed()

bool Raftel::Input::isKeyPressed ( Keys key)

Checks if a key is currently pressed.

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

◆ isKeyRelease()

bool Raftel::Input::isKeyRelease ( Keys key)

Checks if a key was just released.

Parameters
keyThe key to check.
Returns
True if the key was released, false otherwise.

◆ isKeyUp()

bool Raftel::Input::isKeyUp ( Keys key) const

Checks if a key is currently up.

Parameters
keyThe key to check.
Returns
True if the key is up, false otherwise.

◆ isMouseButtonDown()

bool Raftel::Input::isMouseButtonDown ( Buttons button) const

Checks if a mouse button is currently held down.

Parameters
buttonThe button to check.
Returns
True if the button is down, false otherwise.

◆ isMouseButtonPressed()

bool Raftel::Input::isMouseButtonPressed ( Buttons button)

Checks if a mouse button is currently pressed.

Parameters
buttonThe button to check.
Returns
True if the button is pressed, false otherwise.

◆ isMouseButtonRelease()

bool Raftel::Input::isMouseButtonRelease ( Buttons button)

Checks if a mouse button was just released.

Parameters
buttonThe button to check.
Returns
True if the button was released, false otherwise.

◆ isMouseButtonUp()

bool Raftel::Input::isMouseButtonUp ( Buttons button) const

Checks if a mouse button is currently up.

Parameters
buttonThe button to check.
Returns
True if the button is up, false otherwise.

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