Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/InputHandler.h @ 1055

Last change on this file since 1055 was 1024, checked in by rgrieder, 17 years ago

merged input back into trunk
note: I have created an asylum with obsolete code, please check the files

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 Different definitions of input processing.
31 */
32
33#ifndef _InputHandler_H__
34#define _InputHandler_H__
35
36#include <string>
37
38#include <OIS/OIS.h>
39
40#include "CorePrereqs.h"
41#include "InputEvent.h"
42
43namespace orxonox
44{
45  /**
46    @brief Captures mouse and keyboard input while in the actual game mode.
47    Manages the key bindings.
48  */
49  class _CoreExport InputHandlerGame
50        : public OIS::KeyListener, public OIS::MouseListener
51  {
52  public:
53    InputHandlerGame ();
54    ~InputHandlerGame();
55
56    bool loadBindings();
57
58  private:
59    // input events
60                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
61                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
62    bool mouseMoved   (const OIS::MouseEvent &arg);
63                bool keyPressed   (const OIS::KeyEvent   &arg);
64                bool keyReleased  (const OIS::KeyEvent   &arg);
65
66    // temporary hack
67    void callListeners(InputEvent &evt);
68
69    /** denotes the maximum number of different keys there are in OIS.
70        256 should be ok since the highest number in the enum is 237. */
71    static const int numberOfKeys_s = 256;
72    //! Array of input events for every pressed key
73    std::string bindingsKeyPressed_[numberOfKeys_s];
74    //! Array of input events for every released key
75    std::string bindingsKeyReleased_[numberOfKeys_s];
76
77    /** denotes the maximum number of different buttons there are in OIS.
78        16 should be ok since the highest number in the enum is 7. */
79    static const int numberOfButtons_s = 16;
80    //! Array of input events for every pressed key
81    std::string bindingsButtonPressed_[numberOfButtons_s];
82    //! Array of input events for every released key
83    std::string bindingsButtonReleased_[numberOfButtons_s];
84
85  };
86
87
88  /**
89    @brief Captures mouse and keyboard input and distributes it to the
90    GUI.
91  */
92  class _CoreExport InputHandlerGUI
93        : public OIS::KeyListener, public OIS::MouseListener
94  {
95  public:
96    InputHandlerGUI ();
97    ~InputHandlerGUI();
98
99  private:
100    // input events
101                bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
102                bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
103    bool mouseMoved   (const OIS::MouseEvent &arg);
104                bool keyPressed   (const OIS::KeyEvent   &arg);
105                bool keyReleased  (const OIS::KeyEvent   &arg);
106  };
107
108}
109
110#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.