[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/sdl/input.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/sdl/input.cpp |
Date: |
Tue, 01 Mar 2005 19:27:13 -0500 |
Index: usata2/src/sdl/input.cpp
diff -u usata2/src/sdl/input.cpp:1.3 usata2/src/sdl/input.cpp:1.4
--- usata2/src/sdl/input.cpp:1.3 Fri Feb 25 19:50:48 2005
+++ usata2/src/sdl/input.cpp Wed Mar 2 00:27:11 2005
@@ -10,20 +10,20 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: input.cpp,v 1.3 2005/02/25 19:50:48 skunix Exp $
+// $Id: input.cpp,v 1.4 2005/03/02 00:27:11 skunix Exp $
#include <queue>
+#include <vector>
+#include <SDL.h>
#include "../input-system.hpp"
-#include <SDL.h>
-#include <vector>
#include "../log.hpp"
-namespace usata { namespace input{
+namespace usata {
+namespace input {
namespace {
-//using namespace input;
struct SDL2Usata
{
SDLKey s;
@@ -41,7 +41,7 @@
size_t key_conversion_len = sizeof(key_conversion)/sizeof(SDL2Usata);
-int key_convert(SDLKey sk)
+int key_convert(SDLKey sk) throw()
{
SDL2Usata *conv3rt = &key_conversion[0];
int retval(Key::UNKNOWN);
@@ -63,19 +63,23 @@
std::queue<input::Event*> mEventQueue;
public:
SDLDriver();
- virtual ~SDLDriver();
+ virtual ~SDLDriver()throw();
virtual Event* next();
- Event* process(SDL_Event&);
+ static Event* process(SDL_Event&) throw();
+ static Event* key_process(SDL_Event&ev)throw();
+
virtual void update();
};
SDLDriver::SDLDriver()
: input::Driver("SDL")
{
-
+ log::BufferedStream ls(log::Level::INFO);
+ ls << "SDL input Driver initialized" << log::commit;
+
}
-SDLDriver::~SDLDriver()
+SDLDriver::~SDLDriver() throw()
{
}
@@ -91,18 +95,33 @@
}
Event*
-SDLDriver::process(SDL_Event&ev)
+SDLDriver::key_process(SDL_Event&ev) throw()
+{
+ Event*retval;
+ bool state=false;
+ if (ev.type == SDL_KEYDOWN)
+ state=true;
+
+ int key = key_convert(ev.key.keysym.sym);
+
+ retval = new KeyEvent(key, state);
+
+ return retval;
+};
+
+
+Event*
+SDLDriver::process(SDL_Event&ev) throw()
{
switch (ev.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
-// return key_process();
- break;
+ return key_process(ev);
+
case SDL_QUIT:
return new SystemEvent(SystemEvent::QUIT);
- break;
};
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Usata-commits] Changes to usata2/src/sdl/input.cpp,
David Lau <=