Class KeyboardMouseInputData

Class Documentation

class inexor::vulkan_renderer::input::KeyboardMouseInputData

A wrapper for keyboard and mouse input data.

Public Functions

KeyboardMouseInputData() = default
KeyboardMouseInputData(const KeyboardMouseInputData&) = delete
KeyboardMouseInputData(KeyboardMouseInputData&&) = delete
~KeyboardMouseInputData() = default
KeyboardMouseInputData &operator=(const KeyboardMouseInputData&) = delete
KeyboardMouseInputData &operator=(KeyboardMouseInputData&&) = delete
void press_key(std::int32_t key)

Change the key’s state to pressed.

Parameters

key – the key which was pressed and greater or equal to 0

void release_key(std::int32_t key)

Change the key’s state to unpressed.

Note

key must be smaller than GLFW_KEY_LAST and greater or equal to 0

Parameters

key – the key which was released

bool is_key_pressed(std::int32_t key) const

Check if the given key is currently pressed.

Note

key must be smaller than GLFW_KEY_LAST and greater or equal to 0

Parameters

key – the key index

Returns

true if the key is pressed

bool was_key_pressed_once(std::int32_t key)

Checks if a key was pressed once.

Note

key must be smaller than GLFW_KEY_LAST and greater or equal to 0

Parameters

key – The key index

Returns

true if the key was pressed

void press_mouse_button(std::int32_t button)

Change the mouse button’s state to pressed.

Note

button must be smaller than GLFW_MOUSE_BUTTON_LAST and greater or equal to 0

Parameters

button – the mouse button which was pressed

void release_mouse_button(std::int32_t button)

Change the mouse button’s state to unpressed.

Note

button must be smaller than GLFW_MOUSE_BUTTON_LAST and greater or equal to 0

Parameters

button – the mouse button which was released

bool is_mouse_button_pressed(std::int32_t button) const

Check if the given mouse button is currently pressed.

Note

button must be smaller than GLFW_MOUSE_BUTTON_LAST and greater or equal to 0

Parameters

button – the mouse button index

Returns

true if the mouse button is pressed

bool was_mouse_button_pressed_once(std::int32_t button)

Checks if a mouse button was pressed once.

Note

button must be smaller than GLFW_MOUSE_BUTTON_LAST and greater or equal to 0

Parameters

button – the mouse button index

Returns

true if the mouse button was pressed

void set_cursor_pos(double pos_x, double pos_y)

Set the current cursor position.

Parameters
  • pos_x – the current x-coordinate of the cursor

  • pos_y – the current y-coordinate of the cursor

std::array<std::int64_t, 2> get_cursor_pos() const
std::array<double, 2> calculate_cursor_position_delta()

Calculate the change in x- and y-position of the cursor.

Returns

a std::array of size 2 which contains the change in x-position in index 0 and the change in y-position in index 1

Private Members

std::array<std::int64_t, 2> m_previous_cursor_pos = {0, 0}
std::array<std::int64_t, 2> m_current_cursor_pos = {0, 0}
std::array<bool, GLFW_KEY_LAST> m_pressed_keys = {false}
std::array<bool, GLFW_MOUSE_BUTTON_LAST> m_pressed_mouse_buttons = {false}
bool m_keyboard_updated = {false}
bool m_mouse_buttons_updated = {false}
mutable std::shared_mutex m_input_mutex