|
Brenta Engine 1.2
|
Input subsystem. More...
#include <input.hpp>
Data Structures | |
| class | builder |
Public Member Functions | |
| std::expected< void, subsystem::error > | initialize () override |
| Initialize the input system. | |
| std::expected< void, subsystem::error > | terminate () override |
| Cleans up resources. | |
| std::string | name () override |
| Returns the name of the sybsystem. | |
| bool | is_initialized () override |
| Returns true if the subsystem is initialized. | |
Public Member Functions inherited from brenta::subsystem | |
Static Public Member Functions | |
| static input & | instance () |
| static void | add_keyboard_callback (int key, std::function< void()> callback) |
| Add a keyboard callback. | |
| static void | remove_keyboard_callback (int key) |
| Remove a keyboard callback. | |
| static void | key_callback (GLFWwindow *window, int key, int scancode, int action, int mods) |
| Keyboard callback. | |
| static void | add_mouse_pos_callback (types::mouse_callback_name_t name, std::function< void(double, double)> callback) |
| Add a mouse position callback. | |
| static void | remove_mouse_pos_callback (types::mouse_callback_name_t callback_name) |
| Remove a mouse position callback. | |
| static void | mouse_pos_callback (GLFWwindow *window, double xpos, double ypos) |
| Mouse position callback. | |
Static Public Attributes | |
| static const std::string | subsystem_name = "input" |
Additional Inherited Members | |
Public Types inherited from brenta::subsystem | |
| using | error = std::string |
Input subsystem.
This subsystem is used to add and remove callbacks for keyboard and mouse events. You can define your own callbacks and register them with the input subsystem.
|
static |
Add a keyboard callback.
This function adds a callback to a key press event. The callback is a function that takes no arguments and returns void. The key enum is defined in GLFW. When the key is pressed, the callback is called.
| key | The key to add the callback to |
| callback | The callback function |
|
static |
Add a mouse position callback.
This function adds a callback to a mouse position event. The callback is a function that takes two doubles and returns void. The two doubles are the x and y position of the mouse. When the mouse is moved, the callback is called.
| name | The name of the callback |
| callback | The callback function |
|
overridevirtual |
Initialize the input system.
This function initializes the input subsystem. It should be called before any other input function is called.
Implements brenta::subsystem.
|
overridevirtual |
Returns true if the subsystem is initialized.
Implements brenta::subsystem.
|
static |
Keyboard callback.
This function is called when a key is pressed. It calls the callback function associated with the key.
| window | The window that received the event |
| key | The key that was pressed or released |
| scancode | The system-specific scancode of the key |
| action | The GLFW key action (GLFW_PRESS...) |
| mods | Bit field describing which modifier keys were held down |
|
static |
Mouse position callback.
This function is called when the mouse is moved. It calls the callback function associated with the mouse position.
| window | The window that received the event |
| xpos | The new x-coordinate, in screen coordinates, of the cursor |
| ypos | The new y-coordinate, in screen coordinates, of the cursor |
|
overridevirtual |
Returns the name of the sybsystem.
Implements brenta::subsystem.
|
static |
|
static |
|
overridevirtual |