Functions and structures for handling user input. More...
Classes | |
struct | Mouse |
Structure to store mouse state. More... | |
struct | Input |
Structure to store input state. More... | |
Macros | |
#define | HANDLE_KEY_PRESSED(_input_id, _key) |
Macro to handle key press events. | |
#define | HANDLE_KEY_RELEASED(_input_id, _key) |
Macro to handle key release events. | |
Enumerations | |
enum | Keys { KEY_UP = 1 << 0 , KEY_RIGHT = 1 << 1 , KEY_DOWN = 1 << 2 , KEY_LEFT = 1 << 3 , KEY_JUMP = 1 << 4 , KEY_CROUCH = 1 << 5 , KEY_SPRINT = 1 << 6 , KEY_MENU = 1 << 7 , KEY_FLASHLIGHT = 1 << 8 , KEY_VALIDATE = 1 << 9 , KEY_INTERACT = 1 << 10 , KEY_FULLSCREEN = 1 << 11 , KEY_COUNT } |
Enumeration of possible keys. More... | |
Functions | |
void | default_input_settings () |
Sets the default input settings for the application. | |
void | init_input (Input *input) |
Initializes the input structure. | |
int | update_input (Input *input) |
Updates the input state. | |
Functions and structures for handling user input.
This module provides macros, enums, and structures for managing user input, including keyboard and mouse events. It allows for tracking key presses, releases, and active states, as well as mouse movements and button states.
#define HANDLE_KEY_PRESSED | ( | _input_id, | |
_key | |||
) |
Macro to handle key press events.
This macro checks if a key is not currently active and, if so, marks it as pressed and active in the input structure.
key | The key to be handled. |
#define HANDLE_KEY_RELEASED | ( | _input_id, | |
_key | |||
) |
Macro to handle key release events.
This macro checks if a key is currently active and, if so, marks it as released and removes it from the active keys in the input structure.
key | The key to be handled. |
enum Keys |
Enumeration of possible keys.
This enum defines bitwise values for various keys that can be pressed or released. Each key is represented by a unique bit in a 16-bit integer.
void default_input_settings | ( | ) |
Sets the default input settings for the application.
This function initializes and sets the default input settings, ensuring that the application has a consistent and expected input configuration. It should be called during the initialization phase of the application.
void init_input | ( | Input * | input | ) |
Initializes the input structure.
This function sets the initial state of the input structure, clearing all key states and initializing the mouse state.
input | Pointer to the Input structure to be initialized. |
int update_input | ( | Input * | input | ) |
Updates the input state.
This function processes keyboard and mouse events to update the input structure. It handles key presses and releases, mouse movements, and button states.
input | Pointer to the Input structure that stores current input states. |