Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Experimento con emscripten y SDL

1178 views
1
#ifndef INPUT_PROCESSOR_H
2
#define INPUT_PROCESSOR_H
3
4
#include <SDL2/SDL.h>
5
#include <SDL2/SDL_opengl.h>
6
#include <SDL2/SDL_image.h>
7
#include <stdbool.h>
8
9
typedef enum game_state
10
{
11
GS_ONE,
12
GS_TWO,
13
GS_N,
14
GS_E,
15
GS_S,
16
GS_W,
17
GS_QUIT,
18
GS_NUM_STATES
19
} game_state;
20
21
typedef enum binding_type
22
{
23
BINDING_ATOMIC, // press button to turn state on,
24
// press again to switch off
25
26
BINDING_CONTINUOUS, // press button and state turns on,
27
// release and state turns off
28
29
BINDING_ONE_TIME // press button and state turns on,
30
// state must then be turned off
31
// manually
32
} binding_type;
33
34
typedef struct key_state_binding key_state_binding;
35
struct key_state_binding
36
{
37
SDL_Keycode k;
38
game_state s;
39
binding_type t;
40
};
41
42
43
enum
44
{
45
MAX_BINDINGS = 100
46
};
47
48
void input_processor_init();
49
bool add_binding(key_state_binding *binding);
50
bool rm_binding(key_state_binding *binding);
51
void process_input();
52
void activate_state(game_state state);
53
void deactivate_state(game_state state);
54
bool is_state_active(game_state state);
55
56
bool test_input_processor();
57
58
#endif
59
60