Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core4/src/core/input/InputHandler.h @ 3275

Last change on this file since 3275 was 3274, checked in by rgrieder, 15 years ago

Added a few more generic parts to the input library:

  • Created Mouse and Keyboard to join JoyStick and provided them with a templated base class (InputDeviceTemplated) that does most of the work (reduces quite some redundancy)
  • Created InputPrereqs.h from InputInterfaces.h and destroyed the latter
  • Exported InputHandler to its own file and replaced KeyHandler, MouseHandler and JoyStickHandler with the single InputHandler.
  • Deleted the SimpleInputState: There is only one class now which fulfills all our needs.

In general there is now less code and the code itself has more 'pluses'. However I haven't really thrown away any feature at all.

  • Property svn:eol-style set to native
File size: 3.5 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
32    Declarations of various interface classes for the input management.
33*/
34
35#ifndef _InputHandler_H__
36#define _InputHandler_H__
37
38#include "InputPrereqs.h"
39#include "util/Math.h"
40
41namespace orxonox
42{
43    /**
44    @brief
45    */
46    class _CoreExport InputHandler
47    {
48    public:
49        virtual ~InputHandler() { }
50
51        template<class T> void buttonEvent(unsigned int device, const T& button, ButtonEvent::TPress)
52            { this->buttonPressed(button); }
53        template<class T> void buttonEvent(unsigned int device, const T& button, ButtonEvent::TRelease)
54            { this->buttonReleased(button); }
55        template<class T> void buttonEvent(unsigned int device, const T& button, ButtonEvent::THold)
56            { this->buttonHeld(button); }
57        void buttonEvent(unsigned int device, JoyStickButtonCode::ByEnum button, ButtonEvent::TPress)
58            { this->buttonPressed(device - InputDeviceEnumerator::FirstJoyStick, button); }
59        void buttonEvent(unsigned int device, JoyStickButtonCode::ByEnum button, ButtonEvent::TRelease)
60            { this->buttonReleased(device - InputDeviceEnumerator::FirstJoyStick, button); }
61        void buttonEvent(unsigned int device, JoyStickButtonCode::ByEnum button, ButtonEvent::THold)
62            { this->buttonHeld(device - InputDeviceEnumerator::FirstJoyStick, button); }
63
64        virtual void buttonPressed (const KeyEvent& evt) { }
65        virtual void buttonReleased(const KeyEvent& evt) { }
66        virtual void buttonHeld    (const KeyEvent& evt) { }
67
68        virtual void buttonPressed (MouseButtonCode::ByEnum button) { }
69        virtual void buttonReleased(MouseButtonCode::ByEnum button) { }
70        virtual void buttonHeld    (MouseButtonCode::ByEnum button) { }
71        virtual void mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) { }
72        virtual void mouseScrolled (int abs, int rel) { }
73
74        virtual void buttonPressed (unsigned int joyStick, JoyStickButtonCode::ByEnum button) { }
75        virtual void buttonReleased(unsigned int joyStick, JoyStickButtonCode::ByEnum button) { }
76        virtual void buttonHeld    (unsigned int joyStick, JoyStickButtonCode::ByEnum button) { }
77        virtual void axisMoved     (unsigned int joyStick, unsigned int axis, float value){ }
78
79        virtual void keyboardUpdated(float dt) { }
80        virtual void mouseUpdated   (float dt) { }
81        virtual void joyStickUpdated(unsigned int joyStick, float dt) { }
82
83        virtual void allDevicesUpdated(float dt) { }
84
85        static InputHandler EMPTY;
86    };
87}
88
89#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.