Changeset 1520 for code/branches/input/src/core/input/KeyBinder.h
- Timestamp:
- Jun 2, 2008, 10:34:20 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/input/KeyBinder.h
r1519 r1520 37 37 #include "core/CorePrereqs.h" 38 38 39 #include <string>40 39 #include <vector> 41 40 42 #include "ois/OIS.h"43 #include "util/Math.h"44 41 #include "core/OrxonoxClass.h" 45 #include "core/CommandEvaluation.h"46 42 #include "InputInterfaces.h" 43 #include "Button.h" 44 #include "HalfAxis.h" 47 45 48 46 namespace orxonox 49 47 { 50 class _CoreExport BufferedParamCommand51 {52 public:53 BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }54 bool execute();55 56 float value_;57 unsigned int nValuesAdded_;58 int paramIndex_;59 CommandEvaluation evaluation_;60 };61 62 class _CoreExport BaseCommand63 {64 public:65 virtual ~BaseCommand() { }66 virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;67 };68 69 class _CoreExport SimpleCommand : public BaseCommand70 {71 public:72 bool execute(float abs = 1.0f, float rel = 1.0f);73 74 CommandEvaluation evaluation_;75 };76 77 class _CoreExport ParamCommand : public BaseCommand78 {79 public:80 ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }81 bool execute(float abs = 1.0f, float rel = 1.0f);82 83 bool bRelative_;84 float paramModifier_;85 BufferedParamCommand* paramCommand_;86 };87 88 class _CoreExport Button89 {90 public:91 Button() { nCommands_[0]=0; nCommands_[1]=0; nCommands_[2]=0; clear(); }92 virtual ~Button() { clear(); }93 virtual void clear();94 virtual bool addParamCommand(ParamCommand* command) { return false; }95 void parse(std::vector<BufferedParamCommand*>& paramCommandBuffer);96 bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);97 98 //! The configured string value99 std::string bindingString_;100 //! Name of the trigger as strings101 std::string name_;102 //! Basic commands for OnPress, OnHold and OnRelease103 BaseCommand** commands_[3];104 //! Number of basic commands105 unsigned int nCommands_[3];106 //! Says how much it takes for an analog axis to trigger a button107 //! Note: This variable is here to have only one parse() function.108 float buttonThreshold_;109 };110 111 112 class _CoreExport HalfAxis : public Button113 {114 public:115 HalfAxis() : relVal_(0.0f), absVal_(0.0f), paramCommands_(0), nParamCommands_(0),116 wasDown_(false), hasChanged_(false) { }117 using Button::execute;118 bool execute();119 //bool execute(KeybindMode::Enum mode) { return Button::execute(mode); }120 bool addParamCommand(ParamCommand* command);121 void clear();122 123 // axis related124 float relVal_;125 float absVal_;126 ParamCommand** paramCommands_;127 unsigned int nParamCommands_;128 129 // button related130 bool wasDown_;131 bool hasChanged_;132 };133 134 135 48 /** 136 49 @brief Handles mouse, keyboard and joy stick input while in the actual game mode. … … 226 139 bool bClipMouse_; 227 140 }; 228 229 230 class _CoreExport KeyDetector : public KeyBinder231 {232 public:233 KeyDetector();234 ~KeyDetector();235 void loadBindings();236 237 protected:238 void readTrigger(Button& button);239 };240 241 class _CoreExport CalibratorCallback : public KeyHandler242 {243 public:244 CalibratorCallback() {}245 ~CalibratorCallback() {}246 247 private:248 void keyPressed (const KeyEvent& evt);249 void keyReleased(const KeyEvent& evt) {}250 void keyHeld (const KeyEvent& evt) {}251 252 void tickInput(float dt, const HandlerState &state) { }253 };254 141 } 255 142 256 257 258 259 143 #endif /* _KeyBinder_H__ */
Note: See TracChangeset
for help on using the changeset viewer.