Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 2, 2008, 10:34:20 PM (16 years ago)
Author:
rgrieder
Message:

split KeyBinder into multiple files instead of one unreadable monster file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/core/input/KeyBinder.h

    r1519 r1520  
    3737#include "core/CorePrereqs.h"
    3838
    39 #include <string>
    4039#include <vector>
    4140
    42 #include "ois/OIS.h"
    43 #include "util/Math.h"
    4441#include "core/OrxonoxClass.h"
    45 #include "core/CommandEvaluation.h"
    4642#include "InputInterfaces.h"
     43#include "Button.h"
     44#include "HalfAxis.h"
    4745
    4846namespace orxonox
    4947{
    50   class _CoreExport BufferedParamCommand
    51   {
    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 BaseCommand
    63   {
    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 BaseCommand
    70   {
    71   public:
    72     bool execute(float abs = 1.0f, float rel = 1.0f);
    73 
    74     CommandEvaluation evaluation_;
    75   };
    76 
    77   class _CoreExport ParamCommand : public BaseCommand
    78   {
    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 Button
    89   {
    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 value
    99     std::string bindingString_;
    100     //! Name of the trigger as strings
    101     std::string name_;
    102     //! Basic commands for OnPress, OnHold and OnRelease
    103     BaseCommand** commands_[3];
    104     //! Number of basic commands
    105     unsigned int nCommands_[3];
    106     //! Says how much it takes for an analog axis to trigger a button
    107     //! Note: This variable is here to have only one parse() function.
    108     float buttonThreshold_;
    109   };
    110 
    111 
    112   class _CoreExport HalfAxis : public Button
    113   {
    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 related
    124     float relVal_;
    125     float absVal_;
    126     ParamCommand** paramCommands_;
    127     unsigned int nParamCommands_;
    128 
    129     // button related
    130     bool wasDown_;
    131     bool hasChanged_;
    132   };
    133 
    134 
    13548  /**
    13649    @brief Handles mouse, keyboard and joy stick input while in the actual game mode.
     
    226139    bool bClipMouse_;
    227140  };
    228 
    229 
    230   class _CoreExport KeyDetector : public KeyBinder
    231   {
    232   public:
    233     KeyDetector();
    234     ~KeyDetector();
    235     void loadBindings();
    236 
    237   protected:
    238     void readTrigger(Button& button);
    239   };
    240 
    241   class _CoreExport CalibratorCallback : public KeyHandler
    242   {
    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   };
    254141}
    255142
    256 
    257 
    258 
    259143#endif /* _KeyBinder_H__ */
Note: See TracChangeset for help on using the changeset viewer.