aboutsummaryrefslogtreecommitdiff
path: root/src/sdl/system.c
blob: 610685d8cdbb33d6d6bc054a977e7c4e959cda87 (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
49
50
51
52
53
54
55
#include <SDL/SDL.h>
#include "system.h"


char quitGame = 0;

void Input_KeyEvent(SDL_Event* evt);
void Input_JoyEvent(SDL_Event* evt);
void Input_JoyAxisEvent(SDL_Event* evt);
void Input_JoyHatEvent(SDL_Event* evt);

int PHL_MainLoop()
{
    SDL_Event evt;
    while(SDL_PollEvent(&evt))
    {
        switch(evt.type)
        {
            case SDL_QUIT:
                return 0;
            case SDL_KEYDOWN:
            case SDL_KEYUP:
                Input_KeyEvent(&evt);
                break;
            case SDL_JOYAXISMOTION:
                Input_JoyAxisEvent(&evt);
                break;
            case SDL_JOYHATMOTION:
                Input_JoyHatEvent(&evt);
                break;
            case SDL_JOYBUTTONDOWN:
            case SDL_JOYBUTTONUP:
                Input_JoyEvent(&evt);
                break;
        }
    }
    if (quitGame == 1) 
    {
		return 0;
	}
	return 1;
}
void PHL_ConsoleInit()
{

}
void PHL_GameQuit()
{
    quitGame = 1;
}

void PHL_ErrorScreen(char* message)
{
    fprintf(stderr, "%s\n", message);
}