Changeset 1630 for code/branches/input/src/core/input/HalfAxis.cc
- Timestamp:
- Jun 27, 2008, 10:36:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/input/HalfAxis.cc
r1535 r1630 28 28 29 29 /** 30 @file 31 @brief Implementation of the different input handlers. 32 */ 30 @file 31 @brief 32 Implementation of the different input handlers. 33 */ 33 34 34 35 #include "HalfAxis.h" … … 38 39 namespace orxonox 39 40 { 40 void HalfAxis::clear() 41 { 42 Button::clear(); 43 if (nParamCommands_) 41 void HalfAxis::clear() 44 42 { 45 // delete all commands and the command pointer array 46 for (unsigned int i = 0; i < nParamCommands_; i++) 47 delete paramCommands_[i]; 48 delete[] paramCommands_; 49 nParamCommands_ = 0; 43 Button::clear(); 44 if (nParamCommands_) 45 { 46 // delete all commands and the command pointer array 47 for (unsigned int i = 0; i < nParamCommands_; i++) 48 delete paramCommands_[i]; 49 delete[] paramCommands_; 50 nParamCommands_ = 0; 51 } 52 else 53 { 54 nParamCommands_ = 0; nParamCommands_ = 0; 55 } 50 56 } 51 else 57 58 bool HalfAxis::addParamCommand(ParamCommand* command) 52 59 { 53 nParamCommands_ = 0; nParamCommands_ = 0; 60 ParamCommand** cmds = paramCommands_; 61 paramCommands_ = new ParamCommand*[++nParamCommands_]; 62 unsigned int i; 63 for (i = 0; i < nParamCommands_ - 1; i++) 64 paramCommands_[i] = cmds[i]; 65 paramCommands_[i] = command; 66 if (nParamCommands_ > 1) 67 delete[] cmds; 68 return true; 54 69 } 55 }56 70 57 bool HalfAxis::addParamCommand(ParamCommand* command) 58 { 59 ParamCommand** cmds = paramCommands_; 60 paramCommands_ = new ParamCommand*[++nParamCommands_]; 61 unsigned int i; 62 for (i = 0; i < nParamCommands_ - 1; i++) 63 paramCommands_[i] = cmds[i]; 64 paramCommands_[i] = command; 65 if (nParamCommands_ > 1) 66 delete[] cmds; 67 return true; 68 } 69 70 bool HalfAxis::execute() 71 { 72 bool success = true; 73 for (unsigned int i = 0; i < nParamCommands_; i++) 74 success = success && paramCommands_[i]->execute(absVal_, relVal_); 75 return success; 76 } 71 bool HalfAxis::execute() 72 { 73 bool success = true; 74 for (unsigned int i = 0; i < nParamCommands_; i++) 75 success = success && paramCommands_[i]->execute(absVal_, relVal_); 76 return success; 77 } 77 78 }
Note: See TracChangeset
for help on using the changeset viewer.