Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1426


Ignore:
Timestamp:
May 26, 2008, 12:00:20 AM (16 years ago)
Author:
rgrieder
Message:
  • you can now tpye "keybind command" and then press a button/key to bind that string directly. doesn't seem to work yet with mouse axes
Location:
code/branches/network
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/core/InputManager.cc

    r1422 r1426  
    3838#include "InputBuffer.h"
    3939#include "KeyBinder.h"
     40#include "CommandExecutor.h"
     41#include "ConsoleCommand.h"
    4042
    4143namespace orxonox
    4244{
     45  ConsoleCommandShortcut(InputManager, keyBind, AccessLevel::User);
     46  ConsoleCommandShortcut(InputManager, storeKeyStroke, AccessLevel::Offline);
     47
    4348  // ###############################
    4449  // ###    Internal Methods     ###
     
    5459      joySticksSize_(0),
    5560      keyBinder_(0), buffer_(0), keyDetector_(0),
    56       state_(IS_UNINIT), stateRequest_(IS_UNINIT),
     61      state_(IS_UNINIT), stateRequest_(IS_UNINIT), savedState_(IS_UNINIT),
    5762      keyboardModifiers_(0)
    5863  {
     
    405410      if (stateRequest_ != IS_CUSTOM)
    406411      {
    407         activeKeyHandlers_.clear();
    408         activeMouseHandlers_.clear();
    409         for (unsigned int i = 0; i < joySticksSize_; i++)
    410           activeJoyStickHandlers_[i].clear();
     412        if (stateRequest_ != IS_NODETECT && stateRequest_ != IS_DETECT)
     413        {
     414          activeKeyHandlers_.clear();
     415          activeMouseHandlers_.clear();
     416          for (unsigned int i = 0; i < joySticksSize_; i++)
     417            activeJoyStickHandlers_[i].clear();
     418        }
    411419
    412420        switch (stateRequest_)
     
    429437          break;
    430438
    431         case IS_DETECTION:
    432           if (mouse_)
    433             mouse_->capture();
    434           if (keyboard_)
    435             keyboard_->capture();
    436           for (unsigned  int i = 0; i < joySticksSize_; i++)
    437             joySticks_[i]->capture();
    438 
    439           lastStroke_ = "";
     439        case IS_DETECT:
     440          savedState_ = state_;
    440441          enableKeyHandler("keydetector");
    441442          enableMouseHandler("keydetector");
     
    443444          break;
    444445
     446        case IS_NODETECT:
     447          disableKeyHandler("keydetector");
     448          disableMouseHandler("keydetector");
     449          disableJoyStickHandler("keydetector", 0);
     450          break;
     451
    445452        default:
    446453          break;
    447454        }
    448         state_ = stateRequest_;
     455
     456        if (stateRequest_ == IS_NODETECT)
     457          state_ = savedState_;
     458        else
     459          state_ = stateRequest_;
    449460      }
    450461    }
     
    767778  // ################################
    768779
     780  std::string InputManager::bindingCommmandString_s = "";
     781
    769782  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
    770783    bool createKeyboard, bool createMouse, bool createJoySticks)
     
    901914  void InputManager::storeKeyStroke(const std::string& name)
    902915  {
    903     if (_getSingleton().lastStroke_ == "")
    904       _getSingleton().lastStroke_ = name;
    905   }
    906 
    907   const std::string& InputManager::getLastKeyStroke()
    908   {
    909     return _getSingleton().lastStroke_;
    910   }
    911 
     916    setInputState(IS_NODETECT);
     917    COUT(3) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl;
     918    CommandExecutor::execute("set KeyBinder " + name + " " + bindingCommmandString_s, false);
     919  }
     920
     921  void InputManager::keyBind(const std::string& command)
     922  {
     923    bindingCommmandString_s = command;
     924    setInputState(IS_DETECT);
     925  }
    912926
    913927  // ###### KeyHandler ######
  • code/branches/network/src/core/InputManager.h

    r1413 r1426  
    8585      IS_GUI,       //!< All OIS input events are passed to CEGUI.
    8686      IS_CONSOLE,   //!< Keyboard input is redirected to the InputBuffer.
    87       IS_DETECTION, //!< All the input goes to the KeyDetector
     87      IS_DETECT,    //!< All the input additionally goes to the KeyDetector
     88      IS_NODETECT,  //!< remove KeyDetector
    8889      IS_CUSTOM     //!< Any possible configuration.
    8990    };
     
    115116
    116117    static void storeKeyStroke(const std::string& name);
    117     static const std::string& getLastKeyStroke();
     118    static void keyBind(const std::string& command);
    118119
    119120    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
     
    189190    InputState stateRequest_;
    190191    unsigned int keyboardModifiers_;
    191     std::string lastStroke_;
     192    InputState savedState_;
    192193
    193194    //! Keeps track of the joy stick POV states
     
    209210    std::vector<std::vector<int> >              joyStickButtonsDown_;
    210211
     212    static std::string                          bindingCommmandString_s;
    211213  };
    212214
  • code/branches/network/src/core/KeyBinder.cc

    r1422 r1426  
    900900    button.nCommands_[KeybindMode::OnPress] = 1;
    901901  }
     902 
    902903}
  • code/branches/network/src/core/KeyBinder.h

    r1420 r1426  
    232232    void loadBindings();
    233233    void setConfigValues();
     234
    234235  protected:
    235236    void readTrigger(Button& button);
Note: See TracChangeset for help on using the changeset viewer.