Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
Public Member Functions | List of all members
InputManager Class Reference

#include <input_manager.h>

Public Member Functions

 InputManager ()=default
 
 InputManager (SDL_Window *window)
 
 ~InputManager ()
 
void process_event (const SDL_Event &event)
 
void update ()
 
void late_update ()
 
bool is_key_pressed (SDL_Scancode key) const
 
bool is_key_held (SDL_Scancode key) const
 
bool is_key_released (SDL_Scancode key) const
 
InputState get_key_state (SDL_Scancode key) const
 
bool are_keys_held (const std::vector< SDL_Scancode > &keys) const
 
bool any_key_pressed (const std::vector< SDL_Scancode > &keys) const
 
glm::vec2 get_mouse_position () const
 
glm::vec2 get_mouse_delta () const
 
glm::vec2 get_mouse_wheel () const
 
bool is_mouse_button_pressed (MouseButton button) const
 
bool is_mouse_button_held (MouseButton button) const
 
bool is_mouse_button_released (MouseButton button) const
 
InputState get_mouse_button_state (MouseButton button) const
 
void set_mouse_position (int x, int y)
 
void set_relative_mouse_mode (bool enabled)
 
bool is_relative_mouse_mode () const
 
glm::vec2 screen_to_world (const glm::vec2 &screen_pos) const
 
glm::vec2 world_to_screen (const glm::vec2 &world_pos) const
 
size_t get_gamepad_count () const
 
const GamepadInfoget_gamepad (int index) const
 
bool is_gamepad_connected (int index) const
 
bool is_gamepad_button_pressed (int gamepad_index, int button) const
 
bool is_gamepad_button_held (int gamepad_index, int button) const
 
bool is_gamepad_button_released (int gamepad_index, int button) const
 
float get_gamepad_axis (int gamepad_index, int axis) const
 
glm::vec2 get_gamepad_stick (int gamepad_index, int stick_index) const
 
void set_gamepad_deadzone (int gamepad_index, float deadzone)
 
const std::unordered_map< SDL_FingerID, TouchPoint > & get_touch_points () const
 
bool is_touch_active (SDL_FingerID finger_id) const
 
glm::vec2 get_touch_position (SDL_FingerID finger_id) const
 
size_t get_active_touch_count () const
 
TextInputManagerget_text_input ()
 
void start_text_input ()
 
void stop_text_input ()
 
void register_action (const InputAction &action)
 
void unregister_action (const std::string &action_name)
 
bool is_action_pressed (const std::string &action_name) const
 
bool is_action_held (const std::string &action_name) const
 
bool is_action_released (const std::string &action_name) const
 
bool position_in_rect (glm::vec2 position, const Rect2 &rect) const
 
bool mouse_in_rect (const Rect2 &rect) const
 
void set_input_blocked (bool blocked)
 
bool is_input_blocked () const
 
void print_debug_info () const
 
std::vector< SDL_Scancode > get_pressed_keys () const
 
void set_mouse_sensitivity (float sensitivity)
 
float get_mouse_sensitivity () const
 

Constructor & Destructor Documentation

◆ InputManager() [1/2]

InputManager::InputManager ( )
default

◆ InputManager() [2/2]

InputManager::InputManager ( SDL_Window *  window)
explicit

◆ ~InputManager()

InputManager::~InputManager ( )

Member Function Documentation

◆ any_key_pressed()

bool InputManager::any_key_pressed ( const std::vector< SDL_Scancode > &  keys) const

◆ are_keys_held()

bool InputManager::are_keys_held ( const std::vector< SDL_Scancode > &  keys) const

◆ get_active_touch_count()

size_t InputManager::get_active_touch_count ( ) const

◆ get_gamepad()

const GamepadInfo * InputManager::get_gamepad ( int  index) const

◆ get_gamepad_axis()

float InputManager::get_gamepad_axis ( int  gamepad_index,
int  axis 
) const

◆ get_gamepad_count()

size_t InputManager::get_gamepad_count ( ) const
inline

◆ get_gamepad_stick()

glm::vec2 InputManager::get_gamepad_stick ( int  gamepad_index,
int  stick_index 
) const

◆ get_key_state()

InputState InputManager::get_key_state ( SDL_Scancode  key) const

