Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/input.cc')
-rw-r--r--src/client/input.cc86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
new file mode 100644
index 0000000..8af7414
--- /dev/null
+++ b/src/client/input.cc
@@ -0,0 +1,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