Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Input::Utils Namespace Reference

Typedefs

using JoystickAxes = std::vector<float>
using JoystickButtons = std::vector<unsigned char>

Functions

bool IsKeyPressed (int key) noexcept
 Check if a key is pressed.
bool IsMouseButtonPressed (int button) noexcept
 Check if a mouse button is pressed.
glm::vec2 GetMousePosition () noexcept
 Get the current mouse position.
void PrintAvailableControllers () noexcept
 Prints the available controllers that glfw can handle.
bool IsJoystickPresent (int jid) noexcept
 Check if a joystick is present.
std::string GetJoystickName (int jid) noexcept
 Get the name of a joystick.
JoystickAxes GetJoystickAxes (int jid)
 Get the joystick axis values.
JoystickButtons GetJoystickButtons (int jid)
 Get the joystick button states.

Typedef Documentation

◆ JoystickAxes

using Input::Utils::JoystickAxes = std::vector<float>

◆ JoystickButtons

using Input::Utils::JoystickButtons = std::vector<unsigned char>

Function Documentation

◆ GetJoystickAxes()

Input::Utils::JoystickAxes Input::Utils::GetJoystickAxes ( int jid)

Get the joystick axis values.

Parameters
jidThe joystick ID (GLFW_JOYSTICK_1, GLFW_JOYSTICK_2, etc.)
Returns
A vector of axis values.
Exceptions
InputErrorif the joystick is not present or if there is an error retrieving the axes.

◆ GetJoystickButtons()

Input::Utils::JoystickButtons Input::Utils::GetJoystickButtons ( int jid)

Get the joystick button states.

Parameters
jidThe joystick ID (GLFW_JOYSTICK_1, GLFW_JOYSTICK_2, etc.)
Returns
A vector of button states.
Exceptions
InputErrorif the joystick is not present or if there is an error retrieving the buttons.

◆ GetJoystickName()

std::string Input::Utils::GetJoystickName ( int jid)
inlinenoexcept

Get the name of a joystick.

Parameters
jidThe joystick ID (GLFW_JOYSTICK_1, GLFW_JOYSTICK_2, etc.)
Returns
The name of the joystick.

◆ GetMousePosition()

glm::vec2 Input::Utils::GetMousePosition ( )
inlinenoexcept

Get the current mouse position.

Returns
A pair containing the x and y coordinates of the mouse.

◆ IsJoystickPresent()

bool Input::Utils::IsJoystickPresent ( int jid)
inlinenoexcept

Check if a joystick is present.

Parameters
jidThe joystick ID (GLFW_JOYSTICK_1, GLFW_JOYSTICK_2, etc.)
Returns
True if the joystick is present, false otherwise.

◆ IsKeyPressed()

bool Input::Utils::IsKeyPressed ( int key)
inlinenoexcept

Check if a key is pressed.

Parameters
keyThe key to check. (Use GLFW_KEY_* constants)
Returns
True if the key is pressed, false otherwise.

◆ IsMouseButtonPressed()

bool Input::Utils::IsMouseButtonPressed ( int button)
inlinenoexcept

Check if a mouse button is pressed.

Parameters
buttonThe mouse button to check. (Use GLFW_MOUSE_BUTTON_* constants)
Returns
True if the mouse button is pressed, false otherwise.

◆ PrintAvailableControllers()

void Input::Utils::PrintAvailableControllers ( )
noexcept

Prints the available controllers that glfw can handle.