Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1259


Ignore:
Timestamp:
May 12, 2008, 7:06:49 PM (16 years ago)
Author:
rgrieder
Message:

many minor changes, but it's more of a 'svn save' since I'm gonna start rewriting parts of the keybinder

Location:
code/branches/input
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/bin/keybindings.ini

    r1219 r1259  
    2424R_6=
    2525H_6=
    26 P_7=
     26P_7="exec disco.txt"
    2727R_7=
    2828H_7=
     
    3030R_8=
    3131H_8=
    32 P_9=
     32P_9="disco.txt"
    3333R_9=
    3434H_9=
  • code/branches/input/src/core/InputBuffer.cc

    r1237 r1259  
    3737namespace orxonox
    3838{
    39   InputBuffer::InputBuffer(const std::string allowedChars)
     39  InputBuffer::InputBuffer(const std::string allowedChars) :
     40    buffer_(""),
     41    allowedChars_(allowedChars),
     42    lastKey_(KeyCode::Unassigned),
     43    timeSinceKeyPressed_(0.0f),
     44    timeSinceKeyRepeated_(0.0f),
     45    keysToRepeat_(0)
    4046  {
    4147    RegisterObject(InputBuffer);
    4248    setConfigValues();
    43     allowedChars_ = allowedChars;
    44     buffer_ = "";
    45     lastKey_ = KeyCode::Unassigned;
    46     timeSinceKeyPressed_ = 0.0;
    47     timeSinceKeyRepeated_ = 0.0;
    48     keysToRepeat_ = 0;
    4949  }
    5050
  • code/branches/input/src/core/InputBuffer.h

    r1237 r1259  
    9898    { return this->buffer_; }
    9999
    100   private:
     100  private:  // functions
    101101    bool charIsAllowed(const char& input);
    102102
     
    108108    void tick(float dt);
    109109
     110  private: // variables
    110111    std::string buffer_;
    111112    std::list<InputBufferListenerTuple> listeners_;
  • code/branches/input/src/core/InputHandler.cc

    r1237 r1259  
    229229
    230230    std::string mouseButtonNames[] = {
    231     "MouseLeft", "MouseRight", "MouseMiddle",
    232     "MouseButton3", "MouseButton4", "MouseButton5",
    233     "MouseButton6", "MouseButton7" };
     231      "MouseLeft", "MouseRight", "MouseMiddle",
     232      "MouseButton3", "MouseButton4", "MouseButton5",
     233      "MouseButton6", "MouseButton7" };
    234234    for (int i = 0; i < numberOfMouseButtons_s; i++)
    235235      mouseButtonNames_[i] = mouseButtonNames[i];
     
    381381  }
    382382
    383   bool KeyBinder::executeBinding(KeyBinding& binding)
     383  bool KeyBinder::executeSimpleBinding(KeyBinding& binding)
    384384  {
    385385    if (binding.commandStr != "")
     
    406406  {
    407407    // find the appropriate key binding
    408     executeBinding(bindingsKeyPress_[int(evt.key)]);
     408    executeSimpleBinding(bindingsKeyPress_[int(evt.key)]);
    409409
    410410    return true;
     
    418418  {
    419419    // find the appropriate key binding
    420     executeBinding(bindingsKeyRelease_[int(evt.key)]);
     420    executeSimpleBinding(bindingsKeyRelease_[int(evt.key)]);
    421421
    422422    return true;
     
    430430  {
    431431    // find the appropriate key binding
    432     executeBinding(bindingsKeyHold_[int(evt.key)]);
     432    executeSimpleBinding(bindingsKeyHold_[int(evt.key)]);
    433433
    434434    return true;
     
    441441  bool KeyBinder::mouseMoved(const MouseState &evt)
    442442  {
    443     return true;
    444   }
    445 
    446   /**
    447     @brief Event handler for the mouseWheelTurned Event.
     443    /*if (bindingMouseMoved_.commandStr != "")
     444    {
     445      if (bindingMouseMoved_.commandStr != bindingMouseMoved_.evaluation.getCommandString())
     446      {
     447        // key binding has changed, reevaluate the command string.
     448        bindingMouseMoved_.evaluation = CommandExecutor::evaluate(bindingMouseMoved_.commandStr);
     449        bindingMouseMoved_.commandStr = bindingMouseMoved_.evaluation.getCommandString();
     450      }
     451      COUT(3) << "Executing command: " << bindingMouseMoved_.commandStr << std::endl;
     452
     453      bindingMouseMoved_.evaluation.setEvaluatedParameter(
     454      CommandExecutor::execute(bindingMouseMoved_.commandStr);
     455    }*/
     456
     457    return true;
     458  }
     459
     460  /**
     461    @brief Event handler for the mouseScrolled Event.
    448462    @param e Mouse state information
    449463  */
    450   bool KeyBinder::mouseWheelTurned(const MouseState &evt)
     464  bool KeyBinder::mouseScrolled(const MouseState &evt)
    451465  {
    452466    return true;
     
    461475  {
    462476    // find the appropriate key binding
    463     executeBinding(bindingsMouseButtonPress_[int(id)]);
     477    executeSimpleBinding(bindingsMouseButtonPress_[int(id)]);
    464478
    465479    return true;
     
    474488  {
    475489    // find the appropriate key binding
    476     executeBinding(bindingsMouseButtonRelease_[int(id)]);
     490    executeSimpleBinding(bindingsMouseButtonRelease_[int(id)]);
    477491
    478492    return true;
     
    487501  {
    488502    // find the appropriate key binding
    489     executeBinding(bindingsMouseButtonHold_[int(id)]);
     503    executeSimpleBinding(bindingsMouseButtonHold_[int(id)]);
    490504
    491505    return true;
     
    495509  {
    496510    // find the appropriate key binding
    497     executeBinding(bindingsJoyStickButtonPress_[button]);
     511    executeSimpleBinding(bindingsJoyStickButtonPress_[button]);
    498512
    499513    return true;
     
    503517  {
    504518    // find the appropriate key binding
    505     executeBinding(bindingsJoyStickButtonRelease_[button]);
     519    executeSimpleBinding(bindingsJoyStickButtonRelease_[button]);
    506520
    507521    return true;
     
    511525  {
    512526    // find the appropriate key binding
    513     executeBinding(bindingsJoyStickButtonHold_[button]);
     527    executeSimpleBinding(bindingsJoyStickButtonHold_[button]);
    514528
    515529    return true;
  • code/branches/input/src/core/InputHandler.h

    r1237 r1259  
    7979    void setConfigValues();
    8080
    81     std::string testtest;
    82 
    8381  private: // functions
    8482
    85     bool executeBinding(KeyBinding &binding);
     83    bool executeSimpleBinding(KeyBinding &binding);
    8684
    8785    bool keyPressed (const KeyEvent& evt);
     
    9391    bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id);
    9492    bool mouseMoved         (const MouseState& state);
    95     bool mouseWheelTurned   (const MouseState& state);
     93    bool mouseScrolled      (const MouseState& state);
    9694
    9795    bool joyStickButtonPressed (const JoyStickState& state, int button);
     
    124122    //! Array of input events for every held mouse button
    125123    KeyBinding bindingsMouseButtonHold_   [numberOfMouseButtons_s];
     124    //! Key binding for mouse moved event
     125    KeyBinding bindingMouseMoved_;
     126    //! Key binding for mouse scrolled event
     127    KeyBinding bindingMouseScrolled_;
    126128    //! Names of the mouse buttons as strings
    127129    std::string mouseButtonNames_[numberOfMouseButtons_s];
  • code/branches/input/src/core/InputInterfaces.h

    r1238 r1259  
    4848      Unassigned    = OIS::KC_UNASSIGNED, 
    4949      Escape        = OIS::KC_ESCAPE,     
    50       _1            = OIS::KC_1,           
    51       _2            = OIS::KC_2,           
    52       _3            = OIS::KC_3,           
    53       _4            = OIS::KC_4,           
    54       _5            = OIS::KC_5,           
    55       _6            = OIS::KC_6,           
    56       _7            = OIS::KC_7,           
    57       _8            = OIS::KC_8,           
    58       _9            = OIS::KC_9,           
    59       _0            = OIS::KC_0,           
     50      NumRow1       = OIS::KC_1,           
     51      NumRow2       = OIS::KC_2,           
     52      NumRow3       = OIS::KC_3,           
     53      NumRow4       = OIS::KC_4,           
     54      NumRow5       = OIS::KC_5,           
     55      NumRow6       = OIS::KC_6,           
     56      NumRow7       = OIS::KC_7,           
     57      NumRow8       = OIS::KC_8,           
     58      NumRow9       = OIS::KC_9,           
     59      NumRow0       = OIS::KC_0,           
    6060      Minus         = OIS::KC_MINUS,           // - on main keyboard
    6161      Equals        = OIS::KC_EQUALS,     
     
    244244  {
    245245  public:
    246     JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), JoyStickID(ID) { }
     246    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }
    247247    JoyStickState() { clear(); }
    248     int JoyStickID;
     248    int mJoyStickID;
    249249  };
    250250
     
    272272    virtual bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) = 0;
    273273    virtual bool mouseMoved         (const MouseState& state) = 0;
    274     virtual bool mouseWheelTurned   (const MouseState& state) = 0;
     274    virtual bool mouseScrolled      (const MouseState& state) = 0;
    275275  };
    276276
  • code/branches/input/src/core/InputManager.cc

    r1239 r1259  
    5252  InputManager::InputManager() :
    5353      inputSystem_(0), keyboard_(0), mouse_(0),
     54      joySticksSize_(0),
    5455      state_(IS_UNINIT), stateRequest_(IS_UNINIT),
    55       joySticksSize_(0)
     56      keyboardModifiers_(0)
    5657  {
    5758    RegisterObject(InputManager);
    58 
    59     //this->joySticks_.reserve(5);
    60     //this->activeJoyStickHandlers_.reserve(10);
    61     this->activeKeyHandlers_.reserve(10);
    62     this->activeMouseHandlers_.reserve(10);
    6359  }
    6460
     
    8884    @param windowHeight The height of the render window
    8985  */
    90   bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    91         const bool createKeyboard, const bool createMouse, const bool createJoySticks)
     86  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     87        bool createKeyboard, bool createMouse, bool createJoySticks)
    9288  {
    9389    if (state_ == IS_UNINIT)
     
    146142    addKeyHandler(binder, "keybinder");
    147143    addMouseHandler(binder, "keybinder");
     144    addJoyStickHandler(binder, "keybinder");
    148145
    149146    // Read all the key bindings and assign them
     
    267264    }
    268265    joySticksSize_ = joySticks_.size();
     266    activeJoyStickHandlers_.resize(joySticksSize_);
     267    joyStickButtonsDown_.resize(joySticksSize_);
    269268    return success;
    270269  }
     
    375374        activeKeyHandlers_.clear();
    376375        activeMouseHandlers_.clear();
    377         activeJoyStickHandlers_.clear();
     376        for (unsigned int i = 0; i < joySticksSize_; i++)
     377          activeJoyStickHandlers_[i].clear();
    378378
    379379        switch (stateRequest_)
     
    414414    if (keyboard_)
    415415      keyboard_->capture();
     416    for (unsigned  int i = 0; i < joySticksSize_; i++)
     417      joySticks_[i]->capture();
    416418
    417419
     
    428430    // call all the handlers for the held joy stick button events
    429431    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
    430       for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_.size(); iButton++)
     432      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
    431433        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
    432434          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(
     
    509511    }
    510512
    511     // check for mouse wheel turned event
     513    // check for mouse scrolled event
    512514    if (e.state.Z.rel != 0)
    513515    {
    514516      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    515         activeMouseHandlers_[i]->mouseWheelTurned(e.state);
     517        activeMouseHandlers_[i]->mouseScrolled(e.state);
    516518    }
    517519
     
    674676  // ################################
    675677
    676   bool InputManager::initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    677     const bool createKeyboard, const bool createMouse, const bool createJoySticks)
     678  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     679    bool createKeyboard, bool createMouse, bool createJoySticks)
    678680  {
    679681    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
  • code/branches/input/src/core/InputManager.h

    r1237 r1259  
    3939
    4040#include <map>
    41 #include <list>
     41#include <vector>
    4242
    4343#include "ois/OIS.h"
     
    6969
    7070  public: // static functions
    71     static bool initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    72           const bool createKeyboard = true, const bool createMouse = true, const bool createJoySticks = false);
     71    static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     72          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
    7373    static bool initialiseKeyboard();
    7474    static bool initialiseMouse();
     
    121121
    122122    // Intenal methods
    123     bool _initialise(const size_t, const int, const int, const bool, const bool, const bool);
     123    bool _initialise(const size_t, int, int, bool, bool, bool);
    124124    bool _initialiseKeyboard();
    125125    bool _initialiseMouse();
     
    169169
    170170    std::vector<Key>                            keysDown_;
    171     std::vector<MouseButton::Enum>            mouseButtonsDown_;
     171    std::vector<MouseButton::Enum>              mouseButtonsDown_;
    172172    std::vector<std::vector<int> >              joyStickButtonsDown_;
    173173
  • code/branches/input/src/core/SignalHandler.cc

    r1240 r1259  
    6565
    6666  // prepare for restoring XAutoKeyRepeat
    67     Display* display;
    68         if ((display = XOpenDisplay(0)))
    69   {
    70             XKeyboardState oldState;
    71                 XGetKeyboardControl(display, &oldState);
    72                 if (oldState.global_auto_repeat == AutoRepeatModeOn)
    73           bXAutoKeyRepeatOn_ = true;
    74                 else
    75                   bXAutoKeyRepeatOn_ = false;
    76                 XCloseDisplay(display);
     67  Display* display;
     68  if ((display = XOpenDisplay(0)))
     69  {
     70    XKeyboardState oldState;
     71    XGetKeyboardControl(display, &oldState);
     72    if (oldState.global_auto_repeat == AutoRepeatModeOn)
     73      bXAutoKeyRepeatOn_ = true;
     74    else
     75      bXAutoKeyRepeatOn_ = false;
     76    XCloseDisplay(display);
    7777  }
    7878  else
  • code/branches/input/src/orxonox/Orxonox.cc

    r1219 r1259  
    401401  {
    402402    if (!InputManager::initialise(ogre_->getWindowHandle(),
    403           ogre_->getWindowWidth(), ogre_->getWindowHeight()))
     403          ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
    404404      abortImmediateForce();
    405405    InputManager::setInputState(InputManager::IS_NORMAL);
  • code/branches/input/src/orxonox/objects/SpaceShip.h

    r1236 r1259  
    6969            bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) { return true; }
    7070            bool mouseMoved         (const MouseState& state);
    71             bool mouseWheelTurned   (const MouseState& state) { return true; }
     71            bool mouseScrolled      (const MouseState& state) { return true; }
    7272
    7373
  • code/branches/input/visual_studio/vc8/ois.vcproj

    r1219 r1259  
    560560                                </File>
    561561                        </Filter>
     562                        <Filter
     563                                Name="linux"
     564                                >
     565                                <File
     566                                        RelativePath="..\..\src\ois\linux\EventHelpers.cpp"
     567                                        >
     568                                        <FileConfiguration
     569                                                Name="Release|Win32"
     570                                                ExcludedFromBuild="true"
     571                                                >
     572                                                <Tool
     573                                                        Name="VCCLCompilerTool"
     574                                                />
     575                                        </FileConfiguration>
     576                                        <FileConfiguration
     577                                                Name="Debug|Win32"
     578                                                ExcludedFromBuild="true"
     579                                                >
     580                                                <Tool
     581                                                        Name="VCCLCompilerTool"
     582                                                />
     583                                        </FileConfiguration>
     584                                </File>
     585                                <File
     586                                        RelativePath="..\..\src\ois\linux\LinuxForceFeedback.cpp"
     587                                        >
     588                                        <FileConfiguration
     589                                                Name="Release|Win32"
     590                                                ExcludedFromBuild="true"
     591                                                >
     592                                                <Tool
     593                                                        Name="VCCLCompilerTool"
     594                                                />
     595                                        </FileConfiguration>
     596                                        <FileConfiguration
     597                                                Name="Debug|Win32"
     598                                                ExcludedFromBuild="true"
     599                                                >
     600                                                <Tool
     601                                                        Name="VCCLCompilerTool"
     602                                                />
     603                                        </FileConfiguration>
     604                                </File>
     605                                <File
     606                                        RelativePath="..\..\src\ois\linux\LinuxInputManager.cpp"
     607                                        >
     608                                        <FileConfiguration
     609                                                Name="Release|Win32"
     610                                                ExcludedFromBuild="true"
     611                                                >
     612                                                <Tool
     613                                                        Name="VCCLCompilerTool"
     614                                                />
     615                                        </FileConfiguration>
     616                                        <FileConfiguration
     617                                                Name="Debug|Win32"
     618                                                ExcludedFromBuild="true"
     619                                                >
     620                                                <Tool
     621                                                        Name="VCCLCompilerTool"
     622                                                />
     623                                        </FileConfiguration>
     624                                </File>
     625                                <File
     626                                        RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.cpp"
     627                                        >
     628                                        <FileConfiguration
     629                                                Name="Release|Win32"
     630                                                ExcludedFromBuild="true"
     631                                                >
     632                                                <Tool
     633                                                        Name="VCCLCompilerTool"
     634                                                />
     635                                        </FileConfiguration>
     636                                        <FileConfiguration
     637                                                Name="Debug|Win32"
     638                                                ExcludedFromBuild="true"
     639                                                >
     640                                                <Tool
     641                                                        Name="VCCLCompilerTool"
     642                                                />
     643                                        </FileConfiguration>
     644                                </File>
     645                                <File
     646                                        RelativePath="..\..\src\ois\linux\LinuxKeyboard.cpp"
     647                                        >
     648                                        <FileConfiguration
     649                                                Name="Release|Win32"
     650                                                ExcludedFromBuild="true"
     651                                                >
     652                                                <Tool
     653                                                        Name="VCCLCompilerTool"
     654                                                />
     655                                        </FileConfiguration>
     656                                        <FileConfiguration
     657                                                Name="Debug|Win32"
     658                                                ExcludedFromBuild="true"
     659                                                >
     660                                                <Tool
     661                                                        Name="VCCLCompilerTool"
     662                                                />
     663                                        </FileConfiguration>
     664                                </File>
     665                                <File
     666                                        RelativePath="..\..\src\ois\linux\LinuxMouse.cpp"
     667                                        >
     668                                        <FileConfiguration
     669                                                Name="Release|Win32"
     670                                                ExcludedFromBuild="true"
     671                                                >
     672                                                <Tool
     673                                                        Name="VCCLCompilerTool"
     674                                                />
     675                                        </FileConfiguration>
     676                                        <FileConfiguration
     677                                                Name="Debug|Win32"
     678                                                ExcludedFromBuild="true"
     679                                                >
     680                                                <Tool
     681                                                        Name="VCCLCompilerTool"
     682                                                />
     683                                        </FileConfiguration>
     684                                </File>
     685                        </Filter>
    562686                </Filter>
    563687                <Filter
     
    650774                                <File
    651775                                        RelativePath="..\..\src\ois\OISInterface.h"
     776                                        >
     777                                </File>
     778                        </Filter>
     779                        <Filter
     780                                Name="linux"
     781                                >
     782                                <File
     783                                        RelativePath="..\..\src\ois\linux\EventHelpers.h"
     784                                        >
     785                                </File>
     786                                <File
     787                                        RelativePath="..\..\src\ois\linux\LinuxForceFeedback.h"
     788                                        >
     789                                </File>
     790                                <File
     791                                        RelativePath="..\..\src\ois\linux\LinuxInputManager.h"
     792                                        >
     793                                </File>
     794                                <File
     795                                        RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.h"
     796                                        >
     797                                </File>
     798                                <File
     799                                        RelativePath="..\..\src\ois\linux\LinuxKeyboard.h"
     800                                        >
     801                                </File>
     802                                <File
     803                                        RelativePath="..\..\src\ois\linux\LinuxMouse.h"
     804                                        >
     805                                </File>
     806                                <File
     807                                        RelativePath="..\..\src\ois\linux\LinuxPrereqs.h"
    652808                                        >
    653809                                </File>
Note: See TracChangeset for help on using the changeset viewer.