aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/input')
-rw-r--r--src/libjin/input/event.h60
-rw-r--r--src/libjin/input/mouse.cpp22
-rw-r--r--src/libjin/input/mouse.h20
3 files changed, 89 insertions, 13 deletions
diff --git a/src/libjin/input/event.h b/src/libjin/input/event.h
index 4d7230a..83db070 100644
--- a/src/libjin/input/event.h
+++ b/src/libjin/input/event.h
@@ -9,22 +9,62 @@ namespace input
{
#if JIN_INPUT_SDL
#include "SDL.h"
- typedef SDL_Event Event;
+ typedef SDL_Event Event;
+ typedef SDL_Keycode Key;
+ typedef SDL_MouseWheelEvent Wheel;
+
+ enum EventType {
+ QUIT = SDL_QUIT,
+ KEYDOWN = SDL_KEYDOWN,
+ KEYUP = SDL_KEYUP,
+ MOUSEMOTION = SDL_MOUSEMOTION,
+ MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN,
+ MOUSEBUTTONUP = SDL_MOUSEBUTTONUP,
+ MOUSEWHEEL = SDL_MOUSEWHEEL
+ };
+
inline int pollEvent(Event* e)
{
return SDL_PollEvent(e);
}
- enum EventType{
- QUIT = SDL_QUIT,
- KEYDOWN = SDL_KEYDOWN ,
- KEYUP = SDL_KEYUP,
- MOUSEMOTION = SDL_MOUSEMOTION,
- MOUSEBUTTONDOWN = SDL_MOUSEBUTTONDOWN,
- MOUSEBUTTONUP = SDL_MOUSEBUTTONUP,
- MOUSEWHEEL = SDL_MOUSEWHEEL
- };
+ inline const char* getKeyName(Key key)
+ {
+ return SDL_GetKeyName(key);
+ }
+
+ inline const char* getButtonName(int button)
+ {
+ switch (button)
+ {
+ case 1: return "left";
+ case 2: return "middle";
+ case 3: return "right";
+ case 4: return "wheelup";
+ case 5: return "wheeldown";
+ default: return "?";
+ }
+ }
+
+/*
+ inline const char* getWheelName(Wheel wheel)
+ {
+ if (wheel.x == -1)
+ return "left";
+ else if (wheel.x == 1)
+ return "right";
+ else if (wheel.y == -1)
+ return "near";
+ else if (wheel.y == 1)
+ return "far";
+ else
+ return "none";
+ }
+*/
+
+
+
#endif // JIN_INPUT_SDL
}
}
diff --git a/src/libjin/input/mouse.cpp b/src/libjin/input/mouse.cpp
index e69de29..98c4a39 100644
--- a/src/libjin/input/mouse.cpp
+++ b/src/libjin/input/mouse.cpp
@@ -0,0 +1,22 @@
+#include "../modules.h"
+#ifdef JIN_MODULES_INPUT
+
+#include "SDL.h"
+#include "Mouse.h"
+
+namespace jin
+{
+namespace input
+{
+
+ void Mouse::getState(int* x, int* y)
+ {
+#ifdef JIN_INPUT_SDL
+ SDL_GetMouseState(x, y);
+#endif // JIN_INPUT_SDL
+ }
+
+} // input
+} // jin
+
+#endif // JIN_MODULES_INPUT \ No newline at end of file
diff --git a/src/libjin/input/mouse.h b/src/libjin/input/mouse.h
index b926327..cb70407 100644
--- a/src/libjin/input/mouse.h
+++ b/src/libjin/input/mouse.h
@@ -1,15 +1,29 @@
#ifndef __JIN_MOUSE_H
#define __JIN_MOUSE_H
+#include "../modules.h"
+#ifdef JIN_MODULES_INPUT
+
+#include "../Common/Singleton.h"
+
namespace jin
{
namespace input
{
- class Mouse
+ class Mouse : public Singleton<Mouse>
{
public:
- };
+ //
+ void getState(int* x, int* y);
+ private:
+ Mouse() {};
+ ~Mouse() {};
+
+ SINGLETON(Mouse);
+ };
}
}
-#endif \ No newline at end of file
+
+#endif // JIN_MODULES_INPUT
+#endif // __JIN_MOUSE_H \ No newline at end of file