Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 20, 2008, 4:31:03 PM (17 years ago)
Author:
rgrieder
Message:
  • classed FloatParser to ExprParser class
Location:
code/branches/input/src/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/core/InputHandler.cc

    r1112 r1118  
    7474    this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "setInputMode " + getConvertedValue<int, std::string>(IM_KEYBOARD);
    7575    this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit";
     76    this->bindingsKeyHold_[OIS::KC_U] = "exec disco.txt";
    7677    return true;
    7778  }
     
    8384  bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e)
    8485  {
     86    this->keysDown_.push_back(e.key);
    8587    // find the appropriate key binding
    8688    std::string cmdStr = bindingsKeyPress_[int(e.key)];
     
    99101  bool InputHandlerGame::keyReleased(const OIS::KeyEvent &e)
    100102  {
     103    // remove the key from the keysDown_ list
     104    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
     105    {
     106      if (*it == e.key)
     107      {
     108        keysDown_.erase(it);
     109        break;
     110      }
     111    }
     112
    101113    // find the appropriate key binding
    102114    std::string cmdStr = bindingsKeyRelease_[int(e.key)];
     
    136148  {
    137149    return true;
     150  }
     151
     152  /**
     153    @brief Tick method to do additional calculations.
     154    @param dt Delta time.
     155  */
     156  void InputHandlerGame::tick(float dt)
     157  {
     158    // iterate through all the pressed keys
     159    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
     160    {
     161      // find the appropriate key binding
     162      std::string cmdStr = bindingsKeyHold_[*it];
     163      if (cmdStr != "")
     164      {
     165        CommandExecutor::execute(cmdStr);
     166        COUT(3) << "Executing command: " << cmdStr << std::endl;
     167      }
     168    }
    138169  }
    139170
     
    225256  }
    226257
     258  /**
     259    @brief Tick method to do additional calculations.
     260    @param dt Delta time.
     261  */
     262  void InputHandlerGUI::tick(float dt)
     263  {
     264   
     265  }
     266
    227267}
  • code/branches/input/src/core/InputHandler.h

    r1112 r1118  
    3838
    3939#include <string>
     40#include <list>
    4041#include <OIS/OIS.h>
    4142
     
    4849    enum KeybindSetting
    4950    {
    50       none,
    51       onPress,
    52       onRelease,
    53       continuous,
     51      None,
     52      OnPress,
     53      OnRelease,
     54      Continuous,
    5455    };
    5556  }
     
    5859      : public OIS::KeyListener, public OIS::MouseListener
    5960  {
     61    virtual void tick(float dt) = 0;
    6062  };
    6163   
     
    8082                bool keyReleased  (const OIS::KeyEvent   &arg);
    8183
     84    void tick(float dt);
     85
    8286    // temporary hack
    8387    void callListeners(InputEvent &evt);
     88
     89    //! Stores all the keys that are down
     90    std::list<OIS::KeyCode> keysDown_;
    8491
    8592    /** denotes the maximum number of different keys there are in OIS.
     
    114121    ~InputHandlerGUI();
    115122
     123    void tick(float dt);
     124
    116125  private:
    117126    // input events
  • code/branches/input/src/core/InputManager.cc

    r1112 r1118  
    207207    if (mouse_)
    208208      mouse_->capture();
    209 
    210209    if (keyboard_)
    211210      keyboard_->capture();
     211
     212    // Give the listeners the chance to do additional calculations
    212213  }
    213214
Note: See TracChangeset for help on using the changeset viewer.