Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/core/InputHandler.h @ 1123

Last change on this file since 1123 was 1062, checked in by rgrieder, 17 years ago
  • changed header file inclusion order
File size: 3.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30 @file
31 @brief Different definitions of input processing.
32 */
33
34#ifndef _InputHandler_H__
35#define _InputHandler_H__
36
37#include "CorePrereqs.h"
38
39#include <string>
40#include <OIS/OIS.h>
41
42#include "InputEvent.h"
43
44namespace orxonox
45{
46  /**
47    @brief Captures mouse and keyboard input while in the actual game mode.
48    Manages the key bindings.
49  */
50  class _CoreExport InputHandlerGame
51        : public OIS::KeyListener, public OIS::MouseListener
52  {
53  public:
54    InputHandlerGame ();
55    ~InputHandlerGame();
56
57    bool loadBindings();
58
59  private:
60    // input events
61                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
62                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
63    bool mouseMoved   (const OIS::MouseEvent &arg);
64                bool keyPressed   (const OIS::KeyEvent   &arg);
65                bool keyReleased  (const OIS::KeyEvent   &arg);
66
67    // temporary hack
68    void callListeners(InputEvent &evt);
69
70    /** denotes the maximum number of different keys there are in OIS.
71        256 should be ok since the highest number in the enum is 237. */
72    static const int numberOfKeys_s = 256;
73    //! Array of input events for every pressed key
74    std::string bindingsKeyPressed_[numberOfKeys_s];
75    //! Array of input events for every released key
76    std::string bindingsKeyReleased_[numberOfKeys_s];
77
78    /** denotes the maximum number of different buttons there are in OIS.
79        16 should be ok since the highest number in the enum is 7. */
80    static const int numberOfButtons_s = 16;
81    //! Array of input events for every pressed key
82    std::string bindingsButtonPressed_[numberOfButtons_s];
83    //! Array of input events for every released key
84    std::string bindingsButtonReleased_[numberOfButtons_s];
85
86  };
87
88
89  /**
90    @brief Captures mouse and keyboard input and distributes it to the
91    GUI.
92  */
93  class _CoreExport InputHandlerGUI
94        : public OIS::KeyListener, public OIS::MouseListener
95  {
96  public:
97    InputHandlerGUI ();
98    ~InputHandlerGUI();
99
100  private:
101    // input events
102                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
103                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
104    bool mouseMoved   (const OIS::MouseEvent &arg);
105                bool keyPressed   (const OIS::KeyEvent   &arg);
106                bool keyReleased  (const OIS::KeyEvent   &arg);
107  };
108
109}
110
111#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.