Changeset 3288 for code/branches/core4/src/core
- Timestamp:
- Jul 13, 2009, 10:43:59 PM (15 years ago)
- Location:
- code/branches/core4/src/core/input
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/input/InputManager.cc
r3286 r3288 260 260 261 261 // inform all JoyStick Device Number Listeners 262 for (ObjectList<JoyStickQuantityListener>::iterator it = ObjectList<JoyStickQuantityListener>::begin(); it; ++it) 263 it->JoyStickQuantityChanged(devices_.size() - InputDeviceEnumerator::FirstJoyStick); 262 std::vector<JoyStick*> joyStickList; 263 for (unsigned int i = InputDeviceEnumerator::FirstJoyStick; i < devices_.size(); ++i) 264 joyStickList.push_back(static_cast<JoyStick*>(devices_[i])); 265 JoyStickQuantityListener::changeJoyStickQuantity(joyStickList); 264 266 } 265 267 … … 572 574 if (statesByName_.find(name) == statesByName_.end()) 573 575 { 574 InputState* state = new InputState;575 576 if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty) 576 577 { … … 583 584 COUT(2) << "Warning: Could not add an InputState with the same priority '" 584 585 << static_cast<int>(priority) << "' != 0." << std::endl; 585 return false;586 return 0; 586 587 } 587 588 } 588 589 } 590 InputState* state = new InputState(name, bAlwaysGetsInput, bTransparent, priority); 589 591 statesByName_[name] = state; 590 state->JoyStickQuantityChanged(devices_.size() - InputDeviceEnumerator::FirstJoyStick);591 state->setName(name);592 state->bAlwaysGetsInput_ = bAlwaysGetsInput;593 state->bTransparent_ = bTransparent;594 if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)595 state->setPriority(priority);596 592 597 593 return state; -
code/branches/core4/src/core/input/InputState.cc
r3274 r3288 32 32 namespace orxonox 33 33 { 34 InputState::InputState( )35 : priority_(0)36 , bAlwaysGetsInput_( false)37 , bTransparent_( false)34 InputState::InputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority) 35 : name_(name) 36 , bAlwaysGetsInput_(bAlwaysGetsInput) 37 , bTransparent_(bTransparent) 38 38 , bExpired_(true) 39 39 , handlers_(2) … … 42 42 , leaveFunctor_(0) 43 43 { 44 if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty) 45 priority_ = priority; 46 else 47 priority_ = 0; 48 49 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + JoyStickQuantityListener::getJoyStickList().size(), NULL); 44 50 } 45 51 … … 52 58 } 53 59 54 void InputState::JoyStickQuantityChanged( unsigned int n)60 void InputState::JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) 55 61 { 56 62 unsigned int oldSize = handlers_.size(); 57 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + n, NULL);63 handlers_.resize(InputDeviceEnumerator::FirstJoyStick + joyStickList.size(), NULL); 58 64 59 65 for (unsigned int i = oldSize; i < handlers_.size(); ++i) -
code/branches/core4/src/core/input/InputState.h
r3279 r3288 97 97 98 98 private: 99 InputState( );99 InputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority); 100 100 ~InputState() { } 101 101 102 void JoyStickQuantityChanged( unsigned int n);102 void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList); 103 103 104 void setName(const std::string& name) { name_ = name; } 105 void setPriority(int priority) { priority_ = priority; } 104 void setPriority(int priority) { priority_ = priority; } 106 105 107 std::string name_; 106 const std::string name_; 107 const bool bAlwaysGetsInput_; 108 const bool bTransparent_; 108 109 int priority_; 109 bool bAlwaysGetsInput_;110 bool bTransparent_;111 110 bool bExpired_; 112 111 std::vector<InputHandler*> handlers_; -
code/branches/core4/src/core/input/JoyStickQuantityListener.cc
r3286 r3288 28 28 29 29 #include "JoyStickQuantityListener.h" 30 30 31 #include "core/CoreIncludes.h" 32 #include "core/ObjectList.h" 31 33 32 34 namespace orxonox 33 35 { 36 std::vector<JoyStick*> JoyStickQuantityListener::joyStickList_s; 37 34 38 JoyStickQuantityListener::JoyStickQuantityListener() 35 39 { 36 40 RegisterObject(JoyStickQuantityListener); 37 41 } 42 43 //! Calls all registered objects and sets the static variable 44 /*static*/ void JoyStickQuantityListener::changeJoyStickQuantity(const std::vector<JoyStick*>& joyStickList) 45 { 46 joyStickList_s = joyStickList; 47 for (ObjectList<JoyStickQuantityListener>::iterator it = ObjectList<JoyStickQuantityListener>::begin(); it; ++it) 48 it->JoyStickQuantityChanged(joyStickList); 49 } 38 50 } -
code/branches/core4/src/core/input/JoyStickQuantityListener.h
r3286 r3288 43 43 class _CoreExport JoyStickQuantityListener : virtual public OrxonoxClass 44 44 { 45 friend InputManager; 45 46 public: 46 47 JoyStickQuantityListener(); 47 48 virtual ~JoyStickQuantityListener() { } 48 49 49 //! Called when joy sticks get added/removed 50 virtual void JoyStickQuantityChanged(unsigned int value) = 0; 50 //! Returns a list with all JoySticks currently loaded 51 const std::vector<JoyStick*>& getJoyStickList() const { return joyStickList_s; } 52 53 private: 54 //! Called whenever joy sticks get added/removed 55 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) = 0; 56 57 static void changeJoyStickQuantity(const std::vector<JoyStick*>& joyStickList); 58 59 //! Static variable that holds the latest distributed information 60 static std::vector<JoyStick*> joyStickList_s; 51 61 }; 52 62 } -
code/branches/core4/src/core/input/KeyBinder.cc
r3279 r3288 40 40 #include "core/ConfigFileManager.h" 41 41 #include "InputCommands.h" 42 #include "InputManager.h"43 42 44 43 namespace orxonox … … 103 102 104 103 // initialise joy sticks separatly to allow for reloading 105 numberOfJoySticks_ = InputManager::getInstance().getJoyStickQuantity();104 numberOfJoySticks_ = this->getJoyStickList().size(); 106 105 initialiseJoyStickBindings(); 107 106 … … 155 154 } 156 155 157 void KeyBinder::JoyStickQuantityChanged( unsigned int value)156 void KeyBinder::JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) 158 157 { 159 158 unsigned int oldValue = numberOfJoySticks_; 160 numberOfJoySticks_ = value;159 numberOfJoySticks_ = joyStickList.size(); 161 160 162 161 // initialise joy stick bindings -
code/branches/core4/src/core/input/KeyBinder.h
r3274 r3288 76 76 void buttonThresholdChanged(); 77 77 // from JoyStickQuantityListener interface 78 virtual void JoyStickQuantityChanged( unsigned int value);78 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList); 79 79 void initialiseJoyStickBindings(); 80 80 void compilePointerLists(); -
code/branches/core4/src/core/input/KeyDetector.cc
r3274 r3288 73 73 } 74 74 75 void KeyDetector::JoyStickQuantityChanged( unsigned int value)75 void KeyDetector::JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList) 76 76 { 77 KeyBinder::JoyStickQuantityChanged( value);77 KeyBinder::JoyStickQuantityChanged(joyStickList); 78 78 setCallbackCommand(callbackCommand_); 79 79 } -
code/branches/core4/src/core/input/KeyDetector.h
r3274 r3288 49 49 ~KeyDetector(); 50 50 void setCallbackCommand(const std::string& command); 51 void JoyStickQuantityChanged( unsigned int value);51 void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList); 52 52 53 53 private:
Note: See TracChangeset
for help on using the changeset viewer.