Changeset 6394 for code/branches/presentation2/src/libraries/core/input
- Timestamp:
- Dec 22, 2009, 2:07:44 PM (15 years ago)
- Location:
- code/branches/presentation2/src/libraries/core/input
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/libraries/core/input/Button.cc
r5929 r6394 116 116 for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++) 117 117 { 118 if ( commandStrings[iCommand] != "")118 if (!commandStrings[iCommand].empty()) 119 119 { 120 120 SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false, … … 123 123 KeybindMode::Value mode = KeybindMode::None; 124 124 float paramModifier = 1.0f; 125 std::string commandStr = "";125 std::string commandStr; 126 126 127 127 for (unsigned int iToken = 0; iToken < tokens.size(); ++iToken) 128 128 { 129 std::stringtoken = getLowercase(tokens[iToken]);129 const std::string& token = getLowercase(tokens[iToken]); 130 130 131 131 if (token == "onpress") … … 159 159 // we interpret everything from here as a command string 160 160 while (iToken != tokens.size()) 161 commandStr += tokens[iToken++] + " ";162 } 163 } 164 165 if (commandStr == "")161 commandStr += tokens[iToken++] + ' '; 162 } 163 } 164 165 if (commandStr.empty()) 166 166 { 167 167 parseError("No command string given.", false); … … 242 242 } 243 243 244 inline void Button::parseError( std::stringmessage, bool serious)244 inline void Button::parseError(const std::string& message, bool serious) 245 245 { 246 246 if (serious) -
code/branches/presentation2/src/libraries/core/input/Button.h
r5781 r6394 76 76 77 77 private: 78 void parseError( std::stringmessage, bool serious);78 void parseError(const std::string& message, bool serious); 79 79 }; 80 80 -
code/branches/presentation2/src/libraries/core/input/InputBuffer.cc
r6177 r6394 39 39 RegisterRootObject(InputBuffer); 40 40 41 this->buffer_ = "";42 41 this->cursor_ = 0; 43 42 this->maxLength_ = 1024; … … 62 61 this->maxLength_ = 1024; 63 62 this->allowedChars_ = allowedChars; 64 this->buffer_ = "";65 63 this->cursor_ = 0; 66 64 … … 138 136 void InputBuffer::clear(bool update) 139 137 { 140 this->buffer_ = "";138 this->buffer_.clear(); 141 139 this->cursor_ = 0; 142 140 … … 188 186 bool InputBuffer::charIsAllowed(const char& input) 189 187 { 190 if (this->allowedChars_ == "")188 if (this->allowedChars_.empty()) 191 189 return true; 192 190 else -
code/branches/presentation2/src/libraries/core/input/InputManager.cc
r6388 r6394 297 297 if (device == NULL) 298 298 continue; 299 std::stringclassName = device->getClassName();299 const std::string& className = device->getClassName(); 300 300 try 301 301 { … … 579 579 InputState* InputManager::createInputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority) 580 580 { 581 if (name == "")581 if (name.empty()) 582 582 return 0; 583 583 if (statesByName_.find(name) == statesByName_.end()) -
code/branches/presentation2/src/libraries/core/input/JoyStick.cc
r5781 r6394 33 33 #include <boost/foreach.hpp> 34 34 35 #include "util/StringUtils.h" 35 36 #include "core/ConfigFileManager.h" 36 37 #include "core/ConfigValueIncludes.h" … … 61 62 std::string name = oisDevice_->vendor(); 62 63 replaceCharacters(name, ' ', '_'); 63 deviceName_ = name + "_";64 } 65 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Button)) + "_";66 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis)) + "_";67 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Slider)) + "_";64 deviceName_ = name + '_'; 65 } 66 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Button)) + '_'; 67 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis)) + '_'; 68 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Slider)) + '_'; 68 69 deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_POV)); 69 70 //deviceName_ += multi_cast<std::string>(oisDevice_->getNumberOfComponents(OIS::OIS_Vector3)); … … 74 75 { 75 76 // Make the ID unique for this execution time. 76 deviceName_ += "_"+ multi_cast<std::string>(this->getDeviceName());77 deviceName_ += '_' + multi_cast<std::string>(this->getDeviceName()); 77 78 break; 78 79 } -
code/branches/presentation2/src/libraries/core/input/KeyBinder.cc
r6388 r6394 61 61 for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++) 62 62 { 63 std::stringkeyname = KeyCode::ByString[i];63 const std::string& keyname = KeyCode::ByString[i]; 64 64 if (!keyname.empty()) 65 65 keys_[i].name_ = std::string("Key") + keyname; 66 66 else 67 keys_[i].name_ = "";67 keys_[i].name_.clear(); 68 68 keys_[i].paramCommandBuffer_ = ¶mCommandBuffer_; 69 69 keys_[i].groupName_ = "Keys"; … … 188 188 this->joyStickButtons_.resize(joySticks_.size()); 189 189 190 // reinitialise all joy stick bin ings (doesn't overwrite the old ones)190 // reinitialise all joy stick bindings (doesn't overwrite the old ones) 191 191 for (unsigned int iDev = 0; iDev < joySticks_.size(); iDev++) 192 192 { 193 std::stringdeviceName = joySticks_[iDev]->getDeviceName();193 const std::string& deviceName = joySticks_[iDev]->getDeviceName(); 194 194 // joy stick buttons 195 195 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++) … … 221 221 for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++) 222 222 if (!keys_[i].name_.empty()) 223 allButtons_[keys_[i].groupName_ + "."+ keys_[i].name_] = keys_ + i;223 allButtons_[keys_[i].groupName_ + '.' + keys_[i].name_] = keys_ + i; 224 224 for (unsigned int i = 0; i < numberOfMouseButtons_; i++) 225 allButtons_[mouseButtons_[i].groupName_ + "."+ mouseButtons_[i].name_] = mouseButtons_ + i;225 allButtons_[mouseButtons_[i].groupName_ + '.' + mouseButtons_[i].name_] = mouseButtons_ + i; 226 226 for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++) 227 227 { 228 allButtons_[mouseAxes_[i].groupName_ + "."+ mouseAxes_[i].name_] = mouseAxes_ + i;228 allButtons_[mouseAxes_[i].groupName_ + '.' + mouseAxes_[i].name_] = mouseAxes_ + i; 229 229 allHalfAxes_.push_back(mouseAxes_ + i); 230 230 } … … 232 232 { 233 233 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++) 234 allButtons_[(*joyStickButtons_[iDev])[i].groupName_ + "."+ (*joyStickButtons_[iDev])[i].name_] = &((*joyStickButtons_[iDev])[i]);234 allButtons_[(*joyStickButtons_[iDev])[i].groupName_ + '.' + (*joyStickButtons_[iDev])[i].name_] = &((*joyStickButtons_[iDev])[i]); 235 235 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++) 236 236 { 237 allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + "."+ (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]);237 allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + '.' + (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]); 238 238 allHalfAxes_.push_back(&((*joyStickAxes_[iDev])[i])); 239 239 } … … 284 284 } 285 285 286 void KeyBinder::addButtonToCommand( std::stringcommand, Button* button)286 void KeyBinder::addButtonToCommand(const std::string& command, Button* button) 287 287 { 288 288 std::ostringstream stream; 289 stream << button->groupName_ << "."<< button->name_;289 stream << button->groupName_ << '.' << button->name_; 290 290 291 291 std::vector<std::string>& oldKeynames = this->allCommands_[button->bindingString_]; … … 296 296 } 297 297 298 if (command != "")298 if (!command.empty()) 299 299 { 300 300 std::vector<std::string>& keynames = this->allCommands_[command]; … … 310 310 Return the first key name for a specific command 311 311 */ 312 std::string KeyBinder::getBinding(std::stringcommandName)312 const std::string& KeyBinder::getBinding(const std::string& commandName) 313 313 { 314 314 if( this->allCommands_.find(commandName) != this->allCommands_.end()) … … 318 318 } 319 319 320 return "";320 return BLANKSTRING; 321 321 } 322 322 … … 329 329 The index at which the key name is returned for. 330 330 */ 331 std::string KeyBinder::getBinding(std::stringcommandName, unsigned int index)331 const std::string& KeyBinder::getBinding(const std::string& commandName, unsigned int index) 332 332 { 333 333 if( this->allCommands_.find(commandName) != this->allCommands_.end()) … … 339 339 } 340 340 341 return "";342 } 343 344 return "";341 return BLANKSTRING; 342 } 343 344 return BLANKSTRING; 345 345 } 346 346 … … 351 351 The command. 352 352 */ 353 unsigned int KeyBinder::getNumberOfBindings( std::stringcommandName)353 unsigned int KeyBinder::getNumberOfBindings(const std::string& commandName) 354 354 { 355 355 if( this->allCommands_.find(commandName) != this->allCommands_.end()) -
code/branches/presentation2/src/libraries/core/input/KeyBinder.h
r6387 r6394 66 66 void clearBindings(); 67 67 bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false); 68 std::string getBinding(std::stringcommandName); //tolua_export69 std::string getBinding(std::stringcommandName, unsigned int index); //tolua_export70 unsigned int getNumberOfBindings( std::stringcommandName); //tolua_export68 const std::string& getBinding(const std::string& commandName); //tolua_export 69 const std::string& getBinding(const std::string& commandName, unsigned int index); //tolua_export 70 unsigned int getNumberOfBindings(const std::string& commandName); //tolua_export 71 71 72 72 const std::string& getBindingsFilename() … … 160 160 161 161 private: 162 void addButtonToCommand( std::stringcommand, Button* button);162 void addButtonToCommand(const std::string& command, Button* button); 163 163 164 164 //##### ConfigValues ##### -
code/branches/presentation2/src/libraries/core/input/KeyDetector.cc
r6182 r6394 67 67 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 68 68 { 69 it->second->bindingString_ = callbackCommand_s + " "+ it->second->groupName_ + "." + it->second->name_;69 it->second->bindingString_ = callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_; 70 70 it->second->parse(); 71 71 }
Note: See TracChangeset
for help on using the changeset viewer.