-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO_SDL.c
More file actions
76 lines (65 loc) · 1.46 KB
/
Copy pathIO_SDL.c
File metadata and controls
76 lines (65 loc) · 1.46 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <SDL/SDL.h>
#define IO_KEY_ESC SDLK_ESCAPE
#define IO_KEY_UP SDLK_UP
#define IO_KEY_DOWN SDLK_DOWN
#define IO_KEY_LEFT SDLK_LEFT
#define IO_KEY_RIGHT SDLK_RIGHT
#define IO_KEY_I SDLK_i
#define IO_KEY_J SDLK_j
#define IO_KEY_K SDLK_k
#define IO_KEY_L SDLK_l
#define IO_KEY_O SDLK_o
#define IO_KEY_U SDLK_u
#define IO_KEY_C SDLK_c
#define IO_KEY_H SDLK_h
#define IO_KEY_T SDLK_t
#define IO_KEY_N SDLK_n
#define IO_KEY_G SDLK_g
#define IO_KEY_R SDLK_r
#define IO_KEY_F SDLK_f
#define IO_KEY_V SDLK_v
#define IO_KEY_S SDLK_s
#define IO_KEY_SPACE SDLK_SPACE
#define IO_KEY_ENTER SDLK_RETURN
#define IO_KEY_RSHIFT SDLK_RSHIFT
#define IO_KEY_END SDLK_END
typedef char IO_Key;
void IO_Init() {
}
void IO_Done() {
}
void IO_PollKeyboard() {
}
int IO_ReadKey() {
SDL_Event event;
SDL_KeyboardEvent* kevent;
event.type = SDL_USEREVENT;
while (event.type != SDL_KEYUP) {
SDL_WaitEvent(&event);
}
kevent = (SDL_KeyboardEvent*) &event;
return kevent->keysym.sym;
}
void IO_Wait(int time) {
SDL_Delay(time);
}
void IO_ClearKeyboardBuffer() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
}
}
int IO_ReadExtKey() {
SDL_Event event;
SDL_KeyboardEvent* kevent;
event.type = SDL_USEREVENT;
while (event.type != SDL_KEYUP) {
SDL_WaitEvent(&event);
}
kevent = (SDL_KeyboardEvent*) &event;
return kevent->keysym.sym;
}
IO_Key* IO_GetKeyboardState() {
int numkeys;
SDL_PumpEvents();
return SDL_GetKeyState(&numkeys);
}