twn_input: singleton rework, twn_control.h and fixes

This commit is contained in:
2024-10-08 10:12:30 +03:00
parent aef3f6444e
commit 0ede612bec
17 changed files with 677 additions and 647 deletions

View File

@ -8,12 +8,20 @@
#include <stdint.h>
/* context that is valid for current frame */
/* changes to it should not have an effect, unless specified */
/* TODO: ensure the statement above */
typedef struct Context {
InputState input;
/* you may read from and write to these from game code */
void *udata;
/* TODO: is it what we actually want? */
int64_t delta_time; /* preserves real time frame delta with no manipilation */
uint64_t tick_count;
Vec2i mouse_window_position;
Vec2i mouse_relative_position;
/* set just once on startup */
uint64_t random_seed;
@ -21,14 +29,13 @@ typedef struct Context {
/* use it to simulate low framerate (e.g. at 60 tps, set to 2 for 30 fps) */
/* it can be changed at runtime; any resulting logic anomalies are bugs */
unsigned int update_multiplicity;
/* TODO: use Vec2i? */
int window_w;
int window_h;
int base_draw_w;
int base_draw_h;
/* you may read from and write to these from game code */
void *udata;
bool debug;
bool is_running;
bool window_size_has_changed;