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.
. More...
 
static Util::PTSDPosition GetCursorPosition ()
 Retrieves the current position of the cursor. More...
 
static bool IsKeyPressed (const Keycode &key)
 Check if a specific key is currently pressed. More...
 
static bool IsKeyDown (const Keycode &key)
 Check if a specific key is being pressed. More...
 
static bool IsKeyUp (const Keycode &key)
 Check if a specific key is being un-pressed. More...
 
static bool IfScroll ()
 Checks if the mouse wheel is currently being scrolled. More...
 
static bool IsMouseMoving ()
 Checks if the mouse is currently moving. More...
 
static bool IfExit ()
 Checks if the window is closed. More...
 
static void SetCursorPosition (const Util::PTSDPosition &pos)
 Sets the position of the cursor. More...
 
static void Update ()
 Updates the state of the input. More...
 

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()

static Util::PTSDPosition Util::Input::GetCursorPosition ( )
static

Retrieves the current position of the cursor.

Returns
The cursor position as a PTSDPosition (x, y).
See also
Util::Input::SetCursorPosition()
Util::PTSDPosition

◆ GetScrollDistance()

static 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()

static bool Util::Input::IfExit ( )
static

Checks if the window is closed.

Returns
true if the window is closed, false otherwise.

◆ IfScroll()

static 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()

static 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()

static 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()

static 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()

static bool Util::Input::IsMouseMoving ( )
static

Checks if the mouse is currently moving.

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

◆ SetCursorPosition()

static void Util::Input::SetCursorPosition ( const Util::PTSDPosition pos)
static

Sets the position of the cursor.

Parameters
posThe position to set the cursor to.
Note
This also triggers a mouse motion event, making Util::Input::IsMouseMoving() return true in the current update cycle.
See also
Util::Input::GetCursorPosition()
Util::PTSDPosition

◆ Update()

static 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: