- `s_`: server side code
- `u_`: system utility code
- `p_`: platform module directory
+- `i_`: input handling
- `t_`: test case
+## Goto
+
+Goto is allowed for error handling or breaking out of nested loops.
+e.g. `goto error` or `goto loop_done`.
+
## Library functions
Third party functions (even the C stdlib) should be wrapped at all times.
--- /dev/null
+#ifndef I_INPUT_H__
+#define I_INPUT_H__
+
+/**
+ * This module is used for user input
+ * state management.
+ * The structs in this module should not be used
+ * directly to interact with gemplay. They should instead
+ * be translated to action commands.
+ */
+
+#define I_CURSOR_BUTTONS 3
+#define I_KEYBOARD_KEYS 128
+
+enum i_button_state {
+ I_BUTTON_RELEASE = 0,
+ I_BUTTON_JUST_PRESSED = 1,
+ I_BUTTON_HELD = 2
+};
+
+
+/* describes the current cursor state */
+struct i_cursor {
+ struct u_vec2 pos;
+
+ enum i_button_state buttons[I_CURSOR_BUTTONS];
+};
+
+struct i_keyboard {
+ enum i_button_state shift;
+ enum i_button_state ctrl;
+ enum i_button_state alt;
+ enum i_button_state super;
+ enum i_button_state enter;
+ enum i_button_state space;
+ enum i_button_state backspace;
+
+ /* ascii table for all other keys */
+ enum i_button_state keys[I_KEYBOARD_KEYS];
+};
+
+/* primary IO devices */
+extern struct i_cursor i_cursor;
+extern struct i_keyboard i_keyboard;
+
+void i_input_init(void);
+
+#endif
#include "p_platform.h"
#include "r_render.h"
#include "r_assets.h"
+#include "i_input.h"
struct lrts_config lrts_global_cfg;
void lrts_init(void) {
/* init the fallback tile mask */
r_asset_init_fallback_tile();
+ i_input_init();
}
int lrts_main(int argc, char **argv) {