Changeset 10821 for code/branches/cpp11_v2/src/libraries/core/input
- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/core/input
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/input/Button.cc
r10768 r10821 196 196 197 197 // add command to the buffer if not yet existing 198 for ( unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer_->size(); iParamCmd++)199 { 200 if ( (*paramCommandBuffer_)[iParamCmd]->evaluation_.getConsoleCommand()198 for (auto & elem : *paramCommandBuffer_) 199 { 200 if (elem->evaluation_.getConsoleCommand() 201 201 == eval.getConsoleCommand()) 202 202 { 203 203 // already in list 204 cmd->paramCommand_ = (*paramCommandBuffer_)[iParamCmd];204 cmd->paramCommand_ = elem; 205 205 break; 206 206 } -
code/branches/cpp11_v2/src/libraries/core/input/InputBuffer.cc
r9667 r10821 110 110 void InputBuffer::insert(const std::string& input, bool update) 111 111 { 112 for ( unsigned int i = 0; i < input.size(); ++i)113 { 114 this->insert( input[i], false);112 for (auto & elem : input) 113 { 114 this->insert(elem, false); 115 115 116 116 if (update) 117 this->updated( input[i], false);117 this->updated(elem, false); 118 118 } 119 119 … … 170 170 void InputBuffer::updated() 171 171 { 172 for ( std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)173 { 174 if (( *it)->bListenToAllChanges_)175 ( *it)->callFunction();172 for (auto & elem : this->listeners_) 173 { 174 if ((elem)->bListenToAllChanges_) 175 (elem)->callFunction(); 176 176 } 177 177 } … … 179 179 void InputBuffer::updated(const char& update, bool bSingleInput) 180 180 { 181 for ( std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)182 { 183 if ((!( *it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))184 ( *it)->callFunction();181 for (auto & elem : this->listeners_) 182 { 183 if ((!(elem)->trueKeyFalseChar_) && ((elem)->bListenToAllChanges_ || ((elem)->char_ == update)) && (!(elem)->bOnlySingleInput_ || bSingleInput)) 184 (elem)->callFunction(); 185 185 } 186 186 } … … 201 201 return; 202 202 203 for ( std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)204 { 205 if (( *it)->trueKeyFalseChar_ && ((*it)->key_ == evt.getKeyCode()))206 ( *it)->callFunction();203 for (auto & elem : this->listeners_) 204 { 205 if ((elem)->trueKeyFalseChar_ && ((elem)->key_ == evt.getKeyCode())) 206 (elem)->callFunction(); 207 207 } 208 208 -
code/branches/cpp11_v2/src/libraries/core/input/InputDevice.h
r10817 r10821 158 158 159 159 // Call all the states with the held button event 160 for ( unsigned int iB = 0; iB < pressedButtons_.size(); ++iB)161 for ( unsigned int iS = 0; iS < inputStates_.size(); ++iS)162 inputStates_[iS]->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(163 this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg( pressedButtons_[iB]));160 for (auto & button : pressedButtons_) 161 for (auto & state : inputStates_) 162 state->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>( 163 this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button)); 164 164 165 165 // Call states with device update events 166 for ( unsigned int i = 0; i < inputStates_.size(); ++i)167 inputStates_[i]->update(time.getDeltaTime(), this->getDeviceID());166 for (auto & elem : inputStates_) 167 elem->update(time.getDeltaTime(), this->getDeviceID()); 168 168 169 169 static_cast<DeviceClass*>(this)->updateImpl(time); … … 196 196 197 197 // Call states 198 for ( unsigned int i = 0; i < inputStates_.size(); ++i)199 inputStates_[i]->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));198 for (auto & elem : inputStates_) 199 elem->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button)); 200 200 } 201 201 … … 218 218 219 219 // Call states 220 for ( unsigned int i = 0; i < inputStates_.size(); ++i)221 inputStates_[i]->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));220 for (auto & elem : inputStates_) 221 elem->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button)); 222 222 } 223 223 -
code/branches/cpp11_v2/src/libraries/core/input/InputManager.cc
r10778 r10821 373 373 // check whether a state has changed its EMPTY situation 374 374 bool bUpdateRequired = false; 375 for ( std::map<int, InputState*>::iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)376 { 377 if ( it->second->hasExpired())378 { 379 it->second->resetExpiration();375 for (auto & elem : activeStates_) 376 { 377 if (elem.second->hasExpired()) 378 { 379 elem.second->resetExpiration(); 380 380 bUpdateRequired = true; 381 381 } … … 391 391 392 392 // Collect function calls for the update 393 for ( unsigned int i = 0; i < activeStatesTicked_.size(); ++i)394 activeStatesTicked_[i]->update(time.getDeltaTime());393 for (auto & elem : activeStatesTicked_) 394 elem->update(time.getDeltaTime()); 395 395 396 396 // Execute all cached function calls in order … … 401 401 // If we delay the calls, then OIS and and the InputStates are not anymore 402 402 // in the call stack and can therefore be edited. 403 for ( size_t i = 0; i < this->callBuffer_.size(); ++i)404 this->callBuffer_[i]();403 for (auto & elem : this->callBuffer_) 404 elem(); 405 405 406 406 this->callBuffer_.clear(); … … 437 437 // Using an std::set to avoid duplicates 438 438 std::set<InputState*> tempSet; 439 for ( unsigned int i = 0; i < devices_.size(); ++i)440 if ( devices_[i]!= nullptr)441 for (unsigned int iState = 0; iState < devices_[i]->getStateListRef().size(); ++iState)442 tempSet.insert( devices_[i]->getStateListRef()[iState]);439 for (auto & elem : devices_) 440 if (elem != nullptr) 441 for (unsigned int iState = 0; iState < elem->getStateListRef().size(); ++iState) 442 tempSet.insert(elem->getStateListRef()[iState]); 443 443 444 444 // Copy the content of the std::set back to the actual vector 445 445 activeStatesTicked_.clear(); 446 for ( std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)447 activeStatesTicked_.push_back( *it);446 for (const auto & elem : tempSet) 447 activeStatesTicked_.push_back(elem); 448 448 449 449 // Check whether we have to change the mouse mode -
code/branches/cpp11_v2/src/libraries/core/input/JoyStick.cc
r10778 r10821 186 186 void JoyStick::clearBuffersImpl() 187 187 { 188 for ( int j = 0; j < 4; ++j)189 povStates_[j]= 0;188 for (auto & elem : povStates_) 189 elem = 0; 190 190 } 191 191 -
code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc
r10772 r10821 153 153 void KeyBinder::buttonThresholdChanged() 154 154 { 155 for ( unsigned int i = 0; i < allHalfAxes_.size(); i++)156 if (! allHalfAxes_[i]->bButtonThresholdUser_)157 allHalfAxes_[i]->buttonThreshold_ = this->buttonThreshold_;155 for (auto & elem : allHalfAxes_) 156 if (!elem->bButtonThresholdUser_) 157 elem->buttonThreshold_ = this->buttonThreshold_; 158 158 } 159 159 … … 383 383 it->second->clear(); 384 384 385 for ( unsigned int i = 0; i < paramCommandBuffer_.size(); i++)386 delete paramCommandBuffer_[i];385 for (auto & elem : paramCommandBuffer_) 386 delete elem; 387 387 paramCommandBuffer_.clear(); 388 388 } … … 394 394 { 395 395 // iterate over all buttons 396 for ( std::map<std::string, Button*>::iterator it = this->allButtons_.begin(); it != this->allButtons_.end(); ++it)397 { 398 Button* button = it->second;396 for (const auto & elem : this->allButtons_) 397 { 398 Button* button = elem.second; 399 399 400 400 // iterate over all modes … … 465 465 this->mousePosition_[1] = 0.0f; 466 466 467 for ( unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)468 mouseAxes_[i].reset();467 for (auto & elem : mouseAxes_) 468 elem.reset(); 469 469 } 470 470 … … 505 505 } 506 506 507 for ( unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)507 for (auto & elem : mouseAxes_) 508 508 { 509 509 // Why dividing relative value by dt? The reason lies in the simple fact, that when you … … 515 515 { 516 516 // just ignore if dt == 0.0 because we have multiplied by 0.0 anyway.. 517 mouseAxes_[i].relVal_ /= dt;518 } 519 520 tickHalfAxis( mouseAxes_[i]);517 elem.relVal_ /= dt; 518 } 519 520 tickHalfAxis(elem); 521 521 } 522 522 } -
code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.h
r10817 r10821 226 226 { 227 227 // execute all buffered bindings (additional parameter) 228 for ( unsigned int i = 0; i < paramCommandBuffer_.size(); i++)228 for (auto & elem : paramCommandBuffer_) 229 229 { 230 paramCommandBuffer_[i]->rel_ *= dt;231 paramCommandBuffer_[i]->execute();230 elem->rel_ *= dt; 231 elem->execute(); 232 232 } 233 233 234 234 // always reset the relative movement of the mouse 235 for ( unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)236 mouseAxes_[i].relVal_ = 0.0f;235 for (auto & elem : mouseAxes_) 236 elem.relVal_ = 0.0f; 237 237 } 238 238 }// tolua_export -
code/branches/cpp11_v2/src/libraries/core/input/Mouse.cc
r10768 r10821 82 82 IntVector2 rel(e.state.X.rel, e.state.Y.rel); 83 83 IntVector2 clippingSize(e.state.width, e.state.height); 84 for ( unsigned int i = 0; i < inputStates_.size(); ++i)85 inputStates_[i]->mouseMoved(abs, rel, clippingSize);84 for (auto & elem : inputStates_) 85 elem->mouseMoved(abs, rel, clippingSize); 86 86 } 87 87 … … 89 89 if (e.state.Z.rel != 0) 90 90 { 91 for ( unsigned int i = 0; i < inputStates_.size(); ++i)92 inputStates_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);91 for (auto & elem : inputStates_) 92 elem->mouseScrolled(e.state.Z.abs, e.state.Z.rel); 93 93 } 94 94
Note: See TracChangeset
for help on using the changeset viewer.