◆ get_mouse_button_state()

InputState InputManager::get_mouse_button_state ( MouseButton  button) const

◆ get_mouse_delta()

glm::vec2 InputManager::get_mouse_delta ( ) const
inline

◆ get_mouse_position()

glm::vec2 InputManager::get_mouse_position ( ) const
inline

◆ get_mouse_sensitivity()

float InputManager::get_mouse_sensitivity ( ) const
inline

◆ get_mouse_wheel()

glm::vec2 InputManager::get_mouse_wheel ( ) const
inline

◆ get_pressed_keys()

std::vector< SDL_Scancode > InputManager::get_pressed_keys ( ) const

◆ get_text_input()

TextInputManager& InputManager::get_text_input ( )
inline

◆ get_touch_points()

const std::unordered_map<SDL_FingerID, TouchPoint>& InputManager::get_touch_points ( ) const
inline

◆ get_touch_position()

glm::vec2 InputManager::get_touch_position ( SDL_FingerID  finger_id) const

◆ is_action_held()

bool InputManager::is_action_held ( const std::string &  action_name) const

◆ is_action_pressed()

bool InputManager::is_action_pressed ( const std::string &  action_name) const

◆ is_action_released()

bool InputManager::is_action_released ( const std::string &  action_name) const

◆ is_gamepad_button_held()

bool InputManager::is_gamepad_button_held ( int  gamepad_index,
int  button 
) const

◆ is_gamepad_button_pressed()

bool InputManager::is_gamepad_button_pressed ( int  gamepad_index,
int  button 
) const

◆ is_gamepad_button_released()

bool InputManager::is_gamepad_button_released ( int  gamepad_index,
int  button 
) const

◆ is_gamepad_connected()

bool InputManager::is_gamepad_connected ( int  index) const

◆ is_input_blocked()

bool InputManager::is_input_blocked ( ) const
inline

◆ is_key_held()

bool InputManager::is_key_held ( SDL_Scancode  key) const

◆ is_key_pressed()

bool InputManager::is_key_pressed ( SDL_Scancode  key) const

◆ is_key_released()

bool InputManager::is_key_released ( SDL_Scancode  key) const

◆ is_mouse_button_held()

bool InputManager::is_mouse_button_held ( MouseButton  button) const

◆ is_mouse_button_pressed()

bool InputManager::is_mouse_button_pressed ( MouseButton  button) const

◆ is_mouse_button_released()

bool InputManager::is_mouse_button_released ( MouseButton  button) const

◆ is_relative_mouse_mode()

bool InputManager::is_relative_mouse_mode ( ) const

◆ is_touch_active()

bool InputManager::is_touch_active ( SDL_FingerID  finger_id) const

◆ late_update()

void InputManager::late_update ( )

◆ mouse_in_rect()

bool InputManager::mouse_in_rect ( const Rect2 rect) const

◆ position_in_rect()

bool InputManager::position_in_rect ( glm::vec2  position,
const Rect2 rect 
) const

◆ print_debug_info()

void InputManager::print_debug_info ( ) const

◆ process_event()

void InputManager::process_event ( const SDL_Event &  event)

◆ register_action()

void InputManager::register_action ( const InputAction action)

◆ screen_to_world()

glm::vec2 InputManager::screen_to_world ( const glm::vec2 &  screen_pos) const

◆ set_gamepad_deadzone()

void InputManager::set_gamepad_deadzone ( int  gamepad_index,
float  deadzone 
)

◆ set_input_blocked()

void InputManager::set_input_blocked ( bool  blocked)
inline

◆ set_mouse_position()

void InputManager::set_mouse_position ( int  x,
int  y 
)

◆ set_mouse_sensitivity()

void InputManager::set_mouse_sensitivity ( float  sensitivity)
inline

◆ set_relative_mouse_mode()

void InputManager::set_relative_mouse_mode ( bool  enabled)

◆ start_text_input()

void InputManager::start_text_input ( )
inline

◆ stop_text_input()

void InputManager::stop_text_input ( )
inline

◆ unregister_action()

void InputManager::unregister_action ( const std::string &  action_name)

◆ update()

void InputManager::update ( )

◆ world_to_screen()

glm::vec2 InputManager::world_to_screen ( const glm::vec2 &  world_pos) const

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