kiba-engine
Data Structures | Typedefs | Functions
input.c File Reference

Input layer implementation. More...

#include <kiba/core/input.h>
#include <kiba/core/log.h>
#include <kiba/core/memory.h>
Include dependency graph for input.c:

Go to the source code of this file.

Data Structures

struct  input_state
 State of the input system. More...
 

Typedefs

typedef struct input_state input_state
 State of the input system. More...
 

Functions

b8 input_initialize (void)
 Initialize the input system. More...
 
void input_shutdown (void)
 Shutdown input system.
 
void input_update (f64 delta_time)
 Updates the input system. More...
 
b8 input_is_key_down (key_code key)
 Check if a key is currently down. More...
 
b8 input_was_key_down (key_code key)
 Check if a key was down before the last update. More...
 
b8 input_is_key_up (key_code key)
 Check if a key is currently up. More...
 
b8 input_was_key_up (key_code key)
 Check if a key was up before the last update. More...
 
b8 input_is_key_held (key_code key)
 Check if a key is held. More...
 
void input_mouse_position (u32 *x, u32 *y)
 Get current mouse position. More...
 
b8 input_mouse_moved (u32 *x, u32 *y)
 Check if mouse moved. More...
 
i8 input_mouse_wheel (void)
 Get current mouse wheel scrolling direction. More...
 
void input_process_key (key_code key, b8 pressed)
 Set current state for a key. More...
 
void input_process_mouse_position (u32 x, u32 y)
 Set current state for the mouse position. More...
 
void input_process_mouse_wheel (i8 wheel_pos)
 Set current scrolling wheel direction for the mouse. More...
 

Detailed Description

Input layer implementation.

Definition in file input.c.

Typedef Documentation

◆ input_state

typedef struct input_state input_state

State of the input system.

Function Documentation

◆ input_initialize()

b8 input_initialize ( void  )

Initialize the input system.

Prepares the internal state to process and serve input information. Must be called once before using the input system.

Returns
false if an error occurred, true if succesful

Definition at line 43 of file input.c.

Here is the call graph for this function:

◆ input_is_key_down()

b8 input_is_key_down ( key_code  key)

Check if a key is currently down.

Parameters
keythe key_code of the key to check
Returns
true if the key is currently down, false otherwise

Definition at line 57 of file input.c.

◆ input_is_key_held()

b8 input_is_key_held ( key_code  key)

Check if a key is held.

A key is being held when it was down and is currently still down.

Parameters
keythe key_code of the key to check
Returns
true if the key is held, false otherwise

Definition at line 77 of file input.c.

◆ input_is_key_up()

b8 input_is_key_up ( key_code  key)

Check if a key is currently up.

Parameters
keythe key_code of the key to check
Returns
true if the key is currently up, false otherwise

Definition at line 67 of file input.c.

◆ input_mouse_moved()

b8 input_mouse_moved ( u32 *  x,
u32 *  y 
)

Check if mouse moved.

Parameters
xpoints to x delta of the mouse since last update, will be populated by the function
ypoints to y delta of the mouse since last update, will be populated by the function
Returns
false if mouse did not move since last update, true if it moved

Definition at line 87 of file input.c.

◆ input_mouse_position()

void input_mouse_position ( u32 *  x,
u32 *  y 
)

Get current mouse position.

Parameters
xpoints to x coordinate of the mouse, will be populated by the function
ypoints to y coordinate of the mouse, will be populated by the function

Definition at line 82 of file input.c.

◆ input_mouse_wheel()

i8 input_mouse_wheel ( void  )

Get current mouse wheel scrolling direction.

Returns
1 if scrolling down, -1 if scrolling up, 0 if no input

Definition at line 93 of file input.c.

◆ input_process_key()

void input_process_key ( key_code  key,
b8  pressed 
)

Set current state for a key.

Parameters
keythe key_code of the key to update
pressedthe current state of the key

Definition at line 95 of file input.c.

◆ input_process_mouse_position()

void input_process_mouse_position ( u32  x,
u32  y 
)

Set current state for the mouse position.

Parameters
xthe current x coordinate of the mouse
ythe current y coordinate of the mouse

Definition at line 100 of file input.c.

◆ input_process_mouse_wheel()

void input_process_mouse_wheel ( i8  wheel_pos)

Set current scrolling wheel direction for the mouse.

Parameters
wheel_posthe current direction of the mouse wheel

Definition at line 105 of file input.c.

◆ input_update()

void input_update ( f64  delta_time)

Updates the input system.

This should be called every frame before prolling window events.

Parameters
delta_timethe time that passed since the last update

Definition at line 51 of file input.c.

Here is the call graph for this function:

◆ input_was_key_down()

b8 input_was_key_down ( key_code  key)

Check if a key was down before the last update.

Parameters
keythe key_code of the key to check
Returns
true if the key was down, false otherwise

Definition at line 62 of file input.c.

◆ input_was_key_up()

b8 input_was_key_up ( key_code  key)

Check if a key was up before the last update.

Parameters
keythe key_code of the key to check
Returns
true if the key was up, false otherwise

Definition at line 72 of file input.c.