Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/input/Mouse.h @ 8972

Last change on this file since 8972 was 7809, checked in by rgrieder, 14 years ago

Fixed Doxygen problem ('Template' is not always a type).

  • Property svn:eol-style set to native
File size: 2.9 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#ifndef _Core_Mouse_H__
30#define _Core_Mouse_H__
31
32#include "InputPrereqs.h"
33
34#include "InputDevice.h"
35#include "core/WindowEventListener.h"
36
37namespace orxonox
38{
39    //! %Template parameter collection for the base class
40    struct MouseTraits
41    {
42        typedef Mouse DeviceClass;
43        typedef OIS::Mouse OISDeviceClass;
44        typedef MouseButtonCode::ByEnum ButtonType;
45        typedef MouseButtonCode::ByEnum ButtonTypeParam;
46        static const OIS::Type OISDeviceValue = OIS::OISMouse;
47    };
48
49    /**
50    @brief
51        Wraps around an OIS::Mouse and forwards the input events to
52        a list of input states.
53    */
54    class _CoreExport Mouse
55        : public InputDeviceTemplated<MouseTraits>
56        , public OIS::MouseListener
57        , public WindowEventListener
58    {
59        friend class InputDeviceTemplated<MouseTraits>;
60        //! Super class alias
61        typedef InputDeviceTemplated<MouseTraits> super;
62
63    public:
64        //! Only sets the clipping size. Initialising is done in the base class.
65        Mouse(unsigned int id, OIS::InputManager* oisInputManager);
66        ~Mouse();
67
68#ifdef ORXONOX_PLATFORM_LINUX
69        // TODO: Make this a feature rather than a hack
70        void grab();
71        void ungrab();
72#endif
73
74    private:
75        //! OIS event handler
76        bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
77        {
78            super::buttonPressed(static_cast<MouseButtonCode::ByEnum>(id));
79            return true;
80        }
81
82        //! OIS event handler
83        bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
84        {
85            super::buttonReleased(static_cast<MouseButtonCode::ByEnum>(id));
86            return true;
87        }
88
89        bool mouseMoved(const OIS::MouseEvent &arg);
90
91        void windowResized(unsigned int newWidth, unsigned int newHeight);
92
93        // Returns the class name as string
94        static std::string getClassNameImpl() { return "Mouse"; }
95    };
96}
97
98#endif /* _Core_Mouse_H__ */
Note: See TracBrowser for help on using the repository browser.