Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 928 was 928, checked in by rgrieder, 16 years ago
  • added destroy code for the InputHandler
File size: 3.2 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() { }
65
66    void callListeners(InputEvent &evt);
67
68    // input events
69                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
70                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
71    bool mouseMoved   (const OIS::MouseEvent &arg);
72                bool keyPressed   (const OIS::KeyEvent   &arg);
73                bool keyReleased  (const OIS::KeyEvent   &arg);
74
75    OIS::InputManager *inputSystem_;    //!< OIS input manager
76    OIS::Keyboard     *keyboard_;       //!< OIS mouse
77    OIS::Mouse        *mouse_;          //!< OIS keyboard
78
79    //! denotes the maximum number of different keys there are in OIS.
80    //! 256 should be ok since the highest number in the enum is 237.
81    static const int numberOfKeys_ = 256;
82    //! Array of input events for every pressed key
83    InputEvent bindingsKeyPressed_[numberOfKeys_];
84    //! Array of input events for every released key
85    InputEvent bindingsKeyReleased_[numberOfKeys_];
86
87    //! denotes the maximum number of different buttons there are in OIS.
88    //! 16 should be ok since the highest number in the enum is 7.
89    static const int numberOfButtons_ = 16;
90    //! Array of input events for every pressed key
91    InputEvent bindingsButtonPressed_[numberOfButtons_];
92    //! Array of input events for every released key
93    InputEvent bindingsButtonReleased_[numberOfButtons_];
94
95  };
96}
97
98#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.