Practical Tools for Simple Design
Loading...
Searching...
No Matches
Util::Input Class Reference

The Input class provides access to keyboard and mouse input. More...

#include <Input.hpp>

Public Member Functions

 Input (const Input &)=delete
 Input (Input &&)=delete
Inputoperator= (const Input &)=delete

Static Public Member Functions

static glm::vec2 GetScrollDistance ()
 Retrieves the scroll distance of an element.
.
static glm::vec2 GetCursorPosition ()
 Retrieves the current position of the cursor.
static bool IsKeyPressed (const Keycode &key)
 Check if a specific key is currently pressed.
static bool IsKeyDown (const Keycode &key)
 Check if a specific key is being pressed.
static bool IsKeyUp (const Keycode &key)
 Check if a specific key is being un-pressed.
static bool IfScroll ()
 Checks if the mouse wheel is currently being scrolled.
static bool IsMouseMoving ()
 Checks if the mouse is currently moving.
static bool IfExit ()
 Checks if the window is closed.
static void SetCursorPosition (const glm::vec2 &pos)
 Sets the position of the cursor.
static void Update ()
 Updates the state of the input.

Detailed Description

The Input class provides access to keyboard and mouse input.

Note
This class is a singleton and constructable. Use is as follows:
Util::Input::IsKeyPressed(Keycode::A), Util::Input::IsLButtonDown(), etc.

Member Function Documentation

◆ GetCursorPosition()

glm::vec2 Util::Input::GetCursorPosition ( )
static

Retrieves the current position of the cursor.

Note
The cursor position is relative to the upper-left corner of the client area of the window.
Returns
The cursor position as vec2(x, y).
See also
Util::Input::SetCursorPosition()

◆ GetScrollDistance()

glm::vec2 Util::Input::GetScrollDistance ( )
static

Retrieves the scroll distance of an element.
.

The scroll distance is the distance that the mouse wheel has been scrolled. The distance is expressed in multiples or fractions of lines; for example, if the mouse wheel is rotated three lines downward, the scroll distance is {-1.0F, 0.0F}. If the mouse wheel is rotated three lines upward, the scroll distance is {1.0F, 0.0F}. If the mouse wheel is rotated three lines right, the scroll distance is {0.0F, 1.0F}. If the mouse wheel is rotated three lines left, the scroll distance is {0.0F, -1.0F}.

Returns
The scroll distance as vec2(x,y).

◆ IfExit()

bool Util::Input::IfExit ( )
static

Checks if the window is closed.

Returns
true if the window is closed, false otherwise.

◆ IfScroll()

bool Util::Input::IfScroll ( )
static

Checks if the mouse wheel is currently being scrolled.

Returns
A bool value representing the current state of the mouse wheel.

◆ IsKeyDown()

bool Util::Input::IsKeyDown ( const Keycode & key)
static

Check if a specific key is being pressed.

This function checks whether the given key is currently being pressed.

Parameters
keyThe keycode of the key to check.
Returns
true if key is currently pressed, false otherwise.
See also
Util::Keycode

◆ IsKeyPressed()

bool Util::Input::IsKeyPressed ( const Keycode & key)
static

Check if a specific key is currently pressed.

This function checks whether the given key is currently pressed.

Parameters
keyThe keycode of the key to check.
Returns
true if key is currently pressed, false otherwise.
See also
Util::Keycode

◆ IsKeyUp()

bool Util::Input::IsKeyUp ( const Keycode & key)
static

Check if a specific key is being un-pressed.

This function checks whether the given key is currently being un-pressed.

Parameters
keyThe keycode of the key to check.
Returns
true if key is currently pressed, false otherwise.
See also
Util::Keycode

◆ IsMouseMoving()

bool Util::Input::IsMouseMoving ( )
static

Checks if the mouse is currently moving.

Returns
true if the mouse is currently moving, false otherwise.

◆ SetCursorPosition()

void Util::Input::SetCursorPosition ( const glm::vec2 & pos)
static

Sets the position of the cursor.

Parameters
posThe position to set the cursor to.
Note
The cursor position is relative to the upper-left corner of the client area of the window.
It also generates a mouse motion event, which leads Util::Input::IsMouseMoving() to return true in this update-cycle.
See also
Util::Input::GetCursorPosition()

◆ Update()

void Util::Input::Update ( )
static

Updates the state of the input.

Warning
DO NOT CALL THIS METHOD. It is called by context::Update() already.

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