Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 12, 2011, 11:34:40 AM (13 years ago)
Author:
landauf
Message:

implemented feature to reset the mouse cursor to the center
used in NewHumanController to set cursor to the center of the screen every time the ControllableEntity is changed
avoids turning of the spaceship right after spawn, if the player looked around in spectator mode

needs testing with derived mouse input (joysticks should be unchanged).
input system experts may have a look at this. ;)

Location:
code/trunk/src/libraries/core/input
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/input/HalfAxis.h

    r5781 r7859  
    5858        bool addParamCommand(ParamCommand* command);
    5959        void clear();
     60        void reset();
    6061
    6162        // axis related
     
    7778        return success;
    7879    }
     80
     81    inline void HalfAxis::reset()
     82    {
     83        this->relVal_ = 0.0f;
     84        this->absVal_ = 0.0f;
     85        this->hasChanged_ = true;
     86    }
    7987}
    8088
  • code/trunk/src/libraries/core/input/KeyBinder.cc

    r7401 r7859  
    388388    {
    389389        for (unsigned int iDev = 0; iDev < joySticks_.size(); ++iDev)
    390         {
    391390            for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
    392             {
    393                 (*joyStickAxes_[iDev])[i].absVal_ = 0.0f;
    394                 (*joyStickAxes_[iDev])[i].relVal_ = 0.0f;
    395             }
    396         }
     391                (*joyStickAxes_[iDev])[i].reset();
     392    }
     393
     394    /**
     395        @brief Sets the position of the mouse back to 0/0.
     396    */
     397    void KeyBinder::resetMouseAxes()
     398    {
     399        this->mousePosition_[0] = 0.0f;
     400        this->mousePosition_[1] = 0.0f;
     401
     402        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
     403            mouseAxes_[i].reset();
    397404    }
    398405
  • code/trunk/src/libraries/core/input/KeyBinder.h

    r6536 r7859  
    7474        void setConfigValues();
    7575        void resetJoyStickAxes();
     76        void resetMouseAxes();
    7677
    7778    protected: // functions
Note: See TracChangeset for help on using the changeset viewer.