summaryrefslogtreecommitdiff
path: root/src/input.c
blob: ab7768c9d824b1f08cca67f53d59c1c6b4a770c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "input.h"
#include <SDL3/SDL_events.h>

struct LEO_InputManager {
	bool quit;
};

static struct LEO_InputManager *LEO_InputManager_singleton()
{
	static struct LEO_InputManager manager;
	static bool initialized = false;

	if (!initialized) {
		manager.quit = false;
		initialized = true;
	}

	return &manager;
}

void LEO_Input_update(const SDL_Event event)
{
	struct LEO_InputManager *manager = LEO_InputManager_singleton();

	switch (event.type) {
	case SDL_EVENT_QUIT:
		manager->quit = true;
	}
}

bool LEO_Input_quit()
{
	struct LEO_InputManager *manager = LEO_InputManager_singleton();
	return manager->quit;
}