forked from robotfuel/n64_kbd_bbb
/
test.c
117 lines (97 loc) · 1.61 KB
/
test.c
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
i#include "SDL/SDL.h"
void HaxKBSetup();
int Init();
void QuitProgram();
int CaptureInput();
struct KB
{
/* data */
};
//Globals
int boolCaptureIO = 0;
int boolRunProgram = 1;
SDL_Surface* screen = NULL;
SDL_Event event;
//TTF_Font *font = NULL;
int main( int argc, char* args[] )
{
if(!Init())
{
return -1;
}
HaxKBSetup();
CaptureInput();
return 0;
}
void HaxKBSetup()
{
printf("Press Start\n" );
int waiting = 1;
while(waiting)
{
while(SDL_PollEvent(&event))
{
if( event.type == SDL_KEYDOWN )
{
//Process key press
waiting = 0;
break;
}
}
}
printf("Press A\n" );
printf("Press B\n" );
printf("Press Up\n" );
printf("Press Down\n");
}
int CaptureInput()
{
boolCaptureIO = 1;
while( boolCaptureIO )
{
//While there's an event to handle
while( SDL_PollEvent( &event ) )
{
//If a key was pressed
if( event.type == SDL_KEYDOWN )
{
//Process key press
}
else if( event.type == SDL_KEYUP)
{
//Process key up
}
else if( event.type == SDL_QUIT )
{
//Quit the program
QuitProgram();
}
//If there's an event to handle
}
}
}
int Init()
{
//Initialize all SDL subsystems
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return 0;
}
//Set up the screen
screen = SDL_SetVideoMode( 640,480,32, SDL_SWSURFACE );
//If there was an error in setting up the screen
if( screen == NULL )
{
return 0;
}
//Set the window caption
SDL_WM_SetCaption( "Projectx74 v2.0", NULL );
//If everything initialized fine
return 1;
}
void QuitProgram()
{
boolCaptureIO = 0;
boolRunProgram = 0;
SDL_Quit();
}