Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core4/src/core/input/Mouse.h @ 3276

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

Moved grab/ungrab mouse hack for Linux from InputManager to Mouse.

  • 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#include "InputDevice.h"
34
35namespace orxonox
36{
37    /**
38    @brief
39        Wraps around an OIS::Mouse and forwards the input events to
40        a list of input states.
41    */
42    class _CoreExport Mouse
43        : public InputDeviceTemplated<MouseTraits>
44        , public OIS::MouseListener
45    {
46        friend class InputDeviceTemplated<MouseTraits>;
47        //! Super class alias
48        typedef InputDeviceTemplated<MouseTraits> super;
49
50    public:
51        Mouse(unsigned int id, unsigned int windowWidth, unsigned int windowHeight);
52        ~Mouse() { }
53
54        /**
55        @brief
56            Adjusts the mouse window metrics.
57
58            This method has to be called every time the size of the window changes.
59        */
60        void setMouseClipping(unsigned int width, unsigned int height);
61        unsigned int getClippingWidth() const;
62        unsigned int getClippingHeight() const;
63
64        // HACK!
65        static void setMouseClipping_s(unsigned int width, unsigned int height)
66            { instancePointer_s->setMouseClipping(width, height); }
67        void setConfigValues() { }
68#ifdef ORXONOX_PLATFORM_LINUX
69        // HACK!
70        static void grabMouse();
71        static void ungrabMouse();
72#endif
73
74    private:
75        // TODO: Do we need to reset the mouse position?
76        void clearBuffersImpl() { }
77
78        //! OIS event handler
79        bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
80        {
81            super::buttonPressed(static_cast<MouseButtonCode::ByEnum>(id));
82            return true;
83        }
84
85        //! OIS event handler
86        bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
87        {
88            super::buttonReleased(static_cast<MouseButtonCode::ByEnum>(id));
89            return true;
90        }
91
92        bool mouseMoved(const OIS::MouseEvent &arg);
93
94        // HACK:
95        static Mouse* instancePointer_s;
96    };
97}
98
99#endif /* _Core_Mouse_H__ */
Note: See TracBrowser for help on using the repository browser.