kiba-engine
input.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <kiba/defines.h>
11 
13 typedef enum key_code {
14  KEY_MOUSE_LEFT,
15  KEY_MOUSE_RIGHT,
16  KEY_MOUSE_MIDDLE,
17  KEY_BACKSPACE,
18  KEY_ENTER,
19  KEY_TAB,
20  KEY_SHIFT_L,
21  KEY_SHIFT_R,
22  KEY_CONTROL_L,
23  KEY_CONTROL_R,
24  KEY_ALT_L,
25  KEY_ALT_R,
26  KEY_SUPER_L,
27  KEY_SUPER_R,
28  KEY_PAUSE,
29  KEY_CAPITAL,
30  KEY_ESCAPE,
31  KEY_SPACE,
32  KEY_HOME,
33  KEY_END,
34  KEY_PAGE_UP,
35  KEY_PAGE_DOWN,
36  KEY_LEFT,
37  KEY_UP,
38  KEY_DOWN,
39  KEY_RIGHT,
40  KEY_PRINT,
41  KEY_INSERT,
42  KEY_DELETE,
43  KEY_A,
44  KEY_B,
45  KEY_C,
46  KEY_D,
47  KEY_E,
48  KEY_F,
49  KEY_G,
50  KEY_H,
51  KEY_I,
52  KEY_J,
53  KEY_K,
54  KEY_L,
55  KEY_M,
56  KEY_N,
57  KEY_O,
58  KEY_P,
59  KEY_Q,
60  KEY_R,
61  KEY_S,
62  KEY_T,
63  KEY_U,
64  KEY_V,
65  KEY_W,
66  KEY_X,
67  KEY_Y,
68  KEY_Z,
69  KEY_SEMICOLON,
70  KEY_PLUS,
71  KEY_EQUAL,
72  KEY_COMMA,
73  KEY_MINUS,
74  KEY_PERIOD,
75  KEY_SLASH,
76  KEY_GRAVE,
77  KEY_QUOTE,
78  KEY_BRACKET_L,
79  KEY_BRACKET_R,
80  KEY_BACK_SLASH,
81  KEY_0,
82  KEY_1,
83  KEY_2,
84  KEY_3,
85  KEY_4,
86  KEY_5,
87  KEY_6,
88  KEY_7,
89  KEY_8,
90  KEY_9,
91  KEY_NUMPAD0,
92  KEY_NUMPAD1,
93  KEY_NUMPAD2,
94  KEY_NUMPAD3,
95  KEY_NUMPAD4,
96  KEY_NUMPAD5,
97  KEY_NUMPAD6,
98  KEY_NUMPAD7,
99  KEY_NUMPAD8,
100  KEY_NUMPAD9,
101  KEY_NUMPAD_ENTER,
102  KEY_SEPARATOR,
103  KEY_DECIMAL,
104  KEY_ADD,
105  KEY_MULTIPLY,
106  KEY_SUBTRACT,
107  KEY_DIVIDE,
108  KEY_NUMLOCK,
109  KEY_F1,
110  KEY_F2,
111  KEY_F3,
112  KEY_F4,
113  KEY_F5,
114  KEY_F6,
115  KEY_F7,
116  KEY_F8,
117  KEY_F9,
118  KEY_F10,
119  KEY_F11,
120  KEY_F12,
121  KEY_F13,
122  KEY_F14,
123  KEY_F15,
124  KEY_F16,
125  KEY_F17,
126  KEY_F18,
127  KEY_F19,
128  KEY_F20,
129  KEY_F21,
130  KEY_F22,
131  KEY_F23,
132  KEY_F24,
133 
134  KEY_CODE_MAX
136 
146 b8 input_initialize(void);
147 
151 void input_shutdown(void);
152 
161 void input_update(f64 delta_time);
162 
169 KB_API b8 input_is_key_down(key_code key);
170 
177 KB_API b8 input_was_key_down(key_code key);
178 
185 KB_API b8 input_is_key_up(key_code key);
186 
193 KB_API b8 input_was_key_up(key_code key);
194 
203 KB_API b8 input_is_key_held(key_code key);
204 
211 KB_API void input_mouse_position(u32 *x, u32 *y);
212 
220 KB_API b8 input_mouse_moved(u32 *x, u32 *y);
221 
227 KB_API i8 input_mouse_wheel(void);
228 
236 void input_process_key(key_code key, b8 pressed);
237 
245 void input_process_mouse_position(u32 x, u32 y);
246 
253 void input_process_mouse_wheel(i8 wheel_pos);
Global typedefs and macros.
KB_API b8 input_is_key_up(key_code key)
Check if a key is currently up.
Definition: input.c:67
KB_API b8 input_is_key_down(key_code key)
Check if a key is currently down.
Definition: input.c:57
KB_API i8 input_mouse_wheel(void)
Get current mouse wheel scrolling direction.
Definition: input.c:93
KB_API b8 input_was_key_down(key_code key)
Check if a key was down before the last update.
Definition: input.c:62
key_code
All available keycodes.
Definition: input.h:13
KB_API b8 input_is_key_held(key_code key)
Check if a key is held.
Definition: input.c:77
void input_shutdown(void)
Shutdown input system.
Definition: input.c:49
KB_API b8 input_was_key_up(key_code key)
Check if a key was up before the last update.
Definition: input.c:72
void input_process_mouse_position(u32 x, u32 y)
Set current state for the mouse position.
Definition: input.c:100
void input_process_mouse_wheel(i8 wheel_pos)
Set current scrolling wheel direction for the mouse.
Definition: input.c:105
void input_update(f64 delta_time)
Updates the input system.
Definition: input.c:51
KB_API void input_mouse_position(u32 *x, u32 *y)
Get current mouse position.
Definition: input.c:82
void input_process_key(key_code key, b8 pressed)
Set current state for a key.
Definition: input.c:95
KB_API b8 input_mouse_moved(u32 *x, u32 *y)
Check if mouse moved.
Definition: input.c:87
b8 input_initialize(void)
Initialize the input system.
Definition: input.c:43