Changeset 5663 for code/branches/resource2/src/core
- Timestamp:
- Aug 19, 2009, 9:30:05 PM (15 years ago)
- Location:
- code/branches/resource2/src/core/input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/input/Button.cc
r3327 r5663 59 59 nCommands_[1]=0; 60 60 nCommands_[2]=0; 61 this->configContainer_ = 0;62 61 } 63 62 -
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 { -
code/branches/resource2/src/core/input/KeyBinder.h
r3327 r5663 41 41 #include <string> 42 42 #include <vector> 43 #include <boost/shared_ptr.hpp> 43 44 44 45 #include "InputHandler.h" … … 115 116 }; 116 117 //! Actual key bindings for joy stick buttons 117 std::vector< JoyStickButtonVector> joyStickButtons_;118 std::vector<shared_ptr<JoyStickButtonVector> > joyStickButtons_; 118 119 //! Helper class to use something like std:vector<HalfAxis[48]> 119 120 struct JoyStickAxisVector … … 123 124 }; 124 125 //! Actual key bindings for joy stick axes (and sliders) 125 std::vector< JoyStickAxisVector> joyStickAxes_;126 std::vector<shared_ptr<JoyStickAxisVector> > joyStickAxes_; 126 127 127 128 //! Pointer map with all Buttons, including half axes … … 191 192 192 193 inline void KeyBinder::buttonPressed (unsigned int device, JoyStickButtonCode::ByEnum button) 193 { joyStickButtons_[device][button].execute(KeybindMode::OnPress); }194 { (*joyStickButtons_[device])[button].execute(KeybindMode::OnPress); } 194 195 195 196 inline void KeyBinder::buttonReleased(unsigned int device, JoyStickButtonCode::ByEnum button) 196 { joyStickButtons_[device][button].execute(KeybindMode::OnRelease); }197 { (*joyStickButtons_[device])[button].execute(KeybindMode::OnRelease); } 197 198 198 199 inline void KeyBinder::buttonHeld (unsigned int device, JoyStickButtonCode::ByEnum button) 199 { joyStickButtons_[device][button].execute(KeybindMode::OnHold); }200 { (*joyStickButtons_[device])[button].execute(KeybindMode::OnHold); } 200 201 201 202 inline void KeyBinder::allDevicesUpdated(float dt) -
code/branches/resource2/src/core/input/KeyDetector.cc
r3327 r5663 70 70 { 71 71 KeyBinder::JoyStickQuantityChanged(joyStickList); 72 setCallbackCommand(callbackCommand_); 72 if (!callbackCommand_.empty()) 73 setCallbackCommand(callbackCommand_); 73 74 } 74 75 }
Note: See TracChangeset
for help on using the changeset viewer.