- Timestamp:
- Dec 22, 2009, 2:07:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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())
Note: See TracChangeset
for help on using the changeset viewer.