Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/orxonox/InputHandler.h @ 929

Last change on this file since 929 was 929, checked in by rgrieder, 16 years ago
  • removed getRoot() from GaphicsEngine —> added getRenderWindow() —> added 3 function to control render loop
  • rearranged the sequence of methods in Orxonox.cc to make it a little bit more logical
  • added deletion code in Orxonox.cc destructor
  • fixed a bug in AudioManger destructor
  • fixed a bug in InputHandler destroy()
File size: 3.4 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Reto Grieder
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29 @file
30 @brief Implementation of a little Input handler that distributes everything
31        coming from OIS.
32 */
33
34#ifndef _InputHandler_H__
35#define _InputHandler_H__
36
37#include <OIS/OIS.h>
38
39#include "OrxonoxPrereqs.h"
40#include "core/Tickable.h"
41#include "InputEvent.h"
42
43namespace orxonox
44{
45  class _OrxonoxExport InputHandler
46        : public Tickable, public OIS::KeyListener, public OIS::MouseListener
47  {
48    //friend ClassIdentifier<InputHandler>;
49  public:
50    void initialise(size_t windowHnd, int windowWidth, int windowHeight);
51    void destroy();
52    void tick(float dt);
53    void setWindowExtents(int width, int height);
54
55    OIS::Mouse    *getMouse()    { return this->mouse_   ; }
56    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
57
58    static InputHandler* getSingleton();
59
60  private:
61    // don't mess with a Singleton
62    InputHandler ();
63    InputHandler (const InputHandler&);
64    InputHandler& operator=(const InputHandler& instance);
65    ~InputHandler();
66
67    void callListeners(InputEvent &evt);
68
69    // input events
70                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
71                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
72    bool mouseMoved   (const OIS::MouseEvent &arg);
73                bool keyPressed   (const OIS::KeyEvent   &arg);
74                bool keyReleased  (const OIS::KeyEvent   &arg);
75
76    OIS::InputManager *inputSystem_;    //!< OIS input manager
77    OIS::Keyboard     *keyboard_;       //!< OIS mouse
78    OIS::Mouse        *mouse_;          //!< OIS keyboard
79
80    /**
81      @bref Tells whether initialise has been called successfully
82      Also true if destroy() has been called.
83    */
84    bool uninitialized_;
85
86    //! denotes the maximum number of different keys there are in OIS.
87    //! 256 should be ok since the highest number in the enum is 237.
88    static const int numberOfKeys_ = 256;
89    //! Array of input events for every pressed key
90    InputEvent bindingsKeyPressed_[numberOfKeys_];
91    //! Array of input events for every released key
92    InputEvent bindingsKeyReleased_[numberOfKeys_];
93
94    //! denotes the maximum number of different buttons there are in OIS.
95    //! 16 should be ok since the highest number in the enum is 7.
96    static const int numberOfButtons_ = 16;
97    //! Array of input events for every pressed key
98    InputEvent bindingsButtonPressed_[numberOfButtons_];
99    //! Array of input events for every released key
100    InputEvent bindingsButtonReleased_[numberOfButtons_];
101
102  };
103}
104
105#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.