Changeset 5663 for code/branches/resource2/src/core/input/KeyBinder.cc
- Timestamp:
- Aug 19, 2009, 9:30:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/input/KeyBinder.cc
r3327 r5663 55 55 mousePosition_[0] = 0; 56 56 mousePosition_[1] = 0; 57 58 joyStickButtons_.reserve(1000);59 joyStickAxes_.reserve(1000);60 57 61 58 RegisterRootObject(KeyBinder); … … 167 164 { 168 165 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; ++i) 169 joyStickButtons_[iDev][i].readConfigValue(this->configFile_);166 (*joyStickButtons_[iDev])[i].readConfigValue(this->configFile_); 170 167 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; ++i) 171 joyStickAxes_[iDev][i].readConfigValue(this->configFile_);168 (*joyStickAxes_[iDev])[i].readConfigValue(this->configFile_); 172 169 } 173 170 } … … 179 176 void KeyBinder::initialiseJoyStickBindings() 180 177 { 178 while (joyStickAxes_.size() < joySticks_.size()) 179 joyStickAxes_.push_back(shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector())); 180 while (joyStickButtons_.size() < joySticks_.size()) 181 joyStickButtons_.push_back(shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector())); 182 // For the case the new size is smaller 181 183 this->joyStickAxes_.resize(joySticks_.size()); 182 184 this->joyStickButtons_.resize(joySticks_.size()); … … 189 191 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++) 190 192 { 191 joyStickButtons_[iDev][i].name_ = JoyStickButtonCode::ByString[i];192 joyStickButtons_[iDev][i].paramCommandBuffer_ = ¶mCommandBuffer_;193 joyStickButtons_[iDev][i].groupName_ = "JoyStickButtons_" + deviceName;193 (*joyStickButtons_[iDev])[i].name_ = JoyStickButtonCode::ByString[i]; 194 (*joyStickButtons_[iDev])[i].paramCommandBuffer_ = ¶mCommandBuffer_; 195 (*joyStickButtons_[iDev])[i].groupName_ = "JoyStickButtons_" + deviceName; 194 196 } 195 197 // joy stick axes 196 198 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++) 197 199 { 198 joyStickAxes_[iDev][i].name_ = JoyStickAxisCode::ByString[i / 2];200 (*joyStickAxes_[iDev])[i].name_ = JoyStickAxisCode::ByString[i / 2]; 199 201 if (i & 1) 200 joyStickAxes_[iDev][i].name_ += "Pos";202 (*joyStickAxes_[iDev])[i].name_ += "Pos"; 201 203 else 202 joyStickAxes_[iDev][i].name_ += "Neg";203 joyStickAxes_[iDev][i].paramCommandBuffer_ = ¶mCommandBuffer_;204 joyStickAxes_[iDev][i].groupName_ = "JoyStickAxes_" + deviceName;204 (*joyStickAxes_[iDev])[i].name_ += "Neg"; 205 (*joyStickAxes_[iDev])[i].paramCommandBuffer_ = ¶mCommandBuffer_; 206 (*joyStickAxes_[iDev])[i].groupName_ = "JoyStickAxes_" + deviceName; 205 207 } 206 208 } … … 226 228 { 227 229 for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++) 228 allButtons_[ joyStickButtons_[iDev][i].groupName_ + "." + joyStickButtons_[iDev][i].name_] = &(joyStickButtons_[iDev][i]);230 allButtons_[(*joyStickButtons_[iDev])[i].groupName_ + "." + (*joyStickButtons_[iDev])[i].name_] = &((*joyStickButtons_[iDev])[i]); 229 231 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++) 230 232 { 231 allButtons_[ joyStickAxes_[iDev][i].groupName_ + "." + joyStickAxes_[iDev][i].name_] = &(joyStickAxes_[iDev][i]);232 allHalfAxes_.push_back(&( joyStickAxes_[iDev][i]));233 allButtons_[(*joyStickAxes_[iDev])[i].groupName_ + "." + (*joyStickAxes_[iDev])[i].name_] = &((*joyStickAxes_[iDev])[i]); 234 allHalfAxes_.push_back(&((*joyStickAxes_[iDev])[i])); 233 235 } 234 236 } … … 303 305 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++) 304 306 { 305 joyStickAxes_[iDev][i].absVal_ = 0.0f;306 joyStickAxes_[iDev][i].relVal_ = 0.0f;307 (*joyStickAxes_[iDev])[i].absVal_ = 0.0f; 308 (*joyStickAxes_[iDev])[i].relVal_ = 0.0f; 307 309 } 308 310 } … … 366 368 for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++) 367 369 { 368 tickHalfAxis( joyStickAxes_[joyStick][i]);370 tickHalfAxis((*joyStickAxes_[joyStick])[i]); 369 371 } 370 372 } … … 481 483 { 482 484 int i = axisID * 2; 483 JoyStickAxisVector& axis = joyStickAxes_[device];485 JoyStickAxisVector& axis = *joyStickAxes_[device]; 484 486 if (value < 0) 485 487 {
Note: See TracChangeset
for help on using the changeset viewer.