- Timestamp:
- Jul 22, 2008, 9:16:35 PM (16 years ago)
- Location:
- code/branches/gui/src
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/Shell.cc
r1638 r1641 33 33 #include "Core.h" 34 34 #include "ConsoleCommand.h" 35 #include "input/InputInterfaces.h"36 #include "input/SimpleInputState.h"37 #include "input/InputManager.h"38 35 39 36 #define SHELL_UPDATE_LISTENERS(function) \ … … 61 58 this->inputBuffer_ = new InputBuffer(); 62 59 this->configureInputBuffer(); 63 InputManager::createSimpleInputState("console", 40)->setKeyHandler(this->inputBuffer_);64 60 65 61 this->outputBuffer_.registerListener(this); … … 70 66 Shell::~Shell() 71 67 { 72 SimpleInputState * inputState = dynamic_cast<SimpleInputState*>(InputManager::getState("console")); 73 if (inputState) 74 { 75 inputState->removeAndDestroyAllHandlers(); 76 InputManager::destroyState("console"); 77 } 68 if (this->inputBuffer_) 69 delete this->inputBuffer_; 78 70 } 79 71 -
code/branches/gui/src/core/Shell.h
r1638 r1641 71 71 void unregisterListener(ShellListener* listener); 72 72 73 inline InputBuffer &getInputBuffer()74 { return (*this->inputBuffer_); }73 inline InputBuffer* getInputBuffer() 74 { return this->inputBuffer_; } 75 75 inline OutputBuffer& getOutputBuffer() 76 76 { return this->outputBuffer_; } -
code/branches/gui/src/core/input/ExtendedInputState.cc
r1638 r1641 118 118 } 119 119 120 void ExtendedInputState::joyStickButtonPressed(unsigned int joyStickID, unsigned int button)120 void ExtendedInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButton::Enum id) 121 121 { 122 122 assert(joyStickID < joyStickHandlers_.size()); 123 123 for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++) 124 joyStickHandlers_[joyStickID][i]->joyStickButtonPressed(joyStickID, button);125 } 126 127 void ExtendedInputState::joyStickButtonReleased(unsigned int joyStickID, unsigned int button)124 joyStickHandlers_[joyStickID][i]->joyStickButtonPressed(joyStickID, id); 125 } 126 127 void ExtendedInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) 128 128 { 129 129 assert(joyStickID < joyStickHandlers_.size()); 130 130 for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++) 131 joyStickHandlers_[joyStickID][i]->joyStickButtonReleased(joyStickID, button);132 } 133 134 void ExtendedInputState::joyStickButtonHeld(unsigned int joyStickID, unsigned int button)131 joyStickHandlers_[joyStickID][i]->joyStickButtonReleased(joyStickID, id); 132 } 133 134 void ExtendedInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButton::Enum id) 135 135 { 136 136 assert(joyStickID < joyStickHandlers_.size()); 137 137 for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++) 138 joyStickHandlers_[joyStickID][i]->joyStickButtonHeld(joyStickID, button);138 joyStickHandlers_[joyStickID][i]->joyStickButtonHeld(joyStickID, id); 139 139 } 140 140 -
code/branches/gui/src/core/input/ExtendedInputState.h
r1638 r1641 81 81 void mouseScrolled (int abs, int rel); 82 82 83 void joyStickButtonPressed (unsigned int joyStickID, unsigned int button);84 void joyStickButtonReleased(unsigned int joyStickID, unsigned int button);85 void joyStickButtonHeld (unsigned int joyStickID, unsigned int button);83 void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id); 84 void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id); 85 void joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id); 86 86 void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value); void updateTickables(); 87 87 -
code/branches/gui/src/core/input/InputBuffer.h
r1638 r1641 171 171 172 172 void tickInput(float dt); 173 void tick Input(float dt, int device) { }173 void tickKey(float dt) { } 174 174 175 175 std::string buffer_; -
code/branches/gui/src/core/input/InputInterfaces.h
r1638 r1641 213 213 } 214 214 215 namespace JoyStickButton 216 { 217 enum Enum 218 { 219 Button0 = 0, Button1 = 1, Button2 = 2, Button3 = 3, 220 Button4 = 4, Button5 = 5, Button6 = 6, Button7 = 7, 221 Button8 = 8, Button9 = 9, Button10 = 10, Button11 = 11, 222 Button12 = 12, Button13 = 13, Button14 = 14, Button15 = 15, 223 Button16 = 16, Button17 = 17, Button18 = 18, Button19 = 19, 224 Button20 = 20, Button21 = 21, Button22 = 22, Button23 = 23, 225 Button24 = 24, Button25 = 25, Button26 = 26, Button27 = 27, 226 Button28 = 28, Button29 = 29, Button30 = 30, Button31 = 31, 227 228 POV0North = 32, POV0South = 33, POV0East = 34, POV0West = 35, 229 POV0NorthEast = 36, POV0SouthEast = 37, POV0NorthWest = 38, POV0SouthWest = 39, 230 231 POV1North = 40, POV1South = 41, POV1East = 42, POV1West = 43, 232 POV1NorthEast = 44, POV1SouthEast = 45, POV1NorthWest = 46, POV1SouthWest = 47, 233 234 POV2North = 48, POV2South = 49, POV2East = 50, POV2West = 51, 235 POV2NorthEast = 52, POV2SouthEast = 53, POV2NorthWest = 54, POV2SouthWest = 55, 236 237 POV3North = 56, POV3South = 57, POV3East = 58, POV3West = 59, 238 POV3NorthEast = 60, POV3SouthEast = 61, POV3NorthWest = 62, POV3SouthWest = 63, 239 }; 240 } 241 215 242 namespace KeyboardModifier 216 243 { … … 259 286 }; 260 287 261 //typedef OIS::MouseState MouseState;262 263 /*class _CoreExport JoyStickState264 {265 public:266 JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }267 JoyStickState() { clear(); }268 int mJoyStickID;269 JoyStickState() { clear(); }270 271 std::vector<bool> mButtons;272 int axes[16];273 std::vector<Vector3> mVectors;274 };*/275 276 /**277 @brief278 Helper struct to determine which handlers of an object (can implement279 multiple handlers) are active.280 */281 //struct HandlerState282 //{283 // HandlerState() : keyboard(false), mouse(false) { }284 // bool keyboard;285 // bool mouse;286 // std::vector<bool> joySticks;287 //};288 288 289 289 class _CoreExport InputTickable … … 292 292 virtual ~InputTickable() { } 293 293 virtual void tickInput(float dt) = 0; 294 //virtual void tickInput(float dt, unsigned int device) = 0;295 294 }; 296 295 … … 306 305 virtual void keyReleased(const KeyEvent& evt) = 0; 307 306 virtual void keyHeld (const KeyEvent& evt) = 0; 308 virtual void tickKey (float dt) { }307 virtual void tickKey (float dt) = 0; 309 308 }; 310 309 … … 322 321 virtual void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0; 323 322 virtual void mouseScrolled (int abs, int rel) = 0; 324 virtual void tickMouse (float dt) { }323 virtual void tickMouse (float dt) = 0; 325 324 }; 326 325 … … 334 333 public: 335 334 virtual ~JoyStickHandler() { } 336 virtual void joyStickButtonPressed (unsigned int joyStickID, unsigned int button) = 0;337 virtual void joyStickButtonReleased(unsigned int joyStickID, unsigned int button) = 0;338 virtual void joyStickButtonHeld (unsigned int joyStickID, unsigned int button) = 0;335 virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) = 0; 336 virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) = 0; 337 virtual void joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id) = 0; 339 338 virtual void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value) = 0; 340 //virtual bool joyStickVector3Moved (unsigned int joyStickID, unsigned int index /*, fill list*/) {return true;} 341 virtual void tickJoyStick (float dt, unsigned int device) { } 339 virtual void tickJoyStick (float dt, unsigned int joyStick) = 0; 342 340 }; 343 341 … … 346 344 private: 347 345 void tickInput(float dt) { } 348 void tickInput(float dt, unsigned int device) { } 346 void tickJoyStick(float dt, unsigned int joyStick) { } 347 void tickMouse(float dt) { } 348 void tickKey(float dt) { } 349 349 350 350 void keyPressed (const KeyEvent& evt) { } … … 358 358 void mouseScrolled (int abs, int rel) { } 359 359 360 void joyStickButtonPressed (unsigned int joyStickID, unsigned int button) { }361 void joyStickButtonReleased(unsigned int joyStickID, unsigned int button) { }362 void joyStickButtonHeld (unsigned int joyStickID, unsigned int button) { }360 void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) { } 361 void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) { } 362 void joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id) { } 363 363 void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value) { } 364 364 }; -
code/branches/gui/src/core/input/InputManager.cc
r1638 r1641 91 91 /** 92 92 @brief 93 Destructor itself only called at the end of the program, after main. 94 Instance gets registered for destruction with atexit(.). 95 */ 96 InputManager::~InputManager() 97 { 98 _destroy(); 99 } 100 101 /** 102 @brief 93 103 The one instance of the InputManager is stored in this function. 104 Only for internal use. Public Interface ist static. 94 105 @return 95 106 A reference to the only instance of the InputManager … … 99 110 static InputManager theOnlyInstance; 100 111 return theOnlyInstance; 101 }102 103 /**104 @brief105 Destructor only called at the end of the program, after main.106 */107 InputManager::~InputManager()108 {109 _destroy();110 112 } 111 113 … … 133 135 { 134 136 CCOUT(3) << "Initialising Input System..." << std::endl; 135 CCOUT( ORX_DEBUG) << "Initialising OIS components..." << std::endl;137 CCOUT(4) << "Initialising OIS components..." << std::endl; 136 138 137 139 OIS::ParamList paramList; … … 180 182 CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl; 181 183 182 // InputManager holds the input buffer --> create one and add it.183 //buffer_ = new InputBuffer();184 //addKeyHandler(buffer_, "buffer");185 //Shell::getInstance().setInputBuffer(buffer_);186 187 184 setConfigValues(); 188 185 … … 204 201 _updateActiveStates(); 205 202 206 CCOUT( ORX_DEBUG) << "Initialising complete." << std::endl;203 CCOUT(3) << "Initialising complete." << std::endl; 207 204 } 208 205 else 209 206 { 210 CCOUT( ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;207 CCOUT(2) << "Warning: OIS compoments already initialised, skipping" << std::endl; 211 208 } 212 209 return true; … … 333 330 } 334 331 332 /** 333 @brief 334 Sets the size of all the different lists that are dependent on the number 335 of joy stick devices created. 336 @remarks 337 No matter whether there are a mouse and/or keyboard, they will always 338 occupy 2 places in the device number dependent lists. 339 */ 335 340 void InputManager::_redimensionLists() 336 341 { … … 356 361 activeStatesTop_.resize(devicesNum_); 357 362 358 // inform all registeredstates363 // inform all states 359 364 for (std::map<int, InputState*>::const_iterator it = inputStatesByPriority_.begin(); 360 365 it != inputStatesByPriority_.end(); ++it) … … 364 369 /** 365 370 @brief 366 Sets the configurable values. Use keybindings.ini as file.. 371 Sets the configurable values. 372 This mainly concerns joy stick calibrations. 367 373 */ 368 374 void InputManager::setConfigValues() 369 375 { 370 if (joySticksSize_ )376 if (joySticksSize_ > 0) 371 377 { 372 378 std::vector<MultiTypeMath> coeffPos; … … 386 392 if (!cont) 387 393 { 388 cont = new ConfigValueContainer(CFT_ Keybindings, getIdentifier(), "CoeffPos", coeffPos);394 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), "CoeffPos", coeffPos); 389 395 getIdentifier()->addConfigValueContainer("CoeffPos", cont); 390 396 } … … 394 400 if (!cont) 395 401 { 396 cont = new ConfigValueContainer(CFT_ Keybindings, getIdentifier(), "CoeffNeg", coeffNeg);402 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), "CoeffNeg", coeffNeg); 397 403 getIdentifier()->addConfigValueContainer("CoeffNeg", cont); 398 404 } … … 402 408 if (!cont) 403 409 { 404 cont = new ConfigValueContainer(CFT_ Keybindings, getIdentifier(), "Zero", zero);410 cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), "Zero", zero); 405 411 getIdentifier()->addConfigValueContainer("Zero", cont); 406 412 } … … 425 431 /** 426 432 @brief 427 Destroys all the created input devices and sets the InputManager to construction state. 433 Destroys all the created input devices. InputManager will be ready for a 434 new initialisation. 428 435 */ 429 436 void InputManager::_destroy() … … 431 438 if (inputSystem_) 432 439 { 433 CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl; 434 435 // kick all active states 'nicely' 436 for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin(); 437 rit != activeStates_.rend(); ++rit) 438 (*rit).second->onLeave(); 439 activeStates_.clear(); 440 441 // destroy our own states 442 stateEmpty_->removeAndDestroyAllHandlers(); 443 stateCalibrator_->removeAndDestroyAllHandlers(); 444 stateDetector_->removeAndDestroyAllHandlers(); 445 _destroyState(stateEmpty_); 446 _destroyState(stateCalibrator_); 447 _destroyState(stateDetector_); 448 stateEmpty_ = 0; 449 stateCalibrator_ = 0; 450 stateDetector_ = 0; 451 452 // we don't remove the other states yet because the singleton might still exist. 453 // So people can still removeAndDestroy their states 454 //inputStatesByName_.clear(); 455 //inputStatesByPriority_.clear(); 456 457 // destroy the devices 458 _destroyKeyboard(); 459 _destroyMouse(); 460 _destroyJoySticks(); 461 462 _redimensionLists(); 463 464 OIS::InputManager::destroyInputSystem(inputSystem_); 465 inputSystem_ = 0; 466 467 CCOUT(ORX_DEBUG) << "Destroying done." << std::endl; 440 try 441 { 442 CCOUT(3) << "Destroying ..." << std::endl; 443 444 // clear our own states 445 stateEmpty_->removeAndDestroyAllHandlers(); 446 stateCalibrator_->removeAndDestroyAllHandlers(); 447 stateDetector_->removeAndDestroyAllHandlers(); 448 449 // kick all active states 'nicely' 450 for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin(); 451 rit != activeStates_.rend(); ++rit) 452 { 453 (*rit).second->onLeave(); 454 } 455 activeStates_.clear(); 456 _updateActiveStates(); 457 458 // destroy all input states 459 while (inputStatesByPriority_.size() > 0) 460 { 461 _destroyState((*inputStatesByPriority_.rbegin()).second); 462 } 463 464 stateEmpty_ = 0; 465 stateCalibrator_ = 0; 466 stateDetector_ = 0; 467 468 // destroy the devices 469 _destroyKeyboard(); 470 _destroyMouse(); 471 _destroyJoySticks(); 472 473 // 0 joy sticks now 474 _redimensionLists(); 475 476 OIS::InputManager::destroyInputSystem(inputSystem_); 477 inputSystem_ = 0; 478 479 CCOUT(3) << "Destroying done." << std::endl; 480 } 481 catch (OIS::Exception& ex) 482 { 483 CCOUT(1) << "An exception has occured while destroying:\n" << ex.what() << std::endl; 484 } 468 485 } 469 486 } … … 479 496 keyboard_ = 0; 480 497 keysDown_.clear(); 481 CCOUT( ORX_DEBUG) << "Keyboard destroyed." << std::endl;498 CCOUT(4) << "Keyboard destroyed." << std::endl; 482 499 } 483 500 … … 492 509 mouse_ = 0; 493 510 mouseButtonsDown_.clear(); 494 CCOUT( ORX_DEBUG) << "Mouse destroyed." << std::endl;511 CCOUT(4) << "Mouse destroyed." << std::endl; 495 512 } 496 513 … … 510 527 joySticks_.clear(); 511 528 } 512 CCOUT( ORX_DEBUG) << "Joy sticks destroyed." << std::endl;529 CCOUT(4) << "Joy sticks destroyed." << std::endl; 513 530 } 514 531 … … 597 614 } 598 615 616 /** 617 @brief 618 Updates the currently active states (according to activeStates_) for each device. 619 Also, a list of all active states (no duplicates!) is compiled for the general tick. 620 */ 599 621 void InputManager::_updateActiveStates() 600 622 { … … 616 638 } 617 639 640 /** 641 @brief 642 Processes the accumultated data for the joy stick calibration. 643 */ 618 644 void InputManager::_completeCalibration() 619 645 { … … 676 702 // restore old input state 677 703 requestLeaveState("calibrator"); 704 bCalibrating_ = false; 678 705 } 679 706 … … 822 849 // ###### Joy Stick Events ###### 823 850 851 /** 852 @brief 853 Returns the joy stick ID (orxonox) according to a OIS::JoyStickEvent 854 */ 824 855 inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg) 825 856 { … … 839 870 840 871 // check whether the button already is in the list (can happen when focus was lost) 841 std::vector< int>& buttonsDown = joyStickButtonsDown_[iJoyStick];872 std::vector<JoyStickButton::Enum>& buttonsDown = joyStickButtonsDown_[iJoyStick]; 842 873 unsigned int iButton = 0; 843 874 while (iButton < buttonsDown.size() && buttonsDown[iButton] != button) 844 875 iButton++; 845 876 if (iButton == buttonsDown.size()) 846 buttonsDown.push_back( button);847 848 activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, button);877 buttonsDown.push_back((JoyStickButton::Enum)button); 878 879 activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, (JoyStickButton::Enum)button); 849 880 850 881 return true; … … 856 887 857 888 // remove the button from the joyStickButtonsDown_ list 858 std::vector< int>& buttonsDown = joyStickButtonsDown_[iJoyStick];889 std::vector<JoyStickButton::Enum>& buttonsDown = joyStickButtonsDown_[iJoyStick]; 859 890 for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++) 860 891 { … … 866 897 } 867 898 868 activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, button);899 activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, (JoyStickButton::Enum)button); 869 900 870 901 return true; 871 902 } 872 903 904 /** 905 @brief 906 Calls the states for a particular axis with our enumeration. 907 Used by OIS sliders and OIS axes. 908 */ 873 909 void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value) 874 910 { … … 919 955 920 956 // translate the POV into 8 simple buttons 957 921 958 int lastState = povStates_[iJoyStick][id]; 922 959 if (lastState & OIS::Pov::North) … … 959 996 } 960 997 961 bool InputManager::initialiseKeyboard()962 {963 return _getInstance()._initialiseKeyboard();964 }965 966 bool InputManager::initialiseMouse()967 {968 return _getInstance()._initialiseMouse();969 }970 971 bool InputManager::initialiseJoySticks()972 {973 return _getInstance()._initialiseJoySticks();974 }975 976 998 int InputManager::numberOfKeyboards() 977 999 { … … 1030 1052 { 1031 1053 _getInstance()._destroy(); 1032 }1033 1034 void InputManager::destroyKeyboard()1035 {1036 return _getInstance()._destroyKeyboard();1037 }1038 1039 void InputManager::destroyMouse()1040 {1041 return _getInstance()._destroyMouse();1042 }1043 1044 void InputManager::destroyJoySticks()1045 {1046 return _getInstance()._destroyJoySticks();1047 1054 } 1048 1055 … … 1068 1075 } 1069 1076 1077 /** 1078 @brief 1079 Method for easily storing a string with the command executor. It is used by the 1080 KeyDetector to get assign commands. The KeyDetector simply executes 1081 the command 'storeKeyStroke myName' for each button/axis. 1082 @remarks 1083 This is only a temporary hack until we thourouhgly support multiple KeyBinders. 1084 @param name 1085 The name of the button/axis. 1086 */ 1070 1087 void InputManager::storeKeyStroke(const std::string& name) 1071 1088 { … … 1075 1092 } 1076 1093 1094 /** 1095 @brief 1096 Assigns a command string to a key/button/axis. The name is determined via KeyDetector 1097 and InputManager::storeKeyStroke(.). 1098 @param command 1099 Command string that can be executed by the CommandExecutor 1100 */ 1077 1101 void InputManager::keyBind(const std::string& command) 1078 1102 { … … 1082 1106 } 1083 1107 1108 /** 1109 @brief 1110 Starts joy stick calibration. 1111 */ 1084 1112 void InputManager::calibrate() 1085 1113 { 1114 _getInstance().bCalibrating_ = true; 1086 1115 requestEnterState("calibrator"); 1087 1116 } … … 1101 1130 @param name 1102 1131 Unique name of the handler. 1132 @param priority 1133 Unique integer number. Higher means more prioritised. 1103 1134 @return 1104 True if added, false if name already existed.1135 True if added, false if name or priority already existed. 1105 1136 */ 1106 1137 bool InputManager::_configureInputState(InputState* state, const std::string& name, int priority) … … 1134 1165 } 1135 1166 1167 /** 1168 @brief 1169 Returns a new SimpleInputState and configures it first. 1170 */ 1136 1171 SimpleInputState* InputManager::createSimpleInputState(const std::string &name, int priority) 1137 1172 { … … 1146 1181 } 1147 1182 1183 /** 1184 @brief 1185 Returns a new ExtendedInputState and configures it first. 1186 */ 1148 1187 ExtendedInputState* InputManager::createExtendedInputState(const std::string &name, int priority) 1149 1188 { … … 1160 1199 /** 1161 1200 @brief 1162 Removes a Key handler from the list.1201 Removes an input state internally. 1163 1202 @param name 1164 Unique name of the handler.1203 Name of the handler. 1165 1204 @return 1166 1205 True if removal was successful, false if name was not found. 1206 @remarks 1207 You can't remove the internal states "empty", "calibrator" and "detector". 1167 1208 */ 1168 1209 bool InputManager::destroyState(const std::string& name) … … 1184 1225 /** 1185 1226 @brief 1186 Returns the pointer to a handler.1227 Returns the pointer to the requested InputState. 1187 1228 @param name 1188 Unique name of the handler.1229 Unique name of the state. 1189 1230 @return 1190 1231 Pointer to the instance, 0 if name was not found. … … 1201 1242 /** 1202 1243 @brief 1203 Returns the current input handling method1244 Returns the current input state (there might be others active too!) 1204 1245 @return 1205 The current input mode.1246 The current highest prioritised active input state. 1206 1247 */ 1207 1248 InputState* InputManager::getCurrentState() … … 1212 1253 /** 1213 1254 @brief 1214 Enables a specific key handler that has already been added. 1255 Activates a specific input state. 1256 It might not be really activated if the priority is too low! 1215 1257 @param name 1216 Unique name of the handler.1258 Unique name of the state. 1217 1259 @return 1218 1260 False if name was not found, true otherwise. … … 1230 1272 } 1231 1273 1274 /** 1275 @brief 1276 Deactivates a specific input state. 1277 @param name 1278 Unique name of the state. 1279 @return 1280 False if name was not found, true otherwise. 1281 */ 1232 1282 bool InputManager::requestLeaveState(const std::string& name) 1233 1283 { -
code/branches/gui/src/core/input/InputManager.h
r1638 r1641 90 90 static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight, 91 91 bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false); 92 static bool initialiseKeyboard();93 static bool initialiseMouse();94 static bool initialiseJoySticks();95 92 static int numberOfKeyboards(); 96 93 static int numberOfMice(); … … 98 95 99 96 static void destroy(); 100 static void destroyKeyboard();101 static void destroyMouse();102 static void destroyJoySticks();103 97 104 98 //static bool isModifierDown(KeyboardModifier::Enum modifier); … … 119 113 static ExtendedInputState* createExtendedInputState(const std::string& name, int priority); 120 114 static bool destroyState (const std::string& name); 121 //static bool removeState (const std::string& name);122 115 static InputState* getState (const std::string& name); 123 116 static InputState* getCurrentState(); … … 171 164 172 165 private: // variables 173 OIS::InputManager* inputSystem_;//!< OIS input manager174 OIS::Keyboard* keyboard_;//!< OIS mouse175 OIS::Mouse* mouse_;//!< OIS keyboard176 std::vector<OIS::JoyStick*> joySticks_;//!< OIS joy sticks177 unsigned int 178 unsigned int 166 OIS::InputManager* inputSystem_; //!< OIS input manager 167 OIS::Keyboard* keyboard_; //!< OIS mouse 168 OIS::Mouse* mouse_; //!< OIS keyboard 169 std::vector<OIS::JoyStick*> joySticks_; //!< OIS joy sticks 170 unsigned int joySticksSize_; 171 unsigned int devicesNum_; 179 172 180 173 // some internally handled states 181 SimpleInputState* stateDetector_;//!< KeyDetector instance182 SimpleInputState* 183 SimpleInputState* 184 185 std::map<std::string, InputState*> 186 std::map<int, InputState*> 187 188 std::vector<InputState*> stateEnterRequests_;//!< Request to enter a new state189 std::vector<InputState*> stateLeaveRequests_;//!< Request to leave the current state190 191 std::map<int, InputState*> activeStates_;192 std::vector<InputState*> activeStatesTop_;//!< Current input states for joy stick events.193 std::vector<InputState*> activeStatesTicked_;//!< Current input states for joy stick events.174 SimpleInputState* stateDetector_; //!< KeyDetector instance 175 SimpleInputState* stateCalibrator_; 176 SimpleInputState* stateEmpty_; 177 178 std::map<std::string, InputState*> inputStatesByName_; 179 std::map<int, InputState*> inputStatesByPriority_; 180 181 std::vector<InputState*> stateEnterRequests_; //!< Request to enter a new state 182 std::vector<InputState*> stateLeaveRequests_; //!< Request to leave the current state 183 184 std::map<int, InputState*> activeStates_; 185 std::vector<InputState*> activeStatesTop_; //!< Current input states for joy stick events. 186 std::vector<InputState*> activeStatesTicked_; //!< Current input states for joy stick events. 194 187 195 188 // joystick calibration 196 189 //std::vector<int> marginalsMaxConfig_; 197 190 //std::vector<int> marginalsMinConfig_; 198 int marginalsMax_[24]; 199 int marginalsMin_[24]; 200 bool bCalibrated_; 201 bool bCalibrating_; 202 203 unsigned int keyboardModifiers_; //!< Bit mask representing keyboard modifiers 204 //! Keeps track of the joy stick POV states 205 std::vector<POVStates> povStates_; 206 //! Keeps track of the possibly two slider axes 207 std::vector<SliderStates> sliderStates_; 208 std::vector<JoyStickCalibration> joySticksCalibration_; 209 210 std::vector<Key> keysDown_; 211 std::vector<MouseButton::Enum> mouseButtonsDown_; 212 std::vector<std::vector<int> > joyStickButtonsDown_; 213 214 static std::string bindingCommmandString_s; 191 int marginalsMax_[24]; 192 int marginalsMin_[24]; 193 bool bCalibrated_; 194 bool bCalibrating_; 195 196 unsigned int keyboardModifiers_; //!< Bit mask representing keyboard modifiers. 197 std::vector<POVStates> povStates_; //!< Keeps track of the joy stick POV states. 198 std::vector<SliderStates> sliderStates_; //!< Keeps track of the possibly two slider axes. 199 std::vector<JoyStickCalibration> joySticksCalibration_; 200 201 std::vector<Key> keysDown_; 202 std::vector<MouseButton::Enum> mouseButtonsDown_; 203 std::vector<std::vector<JoyStickButton::Enum> > joyStickButtonsDown_; 204 205 static std::string bindingCommmandString_s; 215 206 }; 216 207 -
code/branches/gui/src/core/input/InputState.h
r1638 r1641 84 84 virtual void mouseScrolled (int abs, int rel) = 0; 85 85 86 virtual void joyStickButtonPressed (unsigned int joyStickID, unsigned int button) = 0;87 virtual void joyStickButtonReleased(unsigned int joyStickID, unsigned int button) = 0;88 virtual void joyStickButtonHeld (unsigned int joyStickID, unsigned int button) = 0;86 virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) = 0; 87 virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) = 0; 88 virtual void joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id) = 0; 89 89 virtual void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value) = 0; 90 90 -
code/branches/gui/src/core/input/KeyBinder.cc
r1638 r1641 374 374 } 375 375 376 void KeyBinder::tickJoyStick(float dt, int device)376 void KeyBinder::tickJoyStick(float dt, unsigned int joyStick) 377 377 { 378 378 tickDevices(8, nHalfAxes_s); … … 448 448 449 449 450 void KeyBinder::joyStickButtonPressed (unsigned int joyStickID, unsigned int button)451 { joyStickButtons_[ button].execute(KeybindMode::OnPress); }452 453 void KeyBinder::joyStickButtonReleased(unsigned int joyStickID, unsigned int button)454 { joyStickButtons_[ button].execute(KeybindMode::OnRelease); }455 456 void KeyBinder::joyStickButtonHeld (unsigned int joyStickID, unsigned int button)457 { joyStickButtons_[ button].execute(KeybindMode::OnHold); }450 void KeyBinder::joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) 451 { joyStickButtons_[id].execute(KeybindMode::OnPress); } 452 453 void KeyBinder::joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) 454 { joyStickButtons_[id].execute(KeybindMode::OnRelease); } 455 456 void KeyBinder::joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id) 457 { joyStickButtons_[id].execute(KeybindMode::OnHold); } 458 458 459 459 /** -
code/branches/gui/src/core/input/KeyBinder.h
r1638 r1641 68 68 void tickKey(float dt) { } 69 69 void tickMouse(float dt); 70 void tickJoyStick(float dt, int device);70 void tickJoyStick(float dt, unsigned int joyStick); 71 71 void tickDevices(unsigned int begin, unsigned int end); 72 72 … … 83 83 void mouseScrolled (int abs, int rel); 84 84 85 void joyStickButtonPressed (unsigned int joyStickID, unsigned int button);86 void joyStickButtonReleased(unsigned int joyStickID, unsigned int button);87 void joyStickButtonHeld (unsigned int joyStickID, unsigned int button);85 void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id); 86 void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id); 87 void joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id); 88 88 void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value); 89 89 -
code/branches/gui/src/core/input/SimpleInputState.cc
r1638 r1641 123 123 } 124 124 125 void SimpleInputState::joyStickButtonPressed(unsigned int joyStickID, unsigned int button)126 { 127 assert(joyStickID < joyStickHandler_.size()); 128 if (joyStickHandler_[joyStickID]) 129 joyStickHandler_[joyStickID]->joyStickButtonPressed(joyStickID, button);130 } 131 132 void SimpleInputState::joyStickButtonReleased(unsigned int joyStickID, unsigned int button)133 { 134 assert(joyStickID < joyStickHandler_.size()); 135 if (joyStickHandler_[joyStickID]) 136 joyStickHandler_[joyStickID]->joyStickButtonReleased(joyStickID, button);137 } 138 139 void SimpleInputState::joyStickButtonHeld(unsigned int joyStickID, unsigned int button)140 { 141 assert(joyStickID < joyStickHandler_.size()); 142 if (joyStickHandler_[joyStickID]) 143 joyStickHandler_[joyStickID]->joyStickButtonHeld(joyStickID, button);125 void SimpleInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButton::Enum id) 126 { 127 assert(joyStickID < joyStickHandler_.size()); 128 if (joyStickHandler_[joyStickID]) 129 joyStickHandler_[joyStickID]->joyStickButtonPressed(joyStickID, id); 130 } 131 132 void SimpleInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) 133 { 134 assert(joyStickID < joyStickHandler_.size()); 135 if (joyStickHandler_[joyStickID]) 136 joyStickHandler_[joyStickID]->joyStickButtonReleased(joyStickID, id); 137 } 138 139 void SimpleInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButton::Enum id) 140 { 141 assert(joyStickID < joyStickHandler_.size()); 142 if (joyStickHandler_[joyStickID]) 143 joyStickHandler_[joyStickID]->joyStickButtonHeld(joyStickID, id); 144 144 } 145 145 -
code/branches/gui/src/core/input/SimpleInputState.h
r1638 r1641 72 72 void mouseScrolled (int abs, int rel); 73 73 74 void joyStickButtonPressed (unsigned int joyStickID, unsigned int button);75 void joyStickButtonReleased(unsigned int joyStickID, unsigned int button);76 void joyStickButtonHeld (unsigned int joyStickID, unsigned int button);74 void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id); 75 void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id); 76 void joyStickButtonHeld (unsigned int joyStickID, JoyStickButton::Enum id); 77 77 void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value); 78 78 -
code/branches/gui/src/orxonox/GraphicsEngine.cc
r1640 r1641 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 24 25 * Co-authors: 25 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007,Felix Schulthess26 * Felix Schulthess 26 27 * 27 28 */ … … 89 90 RegisterObject(GraphicsEngine); 90 91 92 assert(singletonRef_s == 0); 91 93 singletonRef_s = this; 92 94 … … 305 307 //Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); 306 308 307 // create a full screen viewport in which to render the scene and the loading screen 308 // The GUI uses its own one to be able to render on top of everything. 309 // That explains why the Z order here is only 1 and not 0 (top most) 310 this->viewport_ = this->renderWindow_->addViewport(0, 1); 309 // create a full screen viewport 310 this->viewport_ = this->renderWindow_->addViewport(0, 0); 311 311 312 312 return true; -
code/branches/gui/src/orxonox/GraphicsEngine.h
r1640 r1641 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 24 25 * Co-authors: 25 * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007,Felix Schulthess26 * Felix Schulthess 26 27 * 27 28 */ … … 88 89 89 90 static GraphicsEngine& getSingleton(); 90 static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }91 static GraphicsEngine* getSingletonPtr() { return singletonRef_s; } 91 92 92 93 private: -
code/branches/gui/src/orxonox/Orxonox.cc
r1640 r1641 300 300 } 301 301 302 void Orxonox::loadGame(const std::string& name)302 /*static*/ void Orxonox::loadGame(const std::string& name) 303 303 { 304 304 const GameMode& mode = Settings::getGameMode(name); -
code/branches/gui/src/orxonox/gui/GUIManager.h
r1640 r1641 103 103 104 104 void tickInput(float dt) { } 105 void tickKey(float dt) { } 106 void tickMouse(float dt) { } 105 107 106 108 void loadScenes(); -
code/branches/gui/src/orxonox/gui/OgreCEGUIRenderer.cpp
r1638 r1641 191 191 // GUI (uses its own viewport to be able render on top of all viewports). 192 192 // But since we don't use overlays in the GUI, it doesn't matter. 193 //if (d_render_sys->_getViewport()->getOverlaysEnabled() && !d_quadlist.empty()) 194 if (!d_quadlist.empty()) 193 // ORXONOX REVERT: Changes are not in place anymore, but might be in the future! 194 if (d_render_sys->_getViewport()->getOverlaysEnabled() && !d_quadlist.empty()) 195 //if (!d_quadlist.empty()) 195 196 { 196 197 /// Quad list needs to be sorted and thus the vertex buffer rebuilt. If not, we can … … 493 494 // GUI (uses its own viewport to be able render on top of all viewports). 494 495 // But since we don't use overlays in the GUI, it doesn't matter. 495 //if (d_render_sys->_getViewport()->getOverlaysEnabled()) 496 if (true) 496 // ORXONOX REVERT: Changes are not in place anymore, but might be in the future! 497 if (d_render_sys->_getViewport()->getOverlaysEnabled()) 498 //if (true) 497 499 { 498 500 z = -1 + z; -
code/branches/gui/src/orxonox/overlays/console/InGameConsole.cc
r1638 r1641 46 46 #include "core/ConsoleCommand.h" 47 47 #include "core/input/InputManager.h" 48 #include "core/input/SimpleInputState.h" 49 #include "core/input/InputBuffer.h" 48 50 #include "GraphicsEngine.h" 49 51 … … 66 68 , consoleOverlayBorder_(0) 67 69 , consoleOverlayTextAreas_(0) 68 , emptySceneManager_(0)69 , emptyCamera_(0)70 , viewport_(0)71 70 { 72 71 RegisterObject(InGameConsole); … … 118 117 void InGameConsole::initialise() 119 118 { 119 // create the corresponding input state 120 InputManager::createSimpleInputState("console", 40)->setKeyHandler(Shell::getInstance().getInputBuffer()); 121 120 122 // create overlay and elements 121 123 Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); … … 195 197 Shell::getInstance().addOutputLevel(true); 196 198 197 // create a sceneManager in order to render in our own viewport198 this->emptySceneManager_ = Ogre::Root::getSingleton()199 .createSceneManager(Ogre::ST_GENERIC, "Console/EmptySceneManager");200 this->emptyCamera_ = this->emptySceneManager_->createCamera("Console/EmptyCamera");201 this->viewport_ = GraphicsEngine::getSingleton().getRenderWindow()->addViewport(emptyCamera_, 10);202 this->viewport_->setOverlaysEnabled(true);203 this->viewport_->setClearEveryFrame(false);204 205 199 COUT(4) << "Info: InGameConsole initialized" << std::endl; 206 200 } … … 211 205 void InGameConsole::destroy() 212 206 { 207 this->deactivate(); 208 209 // destroy the input state previously created 210 SimpleInputState * inputState = dynamic_cast<SimpleInputState*>(InputManager::getState("console")); 211 if (inputState) 212 InputManager::destroyState("console"); 213 213 214 Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); 214 215 if (ovMan) … … 467 468 if (output.size() > this->maxCharsPerLine_) 468 469 { 469 if (Shell::getInstance().getInputBuffer() .getCursorPosition() < this->inputWindowStart_)470 this->inputWindowStart_ = Shell::getInstance().getInputBuffer() .getCursorPosition();471 else if (Shell::getInstance().getInputBuffer() .getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))472 this->inputWindowStart_ = Shell::getInstance().getInputBuffer() .getCursorPosition() - this->maxCharsPerLine_ + 1;470 if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_) 471 this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition(); 472 else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1)) 473 this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1; 473 474 474 475 output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_); -
code/branches/gui/src/orxonox/overlays/console/InGameConsole.h
r1638 r1641 100 100 Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_; 101 101 102 Ogre::SceneManager* emptySceneManager_; //!< dummy SceneManager to render overlays in empty windows103 Ogre::Camera* emptyCamera_; //!< dummy camera to render overlays in empty windows104 Ogre::Viewport* viewport_;105 106 102 // config values 107 103 float relativeWidth;
Note: See TracChangeset
for help on using the changeset viewer.