Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::Input Class Reference

Base input class for querying input states. More...

#include <Input.h>

Public Member Functions

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

Static Public Member Functions

static bool IsKeyPressed (int keycode)
 Checks if the specified key is currently pressed.
static bool IsMouseButtonPressed (int button)
 Checks if the specified mouse button is currently pressed.
static float GetMouseX ()
 Gets the current X position of the mouse cursor.
static float GetMouseY ()
 Gets the current Y position of the mouse cursor.
static glm::vec2 GetMousePosition ()
 Gets the current position of the mouse cursor as a 2D vector.

Protected Member Functions

 Input ()=default

Detailed Description

Base input class for querying input states.

Constructor & Destructor Documentation

◆ Input() [1/2]

Vesper::Input::Input ( )
protecteddefault

◆ Input() [2/2]

Vesper::Input::Input ( const Input & )
delete

Member Function Documentation

◆ GetMousePosition()

glm::vec2 Vesper::Input::GetMousePosition ( )
static

Gets the current position of the mouse cursor as a 2D vector.

24 {
25 auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
26 double xPos, yPos;
27 glfwGetCursorPos(window, &xPos, &yPos);
28 return { (float)xPos, (float)yPos };
29
30 }
static Application & Get()
Retrieves the singleton instance of the Application.
Definition Application.h:67
Window & GetWindow()
Retrieves the application window.
Definition Application.h:70
virtual void * GetNativeWindow() const =0
Retrieves the native window handle.

References Vesper::Application::Get(), Vesper::Window::GetNativeWindow(), and Vesper::Application::GetWindow().

◆ GetMouseX()

float Vesper::Input::GetMouseX ( )
static

Gets the current X position of the mouse cursor.

33 {
34 return GetMousePosition().x;
35 }
static glm::vec2 GetMousePosition()
Gets the current position of the mouse cursor as a 2D vector.
Definition WindowsInput.cpp:23

◆ GetMouseY()

float Vesper::Input::GetMouseY ( )
static

Gets the current Y position of the mouse cursor.

37 {
38 return GetMousePosition().y;
39 }

◆ IsKeyPressed()

bool Vesper::Input::IsKeyPressed ( int keycode)
static

Checks if the specified key is currently pressed.

Parameters
keycodeThe keycode of the key to check.
Returns
True if the key is pressed, false otherwise.
10 {
11 auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
12 auto state = glfwGetKey(window, keycode);
13 return state == GLFW_PRESS || state == GLFW_REPEAT;
14 }

References Vesper::Application::Get(), Vesper::Window::GetNativeWindow(), and Vesper::Application::GetWindow().

Referenced by Vesper::EditorLayer::OnImGuiRender(), Vesper::EditorLayer::OnKeyPressed(), Vesper::EditorCamera::OnUpdate(), and Vesper::OrthographicCameraController::OnUpdate().

◆ IsMouseButtonPressed()

bool Vesper::Input::IsMouseButtonPressed ( int button)
static

Checks if the specified mouse button is currently pressed.

Parameters
buttonThe mouse button to check.
Returns
True if the mouse button is pressed, false otherwise.
17 {
18 auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
19 auto state = glfwGetMouseButton(window, button);
20 return state == GLFW_PRESS;
21 }

References Vesper::Application::Get(), Vesper::Window::GetNativeWindow(), and Vesper::Application::GetWindow().

Referenced by Vesper::EditorCamera::OnUpdate(), and Vesper::EditorLayer::OnUpdate().

◆ operator=()

Input & Vesper::Input::operator= ( const Input & )
delete

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