Changeset 2543 for code/branches/presentation/src
- Timestamp:
- Dec 28, 2008, 11:56:31 PM (16 years ago)
- Location:
- code/branches/presentation/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/core/ConfigFileManager.cc
r2103 r2543 160 160 if ((*it)->getIndex() > size) 161 161 size = (*it)->getIndex(); 162 return (size + 1); 162 if (size == 0) 163 return 0; 164 else 165 return (size + 1); 163 166 } 164 167 -
code/branches/presentation/src/core/ConfigValueContainer.cc
r2171 r2543 273 273 { 274 274 this->valueVector_.clear(); 275 for (unsigned int i = 0; i < ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); i++) 275 unsigned int vectorSize = ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); 276 for (unsigned int i = 0; i < vectorSize; i++) 276 277 { 277 278 if (i < this->defvalueStringVector_.size()) -
code/branches/presentation/src/core/ConfigValueContainer.h
r2171 r2543 109 109 { 110 110 this->init(type, identifier, sectionname, varname); 111 this->initValue( (V)defvalue);111 this->initValue(static_cast<V>(defvalue)); 112 112 } 113 113 … … 217 217 inline const std::string& getName() const 218 218 { return this->varname_; } 219 /** @brief Retuns the name of the section this config value is in. */ 220 inline const std::string& getSectionName() const 221 { return this->sectionname_; } 219 222 /** @brief Returns true if this config-value is a vector */ 220 223 inline bool isVector() const -
code/branches/presentation/src/core/input/Button.cc
r2485 r2543 63 63 } 64 64 65 Button::~Button() 66 { 67 this->clear(); 68 69 if (this->configContainer_) 70 delete this->configContainer_; 71 } 72 65 73 void Button::clear() 66 74 { … … 81 89 } 82 90 } 83 84 if (this->configContainer_)85 delete this->configContainer_;86 this->configContainer_ = 0;87 91 } 88 92 -
code/branches/presentation/src/core/input/Button.h
r2103 r2543 49 49 public: 50 50 Button(); 51 virtual ~Button() { clear(); }51 virtual ~Button(); 52 52 virtual void clear(); 53 53 virtual bool addParamCommand(ParamCommand* command) { return false; } -
code/branches/presentation/src/core/input/InputInterfaces.h
r1887 r2543 378 378 const char* const ByString[] = 379 379 { 380 "Button0 ", "Button1", "Button2", "Button3",381 "Button 4", "Button5", "Button6", "Button7",382 "Button 8", "Button9","Button10", "Button11",380 "Button00", "Button01", "Button02", "Button03", 381 "Button04", "Button05", "Button06", "Button07", 382 "Button08", "Button09", "Button10", "Button11", 383 383 "Button12", "Button13", "Button14", "Button15", 384 384 "Button16", "Button17", "Button18", "Button19", … … 416 416 "Slider0", "Slider1", "Slider2", "Slider3", 417 417 "Slider4", "Slider5", "Slider6", "Slider7", 418 "Axis0 ", "Axis1", "Axis2", "Axis3",419 "Axis 4", "Axis5", "Axis6", "Axis7",420 "Axis 8", "Axis9","Axis10", "Axis11",418 "Axis00", "Axis01", "Axis02", "Axis03", 419 "Axis04", "Axis05", "Axis06", "Axis07", 420 "Axis08", "Axis09", "Axis10", "Axis11", 421 421 "Axis12", "Axis13", "Axis14", "Axis15" 422 422 }; -
code/branches/presentation/src/core/input/InputManager.cc
r2103 r2543 65 65 SetCommandLineSwitch(keyboard_no_grab); 66 66 67 std::string InputManager::bindingCommmandString_s = "";68 67 EmptyHandler InputManager::EMPTY_HANDLER; 69 68 InputManager* InputManager::singletonRef_s = 0; … … 174 173 if (joyStickSupport) 175 174 _initialiseJoySticks(); 176 // Do this anyway to also inform every one ifa joystick was detached.175 // Do this anyway to also inform everything when a joystick was detached. 177 176 _configureNumberOfJoySticks(); 178 177 … … 492 491 } 493 492 } 494 singletonRef_s = 0; 493 494 singletonRef_s = 0; 495 495 } 496 496 … … 660 660 /** 661 661 @brief 662 Updates the InputManager. Tick is called by the Core class.662 Updates the states and the InputState situation. 663 663 @param dt 664 664 Delta time … … 676 676 677 677 // check for states to leave 678 for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin(); 679 rit != stateLeaveRequests_.rend(); ++rit) 680 { 681 (*rit)->onLeave(); 682 // just to be sure that the state actually is registered 683 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 684 685 activeStates_.erase((*rit)->getPriority()); 686 _updateActiveStates(); 687 } 688 stateLeaveRequests_.clear(); 678 if (!stateLeaveRequests_.empty()) 679 { 680 for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin(); 681 rit != stateLeaveRequests_.rend(); ++rit) 682 { 683 (*rit)->onLeave(); 684 // just to be sure that the state actually is registered 685 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 686 687 activeStates_.erase((*rit)->getPriority()); 688 _updateActiveStates(); 689 } 690 stateLeaveRequests_.clear(); 691 } 689 692 690 693 // check for states to enter 691 for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin(); 692 rit != stateEnterRequests_.rend(); ++rit) 693 { 694 // just to be sure that the state actually is registered 695 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 696 697 activeStates_[(*rit)->getPriority()] = (*rit); 698 _updateActiveStates(); 699 (*rit)->onEnter(); 700 } 701 stateEnterRequests_.clear(); 694 if (!stateEnterRequests_.empty()) 695 { 696 for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin(); 697 rit != stateEnterRequests_.rend(); ++rit) 698 { 699 // just to be sure that the state actually is registered 700 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 701 702 activeStates_[(*rit)->getPriority()] = (*rit); 703 _updateActiveStates(); 704 (*rit)->onEnter(); 705 } 706 stateEnterRequests_.clear(); 707 } 702 708 703 709 // check for states to destroy 704 for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin(); 705 rit != stateDestroyRequests_.rend(); ++rit) 706 { 707 _destroyState((*rit)); 708 } 709 stateDestroyRequests_.clear(); 710 if (!stateDestroyRequests_.empty()) 711 { 712 for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin(); 713 rit != stateDestroyRequests_.rend(); ++rit) 714 { 715 _destroyState((*rit)); 716 } 717 stateDestroyRequests_.clear(); 718 } 710 719 711 720 // check whether a state has changed its EMPTY_HANDLER situation … … 1124 1133 1125 1134 // keep in mind that the first 8 axes are reserved for the sliders 1126 _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);1135 _fireAxis(iJoyStick, axis + sliderAxes, arg.state.mAxes[axis].abs); 1127 1136 1128 1137 return true; -
code/branches/presentation/src/core/input/InputManager.h
r2102 r2543 136 136 public: // variables 137 137 static EmptyHandler EMPTY_HANDLER; 138 static const unsigned int sliderAxes = 8; 138 139 139 140 private: // functions … … 192 193 SimpleInputState* stateEmpty_; 193 194 ExtendedInputState* stateMaster_; //!< Always active master input state 194 KeyDetector* keyDetector_; //!< KeyDetector instance195 KeyDetector* keyDetector_; //!< KeyDetector instance 195 196 InputBuffer* calibratorCallbackBuffer_; 196 197 … … 223 224 std::vector<std::vector<JoyStickButtonCode::ByEnum> > joyStickButtonsDown_; 224 225 225 static std::string bindingCommmandString_s; 226 226 227 static InputManager* singletonRef_s; 227 228 }; -
code/branches/presentation/src/core/input/KeyBinder.cc
r2103 r2543 33 33 34 34 #include "KeyBinder.h" 35 35 36 #include <fstream> 36 37 #include <string> 38 37 39 #include "util/Convert.h" 38 40 #include "util/Debug.h" … … 66 68 std::string keyname = KeyCode::ByString[i]; 67 69 if (!keyname.empty()) 68 {69 70 keys_[i].name_ = std::string("Key") + keyname; 70 }71 71 else 72 { 73 // some keys have name "" because the code is not occupied by OIS 74 // Use "Key_" plus the number as name to put it at the end of the config file section 75 std::string number = convertToString(i); 76 if (i < 100) 77 number.insert(0, "0"); 78 keys_[i].name_ = std::string("Key_") + number; 79 } 72 keys_[i].name_ = ""; 80 73 keys_[i].paramCommandBuffer_ = ¶mCommandBuffer_; 81 74 keys_[i].groupName_ = "Keys"; … … 97 90 for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++) 98 91 { 99 mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i >> 1];92 mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i / 2]; 100 93 if (i & 1) 101 94 mouseAxes_[i].name_ += "Pos"; … … 224 217 allHalfAxes_.clear(); 225 218 219 // Note: Don't include the dummy keys which don't actually exist in OIS but have a number 226 220 for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++) 227 allButtons_[keys_[i].name_] = keys_ + i; 221 if (!keys_[i].name_.empty()) 222 allButtons_[keys_[i].name_] = keys_ + i; 228 223 for (unsigned int i = 0; i < numberOfMouseButtons_; i++) 229 224 allButtons_[mouseButtons_[i].name_] = mouseButtons_ + i; … … 327 322 if (bDeriveMouseInput_) 328 323 { 329 // only update when deriv edt has passed324 // only update when derivation dt has passed 330 325 if (deriveTime_ > derivePeriod_) 331 326 { 332 327 for (int i = 0; i < 2; i++) 333 328 { 334 if (mouseRelative_[i] >0)329 if (mouseRelative_[i] < 0) 335 330 { 336 331 mouseAxes_[2*i + 0].absVal_ 337 = 332 = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_; 338 333 mouseAxes_[2*i + 1].absVal_ = 0.0f; 339 334 } 340 else if (mouseRelative_[i] <0)335 else if (mouseRelative_[i] > 0) 341 336 { 342 337 mouseAxes_[2*i + 0].absVal_ = 0.0f; 343 338 mouseAxes_[2*i + 1].absVal_ 344 = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;339 = mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_; 345 340 } 346 341 else … … 363 358 // Why dividing relative value by dt? The reason lies in the simple fact, that when you 364 359 // press a button that has relative movement, that value has to be multiplied by dt to be 365 // frame rate independ ant. This can easily (and only) be done in tickInput(float).360 // frame rate independent. This can easily (and only) be done in tickInput(float). 366 361 // Hence we need to divide by dt here for the mouse to compensate, because the relative 367 362 // move movements have nothing to do with dt. … … 441 436 for (int i = 0; i < 2; i++) 442 437 { 443 if (rel[i]) // performance opt. ifrel[i] == 0438 if (rel[i]) // performance opt. for the case that rel[i] == 0 444 439 { 445 440 // write absolute values … … 454 449 mousePosition_[i] = -mouseClippingSize_; 455 450 456 if (mousePosition_[i] >=0)451 if (mousePosition_[i] < 0) 457 452 { 458 mouseAxes_[2*i + 0].absVal_ = 453 mouseAxes_[2*i + 0].absVal_ = -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_; 459 454 mouseAxes_[2*i + 1].absVal_ = 0.0f; 460 455 } … … 462 457 { 463 458 mouseAxes_[2*i + 0].absVal_ = 0.0f; 464 mouseAxes_[2*i + 1].absVal_ = -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;459 mouseAxes_[2*i + 1].absVal_ = mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_; 465 460 } 466 461 } … … 471 466 for (int i = 0; i < 2; i++) 472 467 { 473 if (rel[i] >0)474 mouseAxes_[0 + 2*i].relVal_ = 468 if (rel[i] < 0) 469 mouseAxes_[0 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_; 475 470 else 476 mouseAxes_[1 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;471 mouseAxes_[1 + 2*i].relVal_ = ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_; 477 472 } 478 473 } … … 484 479 void KeyBinder::mouseScrolled(int abs, int rel) 485 480 { 486 if (rel >0)487 for (int i = 0; i < rel/mouseWheelStepSize_; i++)481 if (rel < 0) 482 for (int i = 0; i < -rel/mouseWheelStepSize_; i++) 488 483 mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_); 489 484 else 490 for (int i = 0; i < -rel/mouseWheelStepSize_; i++)485 for (int i = 0; i < rel/mouseWheelStepSize_; i++) 491 486 mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_); 492 487 } … … 495 490 { 496 491 int i = axis * 2; 497 if (value >=0)498 { 499 joyStickAxes_[joyStickID][i].absVal_ = value;500 joyStickAxes_[joyStickID][i].relVal_ = value;492 if (value < 0) 493 { 494 joyStickAxes_[joyStickID][i].absVal_ = -value; 495 joyStickAxes_[joyStickID][i].relVal_ = -value; 501 496 joyStickAxes_[joyStickID][i].hasChanged_ = true; 502 497 if (joyStickAxes_[joyStickID][i + 1].absVal_ > 0.0f) … … 509 504 else 510 505 { 511 joyStickAxes_[joyStickID][i + 1].absVal_ = -value;512 joyStickAxes_[joyStickID][i + 1].relVal_ = -value;506 joyStickAxes_[joyStickID][i + 1].absVal_ = value; 507 joyStickAxes_[joyStickID][i + 1].relVal_ = value; 513 508 joyStickAxes_[joyStickID][i + 1].hasChanged_ = true; 514 509 if (joyStickAxes_[joyStickID][i].absVal_ > 0.0f) -
code/branches/presentation/src/core/input/KeyBinder.h
r2103 r2543 39 39 40 40 #include <vector> 41 #include <cassert> 42 41 43 #include "InputInterfaces.h" 42 44 #include "Button.h" … … 44 46 #include "InputCommands.h" 45 47 #include "JoyStickDeviceNumberListener.h" 46 #include "core/ConfigFileManager.h"47 48 48 49 namespace orxonox … … 171 172 172 173 inline void KeyBinder::keyPressed (const KeyEvent& evt) 173 { keys_[evt.key].execute(KeybindMode::OnPress); }174 { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnPress); } 174 175 175 176 inline void KeyBinder::keyReleased(const KeyEvent& evt) 176 { keys_[evt.key].execute(KeybindMode::OnRelease); }177 { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnRelease); } 177 178 178 179 inline void KeyBinder::keyHeld (const KeyEvent& evt) 179 { keys_[evt.key].execute(KeybindMode::OnHold); }180 { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnHold); } 180 181 181 182 -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2500 r2543 160 160 void SpaceShip::rotateYaw(const Vector2& value) 161 161 { 162 this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() +value.x);162 this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x); 163 163 164 164 Pawn::rotateYaw(value); -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2493 r2543 177 177 void Spectator::rotateYaw(const Vector2& value) 178 178 { 179 this->yaw_ += value.y;179 this->yaw_ -= value.y; 180 180 181 181 ControllableEntity::rotateYaw(value);
Note: See TracChangeset
for help on using the changeset viewer.