Kohi Game Engine
input.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include "defines.h"
16 #include "input_types.h"
17 
18 struct keymap;
19 struct frame_data;
20 
30 b8 input_system_initialize(u64* memory_requirement, void* state, void* config);
31 
36 void input_system_shutdown(void* state);
37 
43 void input_update(const struct frame_data* p_frame_data);
44 
45 // keyboard input
46 
52 
59 
66 
73 
80 
86 void input_process_key(keys key, b8 pressed);
87 
88 // mouse input
89 
96 
103 
110 
117 
126 
133 
140 
146 void input_process_button(mouse_buttons button, b8 pressed);
147 
153 
159 
166 KAPI const char* input_keycode_str(keys key);
167 
174 KAPI void input_keymap_push(const struct keymap* map);
175 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:205
signed char i8
Signed 8-bit integer.
Definition: defines.h:33
_Bool b8
8-bit boolean type
Definition: defines.h:58
signed int i32
Signed 32-bit integer.
Definition: defines.h:39
signed short i16
Signed 16-bit integer.
Definition: defines.h:36
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
KAPI b8 input_was_key_down(keys key)
Indicates if the given key was previously pressed down on the last frame.
KAPI b8 input_was_key_up(keys key)
Indicates if the given key was previously pressed down in the last frame.
KAPI void input_keymap_push(const struct keymap *map)
Pushes a new keymap onto the keymap stack, making it the active keymap. A copy of the keymap is taken...
KAPI b8 input_is_button_down(mouse_buttons button)
Indicates if the given mouse button is currently pressed.
KAPI void input_get_previous_mouse_position(i32 *x, i32 *y)
Obtains the previous mouse position.
void input_process_mouse_move(i16 x, i16 y)
Sets the current position of the mouse to the given x and y positions. Also updates the previous posi...
void input_system_shutdown(void *state)
Shuts the input system down.
KAPI b8 input_is_key_down(keys key)
Indicates if the given key is currently pressed down.
KAPI b8 input_was_button_down(mouse_buttons button)
Indicates if the given mouse button was previously pressed in the last frame.
KAPI b8 input_keymap_pop(void)
Attempts to pop the top-most keymap from the stack, if there is one.
void input_process_button(mouse_buttons button, b8 pressed)
Sets the press state of the given mouse button.
KAPI b8 input_is_button_up(mouse_buttons button)
Indicates if the given mouse button is currently released.
KAPI void input_key_repeats_enable(b8 enable)
Enables/disables keyboard key repeats.
KAPI b8 input_is_key_up(keys key)
Indicates if the given key is NOT currently pressed down.
void input_process_key(keys key, b8 pressed)
Sets the state for the given key.
void input_update(const struct frame_data *p_frame_data)
Updates the input system every frame.
KAPI const char * input_keycode_str(keys key)
Returns a string representation of the provided key. Ex. "tab" for the tab key.
KAPI b8 input_is_button_dragging(mouse_buttons button)
Indicates if the mouse is currently being dragged with the provided button being held down.
KAPI b8 input_was_button_up(mouse_buttons button)
Indicates if the given mouse button was previously released in the last frame.
b8 input_system_initialize(u64 *memory_requirement, void *state, void *config)
Initializes the input system. Call twice; once to obtain memory requirement (passing state = 0),...
void input_process_mouse_wheel(i8 z_delta)
Processes mouse wheel scrolling.
KAPI void input_get_mouse_position(i32 *x, i32 *y)
Obtains the current mouse position.
keys
Represents available keyboard keys.
Definition: input_types.h:21
mouse_buttons
Represents available mouse buttons.
Definition: input_types.h:8
Engine-level current frame-specific data.
Definition: frame_data.h:11
A keymap, which holds a list of keymap entries, each with a list of bindings. These are held in an in...
Definition: keymap.h:103