Claude Chappe' Curse - A C Game
Logo Institut d'Informatique Claude Chappe Logo Université de Le Mans Logo Raeptor Production
 
Loading...
Searching...
No Matches
Input Handling

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.
 

Detailed Description

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.

Macro Definition Documentation

◆ HANDLE_KEY_PRESSED

#define HANDLE_KEY_PRESSED (   _input_id,
  _key 
)
Value:
if (event.key.keysym.sym == _input_id) { \
if (!(input->active_keys & _key)) input->pressed_keys |= _key; \
input->active_keys |= _key; \
}
Input input
Definition raptiquax.c:33
u16 active_keys
Definition input.h:95
u16 pressed_keys
Definition input.h:96

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.

Parameters
keyThe key to be handled.

◆ HANDLE_KEY_RELEASED

#define HANDLE_KEY_RELEASED (   _input_id,
  _key 
)
Value:
if (event.key.keysym.sym == _input_id) { \
if ((input->active_keys & _key)) input->released_keys |= _key; \
input->active_keys &= ~_key; \
}
u16 released_keys
Definition input.h:97

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.

Parameters
keyThe key to be handled.

Enumeration Type Documentation

◆ Keys

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.

Enumerator
KEY_UP 

The up arrow key.

KEY_RIGHT 

The right arrow key.

KEY_DOWN 

The down arrow key.

KEY_LEFT 

The left arrow key.

KEY_JUMP 

The jump key.

KEY_CROUCH 

The crouch key.

KEY_SPRINT 

The sprint key.

KEY_MENU 

The menu key.

KEY_FLASHLIGHT 

The flashlight key.

KEY_VALIDATE 

The enter key.

KEY_INTERACT 

The interact key.

KEY_FULLSCREEN 

The fullscreen key.

KEY_COUNT 

The total number of keys.

Function Documentation

◆ default_input_settings()

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.

◆ init_input()

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.

Parameters
inputPointer to the Input structure to be initialized.

◆ update_input()

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.

Parameters
inputPointer to the Input structure that stores current input states.
Returns
Returns -1 if the escape key is pressed (to indicate an exit), otherwise returns 0.