Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 29, 2008, 11:13:11 PM (16 years ago)
Author:
rgrieder
Message:
  • InputManager fully functional (most parts tested), if there wasn't that selfish SpaceShip who claims all the mouse input…
  • InputHandler still loads hard coded key bindings, but works fine otherwise
  • I've tried to give full multiple joy stick support. Couldn't yet test that however. And more than one Joystick still doesn't make sense as long as we don't have split view ;)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/core/InputManager.h

    r1195 r1203  
    4343#include "ois/OIS.h"
    4444#include "Tickable.h"
    45 #include "InputEvent.h"
     45//#include "InputEvent.h"
     46#include "InputHandler.h"
    4647
    4748namespace orxonox
    4849{
     50  class Mouse : public OIS::Mouse
     51  {
     52  };
     53
    4954  /**
    5055    @brief Captures and distributes mouse and keyboard input.
     
    7075    };
    7176
    72   public: // functions
    73     // METHODS OF THE STATIC INTERFACE
    74 
     77  public: // static functions
    7578    static bool initialise(size_t windowHnd, int windowWidth, int windowHeight,
    7679          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
     80    static bool initialiseKeyboard();
     81    static bool initialiseMouse();
     82    static bool initialiseJoySticks();
     83
    7784    static void destroy();
     85    static void destroyKeyboard();
     86    static void destroyMouse();
     87    static void destroyJoySticks();
    7888
    7989    static void setWindowExtents(int width, int height);
     
    8595    static void setJoyStickButtonBindingState(bool bActive);
    8696
    87     static bool addKeyListener(OIS::KeyListener* listener, const std::string& name);
     97    static bool addKeyListener(KeyHandler* listener, const std::string& name);
    8898    static bool removeKeyListener  (const std::string& name);
    8999    static bool enableKeyListener  (const std::string& name);
    90100    static bool disableKeyListener (const std::string& name);
    91101    static bool isKeyListenerActive(const std::string& name);
    92     static OIS::KeyListener* getKeyListener(const std::string& name);
     102    static KeyHandler* getKeyListener(const std::string& name);
    93103
    94     static bool addMouseListener(OIS::MouseListener* listener, const std::string& name);
     104    static bool addMouseListener(MouseHandler* listener, const std::string& name);
    95105    static bool removeMouseListener  (const std::string& name);
    96106    static bool enableMouseListener  (const std::string& name);
    97107    static bool disableMouseListener (const std::string& name);
    98108    static bool isMouseListenerActive(const std::string& name);
    99     static OIS::MouseListener* getMouseListener(const std::string& name);
     109    static MouseHandler* getMouseListener(const std::string& name);
    100110
    101     static bool addJoyStickListener(OIS::JoyStickListener* listener, const std::string& name);
     111    static bool addJoyStickListener(JoyStickHandler* listener, const std::string& name);
    102112    static bool removeJoyStickListener  (const std::string& name);
    103     static bool enableJoyStickListener  (const std::string& name);
    104     static bool disableJoyStickListener (const std::string& name);
     113    static bool enableJoyStickListener  (const std::string& name, const int id);
     114    static bool disableJoyStickListener (const std::string& name, const int id);
    105115    static bool isJoyStickListenerActive(const std::string& name);
    106     static OIS::JoyStickListener* getJoyStickListener(const std::string& name);
     116    static JoyStickHandler* getJoyStickListener(const std::string& name);
    107117
    108118    // Temporary solutions. Will be removed soon!
     
    118128    // Intenal methods
    119129    bool _initialise(size_t, int, int, bool, bool, bool);
    120     void _initialiseKeyboard();
    121     void _initialiseMouse();
    122     void _initialiseJoySticks();
     130    bool _initialiseKeyboard();
     131    bool _initialiseMouse();
     132    bool _initialiseJoySticks();
     133
    123134    void _destroy();
    124     //void _setDefaultState();
    125     bool _loadBindings();
    126     void _clearBindings();
    127     void _setNumberOfJoysticks(int size);
     135    void _destroyKeyboard();
     136    void _destroyMouse();
     137    void _destroyJoySticks();
     138
     139    //void _setNumberOfJoysticks(int size);
    128140
    129141    void tick(float dt);
     
    145157
    146158  private: // variables
    147     OIS::InputManager* inputSystem_;    //!< OIS input manager
    148     OIS::Keyboard*     keyboard_;       //!< OIS mouse
    149     OIS::Mouse*        mouse_;          //!< OIS keyboard
    150     std::vector<OIS::JoyStick*> joySticks_;       //!< OIS joy sticks
     159    OIS::InputManager* inputSystem_;            //!< OIS input manager
     160    OIS::Keyboard*     keyboard_;               //!< OIS mouse
     161    OIS::Mouse*        mouse_;                  //!< OIS keyboard
     162    std::map<int, OIS::JoyStick*> joySticks_;   //!< OIS joy sticks
    151163
    152164    InputState state_;
    153165    InputState stateRequest_;
    154166
    155     bool bKeyBindingsActive_;
    156     bool bMouseButtonBindingsActive_;
    157     std::vector<bool> bJoyStickButtonBindingsActive_;
     167    std::map<std::string, KeyHandler*>      listenersKey_;
     168    std::map<std::string, MouseHandler*>    listenersMouse_;
     169    std::map<std::string, JoyStickHandler*> listenersJoySticks_;
    158170
    159     std::map<std::string, OIS::KeyListener*>      listenersKey_;
    160     std::map<std::string, OIS::MouseListener*>    listenersMouse_;
    161     std::map<std::string, OIS::JoyStickListener*> listenersJoySticks_;
    162 
    163     std::list<OIS::KeyListener*>      listenersKeyActive_;
    164     std::list<OIS::MouseListener*>    listenersMouseActive_;
    165     std::list<OIS::JoyStickListener*> listenersJoySticksActive_;
     171    std::list<KeyHandler*>      listenersKeyActive_;
     172    std::list<MouseHandler*>    listenersMouseActive_;
     173    std::map< int, std::list<JoyStickHandler*> > listenersJoySticksActive_;
    166174
    167175    std::list<OIS::KeyCode>         keysDown_;
    168176    std::list<OIS::MouseButtonID>   mouseButtonsDown_;
    169     std::vector< std::list<int> >   joyStickButtonsDown_;
    170 
    171 
    172     /** denotes the maximum number of different keys there are in OIS.
    173         256 should be ok since the highest number in the OIS enum is 237. */
    174     static const int numberOfKeys_s = 256;
    175     //! Array of input events for every pressed key
    176     std::string bindingsKeyPress_  [numberOfKeys_s];
    177     //! Array of input events for every released key
    178     std::string bindingsKeyRelease_[numberOfKeys_s];
    179     //! Array of input events for every held key
    180     std::string bindingsKeyHold_   [numberOfKeys_s];
    181 
    182     /** denotes the maximum number of different buttons there are in OIS.
    183         16 should be ok since the highest number in the OIS enum is 7. */
    184     static const int numberOfMouseButtons_s = 16;
    185     //! Array of input events for every pressed mouse button
    186     std::string bindingsMouseButtonPress_  [numberOfMouseButtons_s];
    187     //! Array of input events for every released mouse button
    188     std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s];
    189     //! Array of input events for every held mouse button
    190     std::string bindingsMouseButtonHold_   [numberOfMouseButtons_s];
    191 
    192     /** denotes the maximum number of different buttons there are in OIS.
    193         32 should be ok. */
    194     static const int numberOfJoyStickButtons_s = 32;
    195     std::vector< std::vector< std::string > > bindingsJoyStickButtonPress_;
    196     std::vector< std::vector< std::string > > bindingsJoyStickButtonRelease_;
    197     std::vector< std::vector< std::string > > bindingsJoyStickButtonHold_;
     177    std::map< int, std::list<int> > joySticksButtonsDown_;
    198178
    199179  };
Note: See TracChangeset for help on using the changeset viewer.