-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.c
More file actions
55 lines (47 loc) · 980 Bytes
/
input.c
File metadata and controls
55 lines (47 loc) · 980 Bytes
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 "input.h"
#include <curses.h>
/* Initialise the input system */
bool iinit(){
cbreak(); // don't wait for newline
noecho();
keypad(stdscr, TRUE);
// Successful init
return true;
}
// Get an input instruction
input_instruction_t iget(){
int c = getch();
switch(c){
case KEY_LEFT:
return in_left;
case KEY_RIGHT:
return in_right;
case KEY_UP:
return in_up;
case KEY_DOWN:
return in_down;
case ' ':
return in_fire;
case '-':
return in_zoom_out;
case '+':
return in_zoom_in;
case 'p':
return in_pause;
case KEY_F(1):
return in_quit;
}
return in_null;
}
// set the timeout in ms
void iset_timeout(int t){
timeout(t);
}
// Set infinitely blocking
void iset_blocking(){
timeout(-1);
}
// Uninitialise input
void iteardown(){
// do nothing
}