Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 19, 2008, 10:31:52 PM (17 years ago)
Author:
rgrieder
Message:

added calculate command ;)
In the console, you can now type something like "calculate sin(cos(3+4) - 8)*7" or even "calculate 7>8" and you'll get the result as a double.
The parser was something I've written 3 years ago when I first used C++ (the parser is mainly C).

Location:
code/branches/input/src/core
Files:
3 edited

Legend:

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

    r1066 r1112  
    3838#include "InputEvent.h"
    3939#include "InputManager.h"
     40#include "core/CommandExecutor.h"
    4041
    4142namespace orxonox
     
    6869    {
    6970      // simply write the key number (i) in the string
    70       this->bindingsKeyPressed_[i] = getConvertedValue<int, std::string>(i);
    71       this->bindingsKeyReleased_[i] = getConvertedValue<int, std::string>(i);
    72     }
     71      this->bindingsKeyPress_[i] = "";
     72      this->bindingsKeyRelease_[i] = "";
     73    }
     74    this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "setInputMode " + getConvertedValue<int, std::string>(IM_KEYBOARD);
     75    this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit";
    7376    return true;
    7477  }
     
    8083  bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e)
    8184  {
    82     if (e.key == OIS::KC_ESCAPE)
    83     {
    84       InputEvent e = {1, true, 0, 0, 0};
    85       InputHandlerGame::callListeners(e);
    86     }
    87     else if (e.key == OIS::KC_NUMPADENTER)
    88     {
    89       InputManager::getSingleton().setInputMode(IM_KEYBOARD);
    90     }
    91     else
    92     {
    93       // find the appropriate key binding
    94       std::string cmdStr = bindingsKeyPressed_[int(e.key)];
    95       //COUT(3) << cmdStr << " pressed" << std::endl;
     85    // find the appropriate key binding
     86    std::string cmdStr = bindingsKeyPress_[int(e.key)];
     87    if (cmdStr != "")
     88    {
     89      CommandExecutor::execute(cmdStr);
     90      COUT(3) << "Executing command: " << cmdStr << std::endl;
    9691    }
    9792    return true;
     
    105100  {
    106101    // find the appropriate key binding
    107     std::string cmdStr = bindingsKeyReleased_[int(e.key)];
    108     //COUT(3) << cmdStr << " released" << std::endl;
     102    std::string cmdStr = bindingsKeyRelease_[int(e.key)];
     103    if (cmdStr != "")
     104    {
     105      CommandExecutor::execute(cmdStr);
     106      COUT(3) << "Executing command: " << cmdStr << std::endl;
     107    }
    109108    return true;
    110109  }
  • code/branches/input/src/core/InputHandler.h

    r1062 r1112  
    4444namespace orxonox
    4545{
     46  namespace KeybindSetting
     47  {
     48    enum KeybindSetting
     49    {
     50      none,
     51      onPress,
     52      onRelease,
     53      continuous,
     54    };
     55  }
     56
     57  class _CoreExport BaseInputHandler
     58      : public OIS::KeyListener, public OIS::MouseListener
     59  {
     60  };
     61   
    4662  /**
    4763    @brief Captures mouse and keyboard input while in the actual game mode.
    4864    Manages the key bindings.
    4965  */
    50   class _CoreExport InputHandlerGame
    51         : public OIS::KeyListener, public OIS::MouseListener
     66  class _CoreExport InputHandlerGame : public BaseInputHandler
    5267  {
    5368  public:
     
    7287    static const int numberOfKeys_s = 256;
    7388    //! Array of input events for every pressed key
    74     std::string bindingsKeyPressed_[numberOfKeys_s];
     89    std::string bindingsKeyPress_[numberOfKeys_s];
    7590    //! Array of input events for every released key
    76     std::string bindingsKeyReleased_[numberOfKeys_s];
     91    std::string bindingsKeyRelease_[numberOfKeys_s];
     92    //! Array of input events for every holding key
     93    std::string bindingsKeyHold_[numberOfKeys_s];
    7794
    7895    /** denotes the maximum number of different buttons there are in OIS.
     
    91108    GUI.
    92109  */
    93   class _CoreExport InputHandlerGUI
    94         : public OIS::KeyListener, public OIS::MouseListener
     110  class _CoreExport InputHandlerGUI : public BaseInputHandler
    95111  {
    96112  public:
  • code/branches/input/src/core/InputManager.cc

    r1089 r1112  
    9393      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    9494
    95 #if defined OIS_LINUX_PLATFORM
    96       paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
    97 #endif
     95//#if defined OIS_LINUX_PLATFORM
     96//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
     97//#endif
    9898
    9999      try
Note: See TracChangeset for help on using the changeset viewer.