Changeset 3279 for code/branches/core4/src/core/input/InputManager.h
- Timestamp:
- Jul 12, 2009, 11:08:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/input/InputManager.h
r3276 r3279 44 44 #include <vector> 45 45 46 #include "util/Math.h"47 #include "util/OrxEnum.h"48 46 #include "core/OrxonoxClass.h" 47 #include "InputState.h" 49 48 50 49 namespace orxonox 51 50 { 52 struct InputStatePriority : OrxEnum<InputStatePriority>53 {54 OrxEnumConstructors(InputStatePriority);55 56 static const int Empty = -1;57 static const int Dynamic = 0;58 59 static const int HighPriority = 1000;60 static const int Console = HighPriority + 0;61 static const int Calibrator = HighPriority + 1;62 static const int Detector = HighPriority + 2;63 };64 65 51 /** 66 52 @brief … … 69 55 class _CoreExport InputManager : public OrxonoxClass 70 56 { 71 // --> setConfigValues is private72 friend class ClassIdentifier<InputManager>;73 74 57 public: 75 enum InputManagerState58 enum State 76 59 { 77 Uninitialised = 0x00, 78 OISReady = 0x01, 79 InternalsReady = 0x02, 80 Ticking = 0x04, 81 Calibrating = 0x08, 82 ReloadRequest = 0x10, 60 Nothing = 0x00, 61 Bad = 0x02, 62 Ticking = 0x04, 63 Calibrating = 0x08, 64 ReloadRequest = 0x10, 83 65 }; 84 66 85 67 InputManager (size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight); 86 68 ~InputManager(); 69 void setConfigValues(); 87 70 88 void initialise(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight); 71 void update(const Clock& time); 72 void clearBuffers(); 73 void calibrate(); 74 void reload(); 89 75 90 void reloadInputSystem(); 76 //------------------------------- 77 // Input States 78 //------------------------------- 79 InputState* createInputState(const std::string& name, bool bAlwaysGetsInput = false, bool bTransparent = false, InputStatePriority priority = InputStatePriority::Dynamic); 80 InputState* getState(const std::string& name); 81 bool enterState (const std::string& name); 82 bool leaveState (const std::string& name); 83 bool destroyState (const std::string& name); 91 84 92 void clearBuffers();93 94 void setWindowExtents(const int width, const int height);85 //------------------------------- 86 // Various getters and setters 87 //------------------------------- 95 88 void setKeyDetectorCallback(const std::string& command); 96 97 InputState* createInputState(const std::string& name, bool bAlwaysGetsInput = false, bool bTransparent = false, InputStatePriority priority = InputStatePriority::Dynamic);98 99 InputState* getState (const std::string& name);100 InputState* getCurrentState();101 bool requestDestroyState (const std::string& name);102 bool requestEnterState (const std::string& name);103 bool requestLeaveState (const std::string& name);104 105 OIS::InputManager* getInputSystem() { return this->inputSystem_; }106 89 bool checkJoyStickID(const std::string& idString) const; 107 90 unsigned int getJoyStickQuantity() const 108 91 { return devices_.size() - InputDeviceEnumerator::FirstJoyStick; } 109 110 void update(const Clock& time);92 OIS::InputManager* getOISInputManager() 93 { return this->oisInputManager_; } 111 94 112 95 static InputManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 113 static InputManager* getInstancePtr() { return singletonRef_s; }114 115 // console commands116 static void calibrate();117 static void reload();118 96 119 97 private: // functions … … 122 100 123 101 // Intenal methods 124 void _initialiseKeyboard(); 125 void _initialiseMouse(unsigned int windowWidth, unsigned int windowHeight); 126 void _initialiseJoySticks(); 102 void loadDevices(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight); 103 void loadMouse(unsigned int windowWidth, unsigned int windowHeight); 104 void loadJoySticks(); 105 void destroyDevices(); 127 106 128 void _startCalibration(); 129 void _stopCalibration(); 107 void stopCalibration(); 130 108 131 void _destroyState(InputState* state); 109 void destroyStateInternal(InputState* state); 110 void updateActiveStates(); 111 bool configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority); 132 112 133 void _reload(); 134 135 void _updateActiveStates(); 136 bool _configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority); 137 138 void setConfigValues(); 113 void reloadInternal(); 139 114 140 115 private: // variables 141 OIS::InputManager* inputSystem_; //!< OIS input manager 116 State internalState_; //!< Current internal state 117 OIS::InputManager* oisInputManager_; //!< OIS input manager 142 118 std::vector<InputDevice*> devices_; //!< List of all input devices (keyboard, mouse, joy sticks) 143 119 size_t windowHnd_; //!< Render window handle 144 InputManagerState internalState_; //!< Current internal state145 120 146 121 // some internally handled states and handlers 147 InputState* stateEmpty_;122 InputState* emptyState_; 148 123 KeyDetector* keyDetector_; //!< KeyDetector instance 149 InputBuffer* calibratorCallback Buffer_;124 InputBuffer* calibratorCallbackHandler_; 150 125 151 std::map<std::string, InputState*> inputStatesByName_; 126 std::map<std::string, InputState*> statesByName_; 127 std::map<int, InputState*> activeStates_; 128 std::vector<InputState*> activeStatesTicked_; 152 129 153 130 std::set<InputState*> stateEnterRequests_; //!< Request to enter a new state 154 131 std::set<InputState*> stateLeaveRequests_; //!< Request to leave a running state 155 132 std::set<InputState*> stateDestroyRequests_; //!< Request to destroy a state 156 157 std::map<int, InputState*> activeStates_;158 std::vector<InputState*> activeStatesTicked_;159 133 160 134 static InputManager* singletonRef_s;
Note: See TracChangeset
for help on using the changeset viewer.