blob: 7b3b94eca9df48a2ff5302cc9e17867e60811fff (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include "TZR_events.h"
#include "TZR_globals.h"
#include <SDL2/SDL_events.h>
int
TZR_PollEvent(TZR_Event *e)
{
TZR_Event discard;
if (e == NULL)
e = &discard;
SDL_Event se;
while (SDL_PollEvent(&se)) switch (se.type) {
case SDL_QUIT:
e->type = TZR_EV_QUIT;
___tzr_should_quit = 1;
return 1;
case SDL_KEYDOWN:
if (se.key.repeat)
break;
e->type = TZR_EV_KEYDOWN;
e->button = se.key.keysym.scancode;
___tzr_keystates[e->button] = TZR_KEYSTATE_PRESS;
break;
case SDL_KEYUP:
e->type = TZR_EV_KEYUP;
e->button = se.key.keysym.scancode;
___tzr_keystates[e->button] = TZR_KEYSTATE_RELEASE;
break;
case SDL_MOUSEBUTTONDOWN:
___tzr_mouse_x = se.button.x;
___tzr_mouse_y = se.button.y;
___tzr_mousestates[se.button.button] = TZR_KEYSTATE_PRESS;
break;
case SDL_MOUSEBUTTONUP:
___tzr_mouse_x = se.button.x;
___tzr_mouse_y = se.button.y;
___tzr_mousestates[se.button.button] = TZR_KEYSTATE_RELEASE;
break;
case SDL_MOUSEMOTION:
___tzr_mouse_x = se.motion.x;
___tzr_mouse_y = se.motion.y;
break;
default:
break;
}
return 0;
}
|