Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2008, 1:50:28 PM (16 years ago)
Author:
rgrieder
Message:
  • OIS initialise should be complete, but need to use cmake to determine version number..
  • merged trunk back
File:
1 edited

Legend:

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

    r1182 r1193  
    5656          public OIS::MouseListener, public OIS::KeyListener, public OIS::JoyStickListener
    5757  {
    58   public:
     58  public: // enumerations
    5959    /**
    60       @brief Designates the way input is handled currently.
    61       IM_GUI:    All the OIS input events are passed to CEGUI
    62       IM_BUFFER: Only keyboard input is captured and passed to the InputBuffer
    63       IM_NORMAL: Normal game mode. Key bindings and mouse are active.
     60      @brief Designates the way input is handled and redirected.
    6461    */
    6562    enum InputState
    6663    {
    67       IS_UNINIT,
    68       IS_NONE,
    69       IS_NORMAL,
    70       IS_GUI,
    71       IS_CONSOLE,
    72       IS_CUSTOM
     64      IS_UNINIT,  //!< InputManager has not yet been initialised.
     65      IS_NONE,    //!< Input is discarded.
     66      IS_NORMAL,  //!< Normal play state. Key and button bindings are active.
     67      IS_GUI,     //!< All OIS input events are passed to CEGUI.
     68      IS_CONSOLE, //!< Keyboard input is redirected to the InputBuffer.
     69      IS_CUSTOM   //!< Any possible configuration.
    7370    };
    7471
    75   public:
    76     void tick(float dt);
    77 
    78     static bool initialise(size_t windowHnd, int windowWidth, int windowHeight);
     72  public: // functions
     73    // METHODS OF THE STATIC INTERFACE
     74
     75    static bool initialise(size_t windowHnd, int windowWidth, int windowHeight,
     76          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
    7977    static void destroy();
    8078
    8179    static void setWindowExtents(int width, int height);
     80
    8281    static void setInputState(const InputState state);
    8382    static InputState getInputState();
     83    static void setKeyBindingState           (bool bActive);
     84    static void setMouseButtonBindingState   (bool bActive);
     85    static void setJoyStickButtonBindingState(bool bActive);
    8486
    8587    static bool addKeyListener(OIS::KeyListener* listener, const std::string& name);
    86     //static bool removeKeyListener(OIS::KeyListener* listener);
    87     static bool removeKeyListener(const std::string& name);
    88     static bool enableKeyListener(const std::string& name);
    89     static bool disableKeyListener(const std::string& name);
     88    static bool removeKeyListener  (const std::string& name);
     89    static bool enableKeyListener  (const std::string& name);
     90    static bool disableKeyListener (const std::string& name);
     91    static bool isKeyListenerActive(const std::string& name);
    9092    static OIS::KeyListener* getKeyListener(const std::string& name);
    91     static bool isKeyListenerActive(const std::string& name);
    9293
    9394    static bool addMouseListener(OIS::MouseListener* listener, const std::string& name);
    94     //static bool removeMouseListener(OIS::MouseListener* listener);
    95     static bool removeMouseListener(const std::string& name);
    96     static bool enableMouseListener(const std::string& name);
    97     static bool disableMouseListener(const std::string& name);
     95    static bool removeMouseListener  (const std::string& name);
     96    static bool enableMouseListener  (const std::string& name);
     97    static bool disableMouseListener (const std::string& name);
     98    static bool isMouseListenerActive(const std::string& name);
    9899    static OIS::MouseListener* getMouseListener(const std::string& name);
    99     static bool isMouseListenerActive(const std::string& name);
    100100
    101101    static bool addJoyStickListener(OIS::JoyStickListener* listener, const std::string& name);
    102     //static bool removeJoyStickListener(OIS::JoyStickListener* listener);
    103     static bool removeJoyStickListener(const std::string& name);
    104     static bool enableJoyStickListener(const std::string& name);
    105     static bool disableJoyStickListener(const std::string& name);
     102    static bool removeJoyStickListener  (const std::string& name);
     103    static bool enableJoyStickListener  (const std::string& name);
     104    static bool disableJoyStickListener (const std::string& name);
     105    static bool isJoyStickListenerActive(const std::string& name);
    106106    static OIS::JoyStickListener* getJoyStickListener(const std::string& name);
    107     static bool isJoyStickListenerActive(const std::string& name);
    108107
    109108    // Temporary solutions. Will be removed soon!
     
    111110    static OIS::Keyboard* getKeyboard() { return _getSingleton().keyboard_; }
    112111
    113   private:
     112  private: // functions
    114113    // don't mess with a Singleton
    115114    InputManager ();
     
    117116    ~InputManager();
    118117
    119     bool _initialise(size_t windowHnd, int windowWidth, int windowHeight);
     118    // Intenal methods
     119    bool _initialise(size_t, int, int, bool, bool, bool);
     120    void _initialiseKeyboard();
     121    void _initialiseMouse();
     122    void _initialiseJoySticks();
    120123    void _destroy();
    121     void _setDefaultState();
    122     void _loadBindings();
     124    //void _setDefaultState();
     125    bool _loadBindings();
     126    void _clearBindings();
     127    void _setNumberOfJoysticks(int size);
     128
     129    void tick(float dt);
    123130
    124131    // input events
     
    137144    static InputManager* _getSingletonPtr() { return &_getSingleton(); }
    138145
    139   private:
     146  private: // variables
    140147    OIS::InputManager* inputSystem_;    //!< OIS input manager
    141148    OIS::Keyboard*     keyboard_;       //!< OIS mouse
    142149    OIS::Mouse*        mouse_;          //!< OIS keyboard
     150    std::vector<OIS::JoyStick*> joySticks_;       //!< OIS joy sticks
    143151
    144152    InputState state_;
    145153    InputState stateRequest_;
    146154
    147     std::list<OIS::KeyCode> keysDown_;
    148 
    149     bool bDefaultKeyInput;
    150     bool bDefaultMouseInput;
    151     bool bDefaultJoyStickInput;
    152 
    153     std::map<std::string, OIS::KeyListener*>      keyListeners_;
    154     std::list<OIS::KeyListener*>                  activeKeyListeners_;
    155     std::map<std::string, OIS::MouseListener*>    mouseListeners_;
    156     std::list<OIS::MouseListener*>                activeMouseListeners_;
    157     std::map<std::string, OIS::JoyStickListener*> joystickListeners_;
    158     std::list<OIS::JoyStickListener*>             activeJoyStickListeners_;
     155    bool bKeyBindingsActive_;
     156    bool bMouseButtonBindingsActive_;
     157    std::vector<bool> bJoyStickButtonBindingsActive_;
     158
     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_;
     166
     167    std::list<OIS::KeyCode>         keysDown_;
     168    std::list<OIS::MouseButtonID>   mouseButtonsDown_;
     169    std::vector< std::list<int> >   joyStickButtonsDown_;
    159170
    160171
    161172    /** denotes the maximum number of different keys there are in OIS.
    162         256 should be ok since the highest number in the enum is 237. */
     173        256 should be ok since the highest number in the OIS enum is 237. */
    163174    static const int numberOfKeys_s = 256;
    164175    //! Array of input events for every pressed key
     
    170181
    171182    /** denotes the maximum number of different buttons there are in OIS.
    172         16 should be ok since the highest number in the enum is 7. */
     183        16 should be ok since the highest number in the OIS enum is 7. */
    173184    static const int numberOfMouseButtons_s = 16;
    174185    //! Array of input events for every pressed mouse button
     
    182193        32 should be ok. */
    183194    static const int numberOfJoyStickButtons_s = 32;
    184     //! Array of input events for every pressed joystick button
    185     std::string bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
    186     //! Array of input events for every released joystick button
    187     std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
    188     //! Array of input events for every held joystick button
    189     std::string bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
     195    std::vector< std::vector< std::string > > bindingsJoyStickButtonPress_;
     196    std::vector< std::vector< std::string > > bindingsJoyStickButtonRelease_;
     197    std::vector< std::vector< std::string > > bindingsJoyStickButtonHold_;
    190198
    191199  };
Note: See TracChangeset for help on using the changeset viewer.