Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 926 was 922, checked in by rgrieder, 16 years ago
  • created InputEventListener and InputEvent
  • escape key now works through the InputHandler
  • the concept will soon be replaced by a new one this is more of a 'svn save' ;)
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 tick(float dt);
52    void setWindowExtents(int width, int height);
53
54    OIS::Mouse    *getMouse()    { return this->mouse_   ; }
55    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
56
57    static InputHandler* getSingleton();
58
59  private:
60    // don't mess with a Singleton
61    InputHandler ();
62    InputHandler (const InputHandler&) { }
63    ~InputHandler() { }
64
65    void callListeners(InputEvent &evt);
66
67    // input events
68                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
69                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
70    bool mouseMoved   (const OIS::MouseEvent &arg);
71                bool keyPressed   (const OIS::KeyEvent   &arg);
72                bool keyReleased  (const OIS::KeyEvent   &arg);
73
74    OIS::InputManager *inputSystem_;    //!< OIS input manager
75    OIS::Keyboard     *keyboard_;       //!< OIS mouse
76    OIS::Mouse        *mouse_;          //!< OIS keyboard
77
78    //! denotes the maximum number of different keys there are in OIS.
79    //! 256 should be ok since the highest number in the enum is 237.
80    static const int numberOfKeys_ = 256;
81    //! Array of input events for every pressed key
82    InputEvent bindingsKeyPressed_[numberOfKeys_];
83    //! Array of input events for every released key
84    InputEvent bindingsKeyReleased_[numberOfKeys_];
85
86    //! denotes the maximum number of different buttons there are in OIS.
87    //! 16 should be ok since the highest number in the enum is 7.
88    static const int numberOfButtons_ = 16;
89    //! Array of input events for every pressed key
90    InputEvent bindingsButtonPressed_[numberOfButtons_];
91    //! Array of input events for every released key
92    InputEvent bindingsButtonReleased_[numberOfButtons_];
93
94  };
95}
96
97#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.