blob: 8af741403862d78c10a13ec5bf50e60d85ab0869 (
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
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
|
/* input.cc
This file is part of the Osirion project and is distributed under
the terms and conditions of the GNU General Public License version 2
*/
// SDL headers
#include <SDL/SDL.h>
//project headers
#include "common/functions.h"
#include "game/game.h"
#include "view.h"
#include "camera.h"
namespace input
{
void init()
{
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
}
void shutdown()
{
}
void handle_keydown(SDL_keysym* keysym)
{
switch( keysym->sym ) {
case SDLK_ESCAPE:
game::shutdown();
break;
case SDLK_SPACE:
camera::nextmode();
break;
case SDLK_LEFT:
camera::rotate_left();
break;
case SDLK_RIGHT:
camera::rotate_right();
break;
case SDLK_UP:
camera::rotate_up();
break;
case SDLK_DOWN:
camera::rotate_down();
break;
case SDLK_KP_PLUS:
game::ship.thrust_increase();
break;
case SDLK_KP_MINUS:
game::ship.thrust_decrease();
break;
case SDLK_KP4:
game::ship.turn_left();
break;
case SDLK_KP6:
game::ship.turn_right();
break;
default:
break;
}
}
void process()
{
SDL_Event event;
while( SDL_PollEvent( &event ) ) {
switch( event.type ) {
// case SDL_MOUSEBUTTONUP:
case SDL_KEYDOWN:
handle_keydown( &event.key.keysym );
break;
case SDL_QUIT:
game::shutdown();
break;
}
}
}
} // namespace input
|