Shkyera Engine
Easy to use, game engine for Python
Loading...
Searching...
No Matches
shkyera::InputManager Class Reference

#include <InputManager.hpp>

Public Types

enum class  CoordinateSystem { ABSOLUTE , SCENE , RUNTIME }
 
using Key = int
 
using MouseButton = int
 

Public Member Functions

void setWindow (GLFWwindow *window)
 
void setCoordinateSystem (CoordinateSystem system, glm::vec2 topLeftCorner, glm::vec2 bottomRightCorner)
 
void update ()
 
bool isKeyDown (Key key) const
 
bool isKeyUp (Key key) const
 
bool isKeyPressed (Key key) const
 
bool isKeyReleased (Key key) const
 
bool isMouseButtonDown (MouseButton button) const
 
bool isMouseButtonUp (MouseButton button) const
 
bool isMouseButtonPressed (MouseButton button) const
 
bool isMouseButtonReleased (MouseButton button) const
 
glm::vec2 getMousePosition (CoordinateSystem coordinateSystem) const
 
glm::vec2 getRelativeMousePosition (CoordinateSystem coordinateSystem) const
 
bool isMouseInside (CoordinateSystem coordinteSystem) const
 

Static Public Member Functions

static InputManagergetInstance ()
 

Private Member Functions

 InputManager ()
 

Private Attributes

GLFWwindow_window = nullptr
 
std::array< bool, MAX_KEYS_currentKeyStates {}
 
std::array< bool, MAX_KEYS_previousKeyStates {}
 
std::array< bool, MAX_MOUSE_BUTTONS_currentMouseStates {}
 
std::array< bool, MAX_MOUSE_BUTTONS_previousMouseStates {}
 
glm::vec2 _mousePos {0.0f, 0.0f}
 
std::unordered_map< CoordinateSystem, std::pair< glm::vec2, glm::vec2 > > _coordinateSystems
 

Static Private Attributes

static constexpr int MAX_KEYS = GLFW_KEY_LAST + 1
 
static constexpr int MAX_MOUSE_BUTTONS = GLFW_MOUSE_BUTTON_LAST + 1
 

Member Typedef Documentation

◆ Key

◆ MouseButton

Member Enumeration Documentation

◆ CoordinateSystem

Enumerator
ABSOLUTE 
SCENE 
RUNTIME 

Constructor & Destructor Documentation

◆ InputManager()

shkyera::InputManager::InputManager ( )
private

Member Function Documentation

◆ getInstance()

InputManager & shkyera::InputManager::getInstance ( )
static

◆ getMousePosition()

glm::vec2 shkyera::InputManager::getMousePosition ( CoordinateSystem  coordinateSystem) const

◆ getRelativeMousePosition()

glm::vec2 shkyera::InputManager::getRelativeMousePosition ( CoordinateSystem  coordinateSystem) const

◆ isKeyDown()

bool shkyera::InputManager::isKeyDown ( Key  key) const

◆ isKeyPressed()

bool shkyera::InputManager::isKeyPressed ( Key  key) const

◆ isKeyReleased()

bool shkyera::InputManager::isKeyReleased ( Key  key) const

◆ isKeyUp()

bool shkyera::InputManager::isKeyUp ( Key  key) const

◆ isMouseButtonDown()

bool shkyera::InputManager::isMouseButtonDown ( MouseButton  button) const

◆ isMouseButtonPressed()

bool shkyera::InputManager::isMouseButtonPressed ( MouseButton  button) const

◆ isMouseButtonReleased()

bool shkyera::InputManager::isMouseButtonReleased ( MouseButton  button) const

◆ isMouseButtonUp()

bool shkyera::InputManager::isMouseButtonUp ( MouseButton  button) const

◆ isMouseInside()

bool shkyera::InputManager::isMouseInside ( CoordinateSystem  coordinteSystem) const

◆ setCoordinateSystem()

void shkyera::InputManager::setCoordinateSystem ( CoordinateSystem  system,
glm::vec2  topLeftCorner,
glm::vec2  bottomRightCorner 
)

◆ setWindow()

void shkyera::InputManager::setWindow ( GLFWwindow window)

◆ update()

void shkyera::InputManager::update ( )

Member Data Documentation

◆ _coordinateSystems

std::unordered_map<CoordinateSystem, std::pair<glm::vec2, glm::vec2> > shkyera::InputManager::_coordinateSystems
private

◆ _currentKeyStates

std::array<bool, MAX_KEYS> shkyera::InputManager::_currentKeyStates {}
private

◆ _currentMouseStates

std::array<bool, MAX_MOUSE_BUTTONS> shkyera::InputManager::_currentMouseStates {}
private

◆ _mousePos

glm::vec2 shkyera::InputManager::_mousePos {0.0f, 0.0f}
private

◆ _previousKeyStates

std::array<bool, MAX_KEYS> shkyera::InputManager::_previousKeyStates {}
private

◆ _previousMouseStates

std::array<bool, MAX_MOUSE_BUTTONS> shkyera::InputManager::_previousMouseStates {}
private

◆ _window

GLFWwindow* shkyera::InputManager::_window = nullptr
private

◆ MAX_KEYS

constexpr int shkyera::InputManager::MAX_KEYS = GLFW_KEY_LAST + 1
staticconstexprprivate

◆ MAX_MOUSE_BUTTONS

constexpr int shkyera::InputManager::MAX_MOUSE_BUTTONS = GLFW_MOUSE_BUTTON_LAST + 1
staticconstexprprivate

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