home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Input_h__
- #define __Input_h__
-
- #include "SDL.h"
- #include "InputInfo.h"
-
- typedef enum actions_e{
- NO_ACTION,
-
- MOVE_FORWARD,
- MOVE_BACKWARD,
- MOVE_LEFT,
- MOVE_RIGHT,
- MOVE_UP,
- MOVE_DOWN,
-
- TURN_LEFT,
- TURN_RIGHT,
- TURN_UP,
- TURN_DOWN,
-
- FIRE_WEAPON_1,
- FIRE_WEAPON_2,
- FIRE_WEAPON_3,
- FIRE_WEAPON_4,
-
- CAMERA_ZOOM_IN,
- CAMERA_ZOOM_OUT,
- CAMERA_ROTATE_LEFT,
- CAMERA_ROTATE_RIGHT,
- CAMERA_ROTATE_UP,
- CAMERA_ROTATE_DOWN,
- CAMERA_RESET,
-
- TOGGLE_CONSOLE,
-
- NUM_ACTIONS
- }action_t;
-
- typedef struct inputArrayElement_s{
- bool pressed;
- }inputArrayElement_t;
-
- typedef inputArrayElement_t inputArray_t[NUM_ACTIONS];
-
-
- typedef struct keyMapElement_s{
- bool pressed;
- action_t action;
- char* consoleString;
- }keyMapElement_t;
-
- typedef keyMapElement_t keyMap_t[SDLK_LAST];
-
-
- enum mouseButtons_e{
- MOUSE_BUTTON1=1, // left
- MOUSE_BUTTON2, // middle
- MOUSE_BUTTON3, // right
- MOUSE_BUTTON4, // mwheelup
- MOUSE_BUTTON5, // mwheeldown
-
- NUM_MOUSE_BUTTONS
- };
-
- typedef struct mouseButton_s{
- bool pressed;
- action_t action;
- char* consoleString;
- int x,y;
- }mouseButton_t;
-
- typedef struct mouse_{
- int x,y;
- mouseButton_t buttons[NUM_MOUSE_BUTTONS];
- float sensitivity;
- }mouse_t;
-
-
- class Input{
- public:
- static InputInfo info;
-
- static bool init();
- static bool shutdown();
- static bool wasInit();
-
- static bool registerCVarsAndCCmds();
- static bool unregisterCVarsAndCCmds();
-
- protected:
- static bool initialized;
-
-
- public:
- static mouse_t mouse;
- static keyMap_t keyMap;
- static inputArray_t inputArray;
-
- static void handleKeyboardEvent(SDL_KeyboardEvent* event);
- static void handleMouseMotionEvent(SDL_MouseMotionEvent* event);
- static void handleMouseButtonEvent(SDL_MouseButtonEvent* event);
-
- static void showMouseCursor();
- static void hideMouseCursor();
- static void grabInput();
- static void freeInput();
-
- static void processInputArray();
-
- static const char* keyNames[SDLK_LAST];
- static const char* actionNames[NUM_ACTIONS];
- static void initKeyNames();
- static void initActionNames();
- static int getMouseButtonForString(char* str);
- static int getKeyForString(char* str);
- static int getActionForString(char* str);
- static const char* getKeyName(int keysym);
- static const char* getActionName(int action);
- };
-
- #endif /* __Input_h__ */
-