Vivid
Loading...
Searching...
No Matches
InputHandler Namespace Reference

A namespace that contains functions to handle input. More...

Functions

bool IsKeyPressed (int key)
 Checks if a key is pressed or not.
 
Vivid::Maths::Vec2 GetMousePosition ()
 Gets the mouse position.
 
Vivid::Maths::Vec2 GetMousePositionOnViewport ()
 Gets the mouse position on the viewport.
 
bool IsMouseButtonPressed (int button)
 Checks if a mouse button is pressed or not.
 

Detailed Description

A namespace that contains functions to handle input.

This namespace contains functions to check if a key is pressed or not, get the mouse position, get the mouse position on the viewport, and check if a mouse button is pressed or not.

Function Documentation

◆ GetMousePosition()

Vivid::Maths::Vec2 InputHandler::GetMousePosition ( )

Gets the mouse position.

Gets an Application singelton and then gets the GLFW window from it and gets the mouse position.

Returns
Vivid::Maths::Vec2 The mouse position.

Definition at line 13 of file InputHandler.cpp.

◆ GetMousePositionOnViewport()

Vivid::Maths::Vec2 InputHandler::GetMousePositionOnViewport ( )

Gets the mouse position on the viewport.

Gets the mouse position and then subtracts the viewport position from it and then returns the mouse position.

Returns
Vivid::Maths::Vec2 The mouse position on the viewport. Right is positive x, up is positive y.

Definition at line 30 of file InputHandler.cpp.

◆ IsKeyPressed()

bool InputHandler::IsKeyPressed ( int  key)

Checks if a key is pressed or not.

Gets an Application singelton and then gets the GLFW window from it and checks if the key is pressed or not.

Parameters
keyThe key to check if it is pressed or not. key is a GLFW key code.
Returns
bool True if key is pressed, false otherwise.

Definition at line 5 of file InputHandler.cpp.

◆ IsMouseButtonPressed()

bool InputHandler::IsMouseButtonPressed ( int  button)

Checks if a mouse button is pressed or not.

Gets an Application singelton and then gets the GLFW window from it and checks if the mouse button is pressed or not.

Parameters
buttonThe mouse button to check if it is pressed or not. button is a GLFW mouse button code.
Returns
bool True if mouse button is pressed, false otherwise.

Definition at line 22 of file InputHandler.cpp.