[4866] | 1 | /*! |
---|
[5039] | 2 | * @file key_mapper.h |
---|
[4836] | 3 | * a construct to map player defined keys to SDL keys |
---|
[4367] | 4 | |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | #ifndef _KEY_MAPPER_H |
---|
| 8 | #define _KEY_MAPPER_H |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | #include "base_object.h" |
---|
[7661] | 12 | #include <string> |
---|
[4866] | 13 | class IniParser; |
---|
[4367] | 14 | |
---|
[7661] | 15 | //! The map class functionalities |
---|
| 16 | class KeyMapper : public BaseObject |
---|
[4400] | 17 | { |
---|
[7661] | 18 | public: |
---|
| 19 | //! A mapping from key-name to key-id |
---|
| 20 | typedef struct KeyMapping |
---|
| 21 | { |
---|
| 22 | int* pValue; |
---|
| 23 | const std::string pName; |
---|
| 24 | int defaultValue; |
---|
| 25 | }; |
---|
[4386] | 26 | |
---|
[7661] | 27 | public: |
---|
[4367] | 28 | KeyMapper(); |
---|
| 29 | virtual ~KeyMapper(); |
---|
| 30 | |
---|
[7256] | 31 | void loadKeyBindings(const std::string& fileName ); |
---|
| 32 | void loadKeyBindings(); |
---|
[4866] | 33 | void loadKeyBindings(IniParser* iniParser); |
---|
[4368] | 34 | |
---|
[7661] | 35 | static const KeyMapping* getKeyMapping() { return KeyMapper::map; }; |
---|
| 36 | |
---|
[4389] | 37 | void debug(); |
---|
| 38 | |
---|
[7661] | 39 | private: |
---|
[7221] | 40 | int* nameToIndex (const std::string& name); |
---|
| 41 | void mapKeys(const std::string& name, int* index); |
---|
[4368] | 42 | |
---|
[7661] | 43 | public: |
---|
[6997] | 44 | static int PEV_FORWARD; //!< forward button |
---|
| 45 | static int PEV_BACKWARD; //!< backward buttton |
---|
[4452] | 46 | static int PEV_LEFT; //!< left button |
---|
| 47 | static int PEV_RIGHT; //!< right button |
---|
[6998] | 48 | static int PEV_UP; //!< up button |
---|
| 49 | static int PEV_DOWN; //!< down button |
---|
[4866] | 50 | |
---|
[5978] | 51 | static int PEV_ROLL_LEFT; //!< rolls left |
---|
| 52 | static int PEV_ROLL_RIGHT; //!< rolls right |
---|
| 53 | |
---|
[4452] | 54 | static int PEV_STRAFE_LEFT; //!< strafe left button |
---|
| 55 | static int PEV_STRAFE_RIGHT; //!< strafe right button |
---|
[4866] | 56 | |
---|
[4452] | 57 | static int PEV_FIRE1; //!< fire button 1 |
---|
| 58 | static int PEV_FIRE2; //!< fire button 2 |
---|
| 59 | static int PEV_PREVIOUS_WEAPON; //!< prev weapon button |
---|
| 60 | static int PEV_NEXT_WEAPON; //!< next weapon button |
---|
[4368] | 61 | |
---|
[6998] | 62 | static int PEV_CHANGE_SHIP; //!< The button to change the Ship. |
---|
| 63 | |
---|
[4452] | 64 | static int PEV_VIEW0; //!< view 0 button |
---|
| 65 | static int PEV_VIEW1; //!< view 1 button |
---|
| 66 | static int PEV_VIEW2; //!< view 2 button |
---|
| 67 | static int PEV_VIEW3; //!< view 3 button |
---|
| 68 | static int PEV_VIEW4; //!< view 4 button |
---|
| 69 | static int PEV_VIEW5; //!< view 5 button |
---|
[4368] | 70 | |
---|
[4452] | 71 | static int PEV_NEXT_WORLD; //!< next world button |
---|
| 72 | static int PEV_PREVIOUS_WORLD; //!< prev world button |
---|
[4410] | 73 | |
---|
[4452] | 74 | static int PEV_PAUSE; //!< pause button |
---|
| 75 | static int PEV_QUIT; //!< quit button |
---|
[4410] | 76 | |
---|
[7661] | 77 | private: |
---|
| 78 | int coord[2]; //!< temp place to save variables in nameToIndex() function |
---|
| 79 | static KeyMapping map[]; //!< The KeyMapping that maps strings to ID's and Vice Versa |
---|
[4367] | 80 | }; |
---|
| 81 | |
---|
[4400] | 82 | |
---|
| 83 | |
---|
| 84 | |
---|
[4367] | 85 | #endif /* _KEY_MAPPER_H */ |
---|